Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alerts to Grafana dashboards #740

Merged
merged 19 commits into from
Dec 14, 2023
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,65 @@ jobs:
./hack/scripts/update-chart-dependencies.sh
make ci

- name: Test Grafana Dashboards
run: |
echo "all db dashboards"
helm template charts/kubedb-grafana-dashboards
echo "-----------------------------------------"
echo "elasticsearch dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=elasticsearch \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "kafka dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=kafka \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "mariadb dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=mariadb \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "mongodb dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=mongodb \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "mysql dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=mysql \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "perconaxtradb dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=perconaxtradb \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "postgres dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=postgres \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "proxysql dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=proxysql \
--set app.name=mydb \
--set app.namespace=demo
echo "-----------------------------------------"
echo "redis dashboard with alerts"
helm template charts/kubedb-grafana-dashboards \
--set resources[0]=redis \
--set app.name=mydb \
--set app.namespace=demo

kubernetes:
name: Kubernetes
runs-on: ubuntu-20.04
Expand Down
33 changes: 21 additions & 12 deletions charts/kubedb-grafana-dashboards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,32 @@ The command removes all the Kubernetes components associated with the chart and

The following table lists the configurable parameters of the `kubedb-grafana-dashboards` chart and their default values.

| Parameter | Description | Default |
|---------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------------------------|
| nameOverride | Overrides name template | <code>""</code> |
| fullnameOverride | Overrides fullname template | <code>""</code> |
| resources | List of resources for which dashboards will be applied | <code>["elasticsearch","mariadb","mongodb","mysql","postgres","redis","proxysql"]</code> |
| dashboard.folderID | ID of Grafana folder where these dashboards will be applied | <code>0</code> |
| dashboard.overwrite | If true, dashboard with matching uid will be overwritten | <code>true</code> |
| dashboard.templatize.title | If true, datasource will be prefixed to dashboard name | <code>false</code> |
| dashboard.templatize.datasource | If true, datasource will be hardcoded in the dashboard | <code>false</code> |
| grafana.name | Name of Grafana Appbinding where these dashboards are applied | <code>""</code> |
| grafana.namespace | Namespace of Grafana Appbinding where these dashboards are applied | <code>""</code> |
| Parameter | Description | Default |
|---------------------------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| nameOverride | Overrides name template | <code>""</code> |
| fullnameOverride | Overrides fullname template | <code>""</code> |
| resources | List of resources for which dashboards will be applied | <code>["elasticsearch","kafka","mariadb","mongodb","mysql","perconaxtradb","postgres","proxysql","redis"]</code> |
| dashboard.folderID | ID of Grafana folder where these dashboards will be applied | <code>0</code> |
| dashboard.overwrite | If true, dashboard with matching uid will be overwritten | <code>true</code> |
| dashboard.templatize.title | If true, datasource will be prefixed to dashboard name | <code>false</code> |
| dashboard.templatize.datasource | If true, datasource will be hardcoded in the dashboard | <code>false</code> |
| dashboard.replacements.job=\"kube-state-metrics\" | | <code>job=\"kubernetes-service-endpoints\"</code> |
| dashboard.replacements.job=\"kubelet\" | | <code>job=\"kubernetes-nodes-cadvisor\"</code> |
| dashboard.replacements.job=\"repl-stats\" | | <code>job=\"kubedb-databases\"</code> |
| grafana.name | Name of Grafana Appbinding where these dashboards are applied | <code>""</code> |
| grafana.namespace | Namespace of Grafana Appbinding where these dashboards are applied | <code>""</code> |
| grafana.version | | <code>8.2.3</code> |
| grafana.jobName | | <code>kubedb-databases</code> |
| grafana.url | | <code>""</code> |
| grafana.apikey | | <code>""</code> |
| app.name | | <code>""</code> |
| app.namespace | | <code>""</code> |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example:

```bash
$ helm upgrade -i kubedb-grafana-dashboards appscode/kubedb-grafana-dashboards -n kubeops --create-namespace --version=v2023.12.11 --set resources=["elasticsearch","mariadb","mongodb","mysql","postgres","redis","proxysql"]
$ helm upgrade -i kubedb-grafana-dashboards appscode/kubedb-grafana-dashboards -n kubeops --create-namespace --version=v2023.12.11 --set resources=["elasticsearch","kafka","mariadb","mongodb","mysql","perconaxtradb","postgres","proxysql","redis"]
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $shared := and (eq .Values.app.name "") (eq .Values.app.namespace "") -}}
{
"annotations": {
"list": [
Expand Down Expand Up @@ -940,7 +941,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{name}}",
"legendFormat": {{ `"{{name}}"` }},
"refId": "A",
"step": 240
}
Expand Down Expand Up @@ -1044,7 +1045,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{name}}",
"legendFormat": {{ `"{{name}}"` }},
"refId": "A",
"step": 240
}
Expand Down Expand Up @@ -1145,7 +1146,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{name}}",
"legendFormat": {{ `"{{name}}"` }},
"refId": "A"
}
],
Expand Down Expand Up @@ -1246,7 +1247,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{name}}",
"legendFormat": {{ `"{{name}}"` }},
"refId": "A"
}
],
Expand Down Expand Up @@ -1366,7 +1367,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{name}}",
"legendFormat": {{ `"{{name}}"` }},
"metric": "",
"refId": "A",
"step": 1800
Expand Down Expand Up @@ -1474,7 +1475,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{name}}",
"legendFormat": {{ `"{{name}}"` }},
"metric": "",
"refId": "A",
"step": 1800
Expand Down Expand Up @@ -1587,7 +1588,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{ name }}",
"legendFormat": {{ `"{{name}}"` }},
"metric": "elasticsearch_breakers_tripped",
"metrics": [
{
Expand Down Expand Up @@ -1700,7 +1701,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{ name }}",
"legendFormat": {{ `"{{name}}"` }},
"refId": "A",
"step": 240
}
Expand Down Expand Up @@ -1806,7 +1807,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{name}}-RX",
"legendFormat": {{ `"{{name}}-RX"` }},
"refId": "A",
"step": 240
},
Expand All @@ -1816,7 +1817,7 @@
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{name}}-TX",
"legendFormat": {{ `"{{name}}-TX"` }},
"refId": "B",
"step": 240
}
Expand Down Expand Up @@ -1919,7 +1920,7 @@
"expr": "irate(elasticsearch_jvm_gc_collection_seconds_sum{namespace=~\"$namespace\",cluster=~\"$app\"}[1m])",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{ name }} {{ gc }}",
"legendFormat": {{ `"{{ name }} {{ gc }}"` }},
"refId": "A",
"step": 240
}
Expand Down Expand Up @@ -2008,7 +2009,6 @@
"value": "default"
},
"datasource": "${datasource}",
"definition": "label_values(kube_namespace_labels,namespace)",
"description": null,
"error": null,
"hide": 0,
Expand All @@ -2017,15 +2017,20 @@
"multi": false,
"name": "namespace",
"options": [],
{{- if $shared }}
"query": "label_values(kube_namespace_labels,namespace)",
"type": "query",
{{- else }}
"query": {{ $.Values.app.namespace | quote }},
"type": "constant",
{{- end }}
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
Expand All @@ -2040,7 +2045,6 @@
]
},
"datasource": "${datasource}",
"definition": "label_values(elasticsearch_cluster_health_status{namespace=~\"$namespace\"},cluster)",
"description": null,
"error": null,
"hide": 0,
Expand All @@ -2049,15 +2053,20 @@
"multi": true,
"name": "app",
"options": [],
{{- if $shared }}
"query": "label_values(elasticsearch_cluster_health_status{namespace=~\"$namespace\"},cluster)",
"type": "query",
{{- else }}
"query": {{ $.Values.app.name | quote }},
"type": "constant",
{{- end }}
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
Expand Down Expand Up @@ -2092,7 +2101,11 @@
]
},
"timezone": "utc",
{{- if $shared }}
"title": "KubeDB / Elasticsearch / Database",
{{- else }}
"title": {{ printf "KubeDB / Elasticsearch / Database / %s / %s" $.Values.app.namespace $.Values.app.name | quote }},
{{- end }}
"uid": "0dBMIuN7k",
"version": 4
}
Loading
Loading