Skip to content

Grafana DataSource example

Back

This example show how to add Grafana DataSource to collect data from different sources.

Overview

Grafana uses datasources to retrieve data from various sources and display it on dashboards. Every datasource has a type to specify which source of data will be used (Prometheus, InfluxDB, Graphite, Jaeger, etc.). Some the most popular types are available by default, but to support the rest, the corresponding plugins must be installed in Grafana.

Datasource has information about connection to source of data and some support information (credentials, time intervals between scraping metrics, HTTP headers, etc.).

You can add datasource via Grafana UI (see more in official documentation), but the datasources created in this way will be deleted as soon as the Grafana instance is rebooted.

This document describes how to add Grafana datasource as Custom Resource for the grafana-operator.

DataSource

...
spec:
  name: simple-datasource-example.yaml
  datasources:
  - name: Prometheus datasource
    type: prometheus
    access: proxy
    ...

It means that datasource with name Prometheus datasource and type prometheus will be added to Grafana.

One DataSource CR can handle multiple datasources with unique names.

Required fields for every datasource: name, type, access. Full list of parameters is unique for each type of datasource.

Files

See more examples in the grafana-operator repository.

How to apply the simple example

Kubernetes:

kubectl apply -f simple-datasource-example.yaml

OpenShift:

oc apply -f simple-datasource-example.yaml