Grafana
Grafana allows you to query, visualize and explore your metrics.
Instances
An overview of Gjensidige's Grafana instances is available on Confluence.
Managing dashboards via GUI
In Grafana under Dashboards -> Browse
you will find a folder called playground
. Here you may create a new dashboard and start building it.
Once you are happy with the dashboard and have saved it, you can also choose to commit the JSON model into your infrastructure as code (see next section). Once it is managed as code, you can no longer edit it in the GUI.
There is no practical difference, and is mostly a matter of team preference. Dashboards that are managed as infrastructure, are stored in a code repository and deployed via ArgoCD. Dashboards that are managed with the GUI, are saved to a high availability database with backups.
Managing dashboards as infrastructure
Dashboards in Grafana can be managed by provisioning ConfigMap
resources containing dashboards in JSON format.
Example:
apiVersion: v1
kind: ConfigMap
metadata:
name: my-sample-dashboard
namespace: team-demo
labels:
grafana_dashboard: '1'
annotations:
k8s-sidecar-target-directory: /tmp/dashboards/team-demo
data:
my-sample-dashboard.json: |-
{
"title": "Demo Example",
"uid": "demo-example", // Be aware the uid has a limit of 40 chars and has to be unique across all dashboards
...
}
-
Specify
name
andnamespace
for theConfigMap
. -
The label
grafana_dashboard: '1'
is required for the Grafana sidecar to be able to pick up theConfigMap
. -
The annotation
k8s-sidecar-target-directory
should be set to a directory under/tmp/dashboards/
to group your dashboards into a folder in Grafana. -
The
data
field should contain a key-value pair where the key is a file name (ending with.json
) and the value is the JSON model of a dashboard. To start with an empty dashboard you'll only need to specify thetitle
anduid
field in the JSON model.cautionGrafana dashboard UID can have a maximum length of 40 characters.
JSON modelA dashboard in Grafana is represented by a JSON object, which includes metadata, queries, variables, data sources, panel details, etc.
You can use a premade dashboard or build your own.
-
To use a premade dashboard, f.ex. from grafana.com, you can obtain its JSON model by clicking on the 'Download JSON' button on the detail page of the dashboard.
-
To use a custom dashboard, create/update a dashboard using Grafana’s UI. Once complete, click on the gear icon in the top navigation menu to go to the dashboard’s settings. Then, in the left navigation menu, click 'JSON Model', and copy the JSON data structure that appears.
-
Deploying dashboards
Deploy the ConfigMap
to your namespace using Argo CD.