Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Cloudflare app in Grafana from code?

I'm using Grafana based on the helm chart, at the moment I have all the configurations as code, the main configuration is placed into the vales.yaml as part of the grafana.ini values, the dashboards and datasources are placed into configmaps per each datasource or dashboard and the sidecar container is in charge of taking them based on the labels.

Now I want to use apps and the first app I'm trying is the Cloudflare app from here, the app is installed correctly using the plugins section in the chart values.yaml but I don't see any documentation of how to pass the email and token of CloudFlare API by configMap or json.

Is it possible? or do I have to configure it manually inside the app settings?

like image 947
wolmi Avatar asked Nov 25 '19 16:11

wolmi


2 Answers

Grafana plugins are provisionable datasources.

The CloudFlare App plugin uses "{{.SecureJsonData.token}}" for X-Auth-Key and "{{.JsonData.email}}"} for X-Auth-Email.

You could provision the Cloudflare app plugin datasource with jsonData and secureJsonData you like to use.

The datasource name is the id given in Cloudflare app plugin plugin.yaml file.

You may configure jsonData and secureJsonData for this datasource in datasources field in values.yaml.

For example,

datasources: 
  datasources.yaml:
    apiVersion: 1
    datasources:
    - name: cloudflare-app
      jsonData:
        email: [email protected]
      secureJsonData:
        token: extra-tolkien
like image 146
Oluwafemi Sule Avatar answered Nov 15 '22 09:11

Oluwafemi Sule


To update this answer, this plugin began support of API tokens in December 2020. In order to have the Grafana provisioner pick up your token, if you're using an API token instead of the email/API key, you must specify:

    jsonData:
      bearerSet: true
    secureJsonData:
      bearer: "your-api-token"
like image 37
paladin-devops Avatar answered Nov 15 '22 11:11

paladin-devops