Grafana
Grafana allows you to query, visualize and explore your metrics.
Instances
An overview of Gjensidige's Grafana instances is available on Confluence.
Dashboards
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.
Constructing 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 want to keep it,
you'll need to store the generated JSON model in version control via a ConfigMap
.
Grafana instances will be reset at regular intervals, thus any changes not defined as infrastructure as code will be lost.