Skip to content

Commit

Permalink
Improve custom dashboard addition in Grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad-Faizan authored and ashish1099 committed Oct 18, 2023
1 parent 0b15c80 commit fed50ba
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
29 changes: 29 additions & 0 deletions build/kube-prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,35 @@ jsonnet -e '(import "mixin.libsonnet").prometheusAlerts' | gojsontoyaml > promet
```
kubectl apply -f <path to alert rules file>.yaml -n monitoring
```
## Adding Support for Custom Dashboards in Grafana
### To add custom Grafana dashboards to Grafana via GitOps:
- Open the **Dashboard settings** from Grafana for the dashboard you want to add.
- Click on **JSON Model** on the left hand pane, and copy the JSON into a file on your k8id-config repo.
- Add a _folder name_ and the path to the dashboard in your cluster specific jsonnet file.
See [example jsonnet file](./examples/k8id_managed.jsonnet) for details.
```jsonnet
grafana_dashboards: {
'Custom Grafana Folder': {
'custom-dashboard.json': (import '../path/to/custom-dashboard.json'),
},
},
```
- Run the [build command](#run-the-build-script) with the path to your _cluster specific jsonnet file_ to generate the changes.
- Push the changes to your _k8id config_ repo and sync the changes in _kube-prometheus_ app on ArgoCD.
- The Grafana pod will restart after the ArgoCD sync and will reflect the new dashboard once you are logged in.
### To persist the changes made to a custom dashboard:
- Save the changes made to the dashboard on Grafana.
- Copy the JSON model of the dashboard from the **Dashboard Settings**.
- Paste and overwrite the `custom-dashboard.json` file in your k8id-config repo.
- Run the build script and merge the changes on your k8id-config repo.
- Sync the changes in ArgocD app (expect changes in ConfigMap k8s resource).
- The Grafana pod will restart and the dashboard changes will be persisted now.
## Jsonnet debugging
Expand Down
2 changes: 1 addition & 1 deletion build/kube-prometheus/common-template.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ local kp =
grafana+: {
plugins: vars.grafana_plugins,
resources: vars.grafana_resources,
rawDashboards+:: vars.grafana_dashboards,
folderDashboards+:: vars.grafana_dashboards,
analytics+: {
check_for_updates: false,
},
Expand Down
1 change: 0 additions & 1 deletion build/kube-prometheus/examples/k8id_managed.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
grafana_ingress_annotations: {
'kubernetes.io/ingress.class': 'traefik-cert-manager',
},

}

0 comments on commit fed50ba

Please sign in to comment.