-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added database monitoring overview * Elasticsearch: Updated buitin Prometheus doc * Memcached: Updated builtin Prometheus doc * MongoDB: Updated builtin Prometheus doc * MySQL: Updated builtin Prometheus doc * Postgres: Updated builtin Prometheus doc * Redis: Updated builtin Prometheus doc * Elasticsearch: Updated coreos Prometheus operator doc * Memcached: Updated coreos Prometheus doc * MongoDB: Updated coreos Prometheus doc * MySQL: Updated coreos Prometheus doc * Postgres: Updated coreos Prometheus doc * Redis: Updated coreos Prometheus doc * updated Prometheus discovery job + docs + image
- Loading branch information
1 parent
fac6475
commit e98d128
Showing
99 changed files
with
2,580 additions
and
2,775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: Database Monitoring | KubeDB | ||
description: Database Monitoring | ||
menu: | ||
docs_0.9.0: | ||
identifier: database-monitoring | ||
parent: concepts | ||
name: Database Monitoring | ||
weight: 30 | ||
menu_name: docs_0.9.0 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
title: Database Monitoring Overview | ||
description: Database Monitoring Overview | ||
menu: | ||
docs_0.9.0: | ||
identifier: database-monitoring-overview | ||
name: Overview | ||
parent: database-monitoring | ||
weight: 10 | ||
menu_name: docs_0.9.0 | ||
section_menu_id: concepts | ||
--- | ||
|
||
# Monitoring Database with KubeDB | ||
|
||
KubeDB has native support for monitoring via [Prometheus](https://prometheus.io/). You can use builtin [Prometheus](https://github.com/prometheus/prometheus) scrapper or [CoreOS Prometheus Operator](https://github.com/coreos/prometheus-operator) to monitor KubeDB managed databases. This tutorial will show you how database monitoring works with KubeDB and how to configure Database crd to enable monitoring. | ||
|
||
## Overview | ||
|
||
KubeDB uses Prometheus [exporter](https://prometheus.io/docs/instrumenting/exporters/#databases) images to export Prometheus metrics for respective databases. Following diagram shows the logical flow of database monitoring with KubeDB. | ||
|
||
<p align="center"> | ||
<img alt="Database Monitoring Flow" src="/docs/images/concepts/monitoring/database-monitoring-overview.svg"> | ||
</p> | ||
|
||
When a user creates a database crd with `spec.monitor` section configured, KubeDB operator provisions the respective database and injects an exporter image as sidecar to the database pod. It also creates a dedicated stats service with name `{database-crd-name}-stats` for monitoring. Prometheus server can scrape metrics using this stats service. | ||
|
||
## Configure Monitoring | ||
|
||
In order to enable monitoring for a database, you have to configure `spec.monitor` section. KubeDB provides following options to configure `spec.monitor` section: | ||
|
||
| Field | Type | Uses | | ||
| ----------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `spec.monitor.agent` | `Required` | Type of the monitoring agent that will be used to monitor this database. It can be `prometheus.io/builtin` or `prometheus.io/coreos-operator`. | | ||
| `spec.monitor.prometheus.namespace` | `Optional` | Namespace where the Prometheus server is running or will be deployed. For agent type `prometheus.io/coreos-operator`, `ServiceMonitor` crd will be created in this namespace. | | ||
| `spec.monitor.prometheus.labels` | `Optional` | Labels for `ServiceMonitor` crd. | | ||
| `spec.monitor.prometheus.port` | `Optional` | Port number where the exporter side car will serve metrics. | | ||
| `spec.monitor.prometheus.interval` | `Optional` | Interval at which metrics should be scraped. | | ||
| `spec.monitor.args` | `Optional` | Arguments to pass to the exporter sidecar. | | ||
| `spec.monitor.env` | `Optional` | List of environment variables to set in the exporter sidecar container. | | ||
| `spec.monitor.resources` | `Optional` | Resources required by exporter sidecar container. | | ||
| `spec.monitor.securityContext` | `Optional` | Security options the exporter should run with. | | ||
|
||
## Sample Configuration | ||
|
||
A sample YAML for Redis crd with `spec.monitor` section configured to enable monitoring with CoreOS [prometheus-operator](https://github.com/coreos/prometheus-operator) is shown below. | ||
|
||
```yaml | ||
apiVersion: kubedb.com/v1alpha1 | ||
kind: Redis | ||
metadata: | ||
name: sample-redis | ||
namespace: databases | ||
spec: | ||
version: "4.0-v1" | ||
terminationPolicy: WipeOut | ||
configSource: # configure Redis to use password for authentication | ||
configMap: | ||
name: redis-config | ||
storageType: Durable | ||
storage: | ||
storageClassName: default | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 5Gi | ||
monitor: | ||
agent: prometheus.io/coreos-operator | ||
prometheus: | ||
namespace: monitoring | ||
labels: | ||
k8s-app: prometheus | ||
args: | ||
- --redis.password=$(REDIS_PASSWORD) | ||
env: | ||
- name: REDIS_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: _name_of_secret_with_redis_password | ||
key: password # key with the password | ||
resources: | ||
requests: | ||
memory: 512Mi | ||
cpu: 200m | ||
limits: | ||
memory: 512Mi | ||
cpu: 250m | ||
securityContext: | ||
runAsUser: 2000 | ||
allowPrivilegeEscalation: false | ||
``` | ||
Assume that above Redis is configured to use basic authentication. So, exporter image also need to provide password to collect metrics. We have provided it through `spec.monitor.args` field. | ||
|
||
Here, we have specified that we are going to monitor this server using CoreOS prometheus-operator through `spec.monitor.agent: prometheus.io/coreos-operator`. KubeDB will create a `ServiceMonitor` crd in `monitoring` namespace and this `ServiceMonitor` will have `k8s-app: prometheus` label. | ||
|
||
## Next Steps | ||
|
||
- Learn how to monitor Elasticsearch database with KubeDB using [builtin-Prometheus](/docs/guides/elasticsearch/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/elasticsearch/monitoring/using-coreos-prometheus-operator.md). | ||
- Learn how to monitor PostgreSQL database with KubeDB using [builtin-Prometheus](/docs/guides/postgres/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/postgres/monitoring/using-coreos-prometheus-operator.md). | ||
- Learn how to monitor MySQL database with KubeDB using [builtin-Prometheus](/docs/guides/mysql/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/mysql/monitoring/using-coreos-prometheus-operator.md). | ||
- Learn how to monitor MongoDB database with KubeDB using [builtin-Prometheus](/docs/guides/mongodb/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/mongodb/monitoring/using-coreos-prometheus-operator.md). | ||
- Learn how to monitor Redis server with KubeDB using [builtin-Prometheus](/docs/guides/redis/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/redis/monitoring/using-coreos-prometheus-operator.md). | ||
- Learn how to monitor Memcached server with KubeDB using [builtin-Prometheus](/docs/guides/memcached/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/memcached/monitoring/using-coreos-prometheus-operator.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
docs/examples/concepts/database-monitoring/sample-redis-mon.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apiVersion: kubedb.com/v1alpha1 | ||
kind: Redis | ||
metadata: | ||
name: sample-redis | ||
namespace: databases | ||
spec: | ||
version: "4.0-v1" | ||
terminationPolicy: WipeOut | ||
configSource: # configure Redis to use password for authentication | ||
configMap: | ||
name: redis-config | ||
storageType: Durable | ||
storage: | ||
storageClassName: default | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 5Gi | ||
monitor: | ||
agent: prometheus.io/coreos-operator | ||
prometheus: | ||
namespace: monitoring | ||
labels: | ||
k8s-app: prometheus | ||
args: | ||
- --redis.password=$(REDIS_PASSWORD) | ||
env: | ||
- name: REDIS_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: _name_of_secret_with_redis_password | ||
key: password # key with the password | ||
resources: | ||
requests: | ||
memory: 512Mi | ||
cpu: 200m | ||
limits: | ||
memory: 512Mi | ||
cpu: 250m | ||
securityContext: | ||
runAsUser: 2000 | ||
allowPrivilegeEscalation: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...monitoring/builtin-prometheus/demo-1.yaml → ...cached/monitoring/builtin-prom-memcd.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...monitoring/builtin-prometheus/demo-1.yaml → .../mongodb/monitoring/builtin-prom-mgo.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.