kube-prometheus icon indicating copy to clipboard operation
kube-prometheus copied to clipboard

Adding additional datasources to Grafana config, removes Prometheus datasource

Open pslobo opened this issue 3 years ago • 3 comments

What happened? When adding addition datasources to Grafana, the resulting config no longer has Prometheus datasource.

Config 1

local kp =
  (import 'kube-prometheus/main.libsonnet') +
  {
    values+:: {
      common+: {
        namespace: 'observability',
        platform: 'gke',

        versions+: {
          grafana: '8.0.6',
        },
      },

      grafana+: {
        config: {
          sections: import 'grafana-config.json',
        },
      },
    },
.....

Result 1

{
    "apiVersion": 1,
    "datasources": [
        {
            "access": "proxy",
            "editable": false,
            "name": "prometheus",
            "orgId": 1,
            "type": "prometheus",
            "url": "http://prometheus-k8s.observability.svc:9090",
            "version": 1
        }
    ]
}

Config 2

local kp =
  (import 'kube-prometheus/main.libsonnet') +
  {
    values+:: {
      common+: {
        namespace: 'observability',
        platform: 'gke',

        versions+: {
          grafana: '8.0.6',
        },
      },

      grafana+: {
        config: {
          sections: import 'grafana-config.json',
        },
        datasources+:: [
          {
            name: 'Loki',
            type: 'loki',
            access: 'proxy',
            org_id: 1,
            url: 'http://ew-loki-gateway',
            version: 1,
            editable: false,
            jsonData: {
              maxLines: 2000,
              derivedFields: [{
                datasourceUid: 'tempo',
                matcherRegex: '"trace_id":"(\\w+)"',
                name: 'TraceID',
                url: '$${__value.raw}',
              }],
            },
          },
          {
            name: 'Tempo',
            type: 'jaeger',
            access: 'proxy',
            uid: 'tempo',
            org_id: 1,
            url: 'http://ew-tempo-query-frontend:16686',
            version: 1,
            editable: false,
          },
        ],
      },
    },
.....

Result 2

{
    "apiVersion": 1,
    "datasources": [
        {
            "access": "proxy",
            "editable": false,
            "jsonData": {
                "derivedFields": [
                    {
                        "datasourceUid": "tempo",
                        "matcherRegex": "\"trace_id\":\"(\\w+)\"",
                        "name": "TraceID",
                        "url": "$${__value.raw}"
                    }
                ],
                "maxLines": 2000
            },
            "name": "Loki",
            "org_id": 1,
            "type": "loki",
            "url": "http://ew-loki-gateway",
            "version": 1
        },
        {
            "access": "proxy",
            "editable": false,
            "name": "Tempo",
            "org_id": 1,
            "type": "jaeger",
            "uid": "tempo",
            "url": "http://ew-tempo-query-frontend:16686",
            "version": 1
        }
    ]
}

Did you expect to see some different? I expected to see something similar to what happened with release-04, namely:

{
    "apiVersion": 1,
    "datasources": [
        {
            "access": "proxy",
            "editable": false,
            "name": "prometheus",
            "orgId": 1,
            "type": "prometheus",
            "url": "http://prometheus-k8s.observability.svc:9090",
            "version": 1
        },
        {
            "access": "proxy",
            "editable": false,
            "jsonData": {
                "derivedFields": [
                    {
                        "datasourceUid": "tempo",
                        "matcherRegex": "\"trace_id\":\"(\\w+)\"",
                        "name": "TraceID",
                        "url": "$${__value.raw}"
                    }
                ],
                "maxLines": 2000
            },
            "name": "Loki",
            "org_id": 1,
            "type": "loki",
            "url": "http://ew-loki-gateway",
            "version": 1
        },
        {
            "access": "proxy",
            "editable": false,
            "name": "Tempo",
            "org_id": 1,
            "type": "jaeger",
            "uid": "tempo",
            "url": "http://ew-tempo-query-frontend:16686",
            "version": 1
        }
    ]
}

However, changing this line to { datasources+: g._config.datasources } produced the desired results.

How to reproduce it (as minimally and precisely as possible): Tested on release-08 and HEAD. Should be reproducible with minimal jsonnet as long as it adds additional datasources to Grafana.

pslobo avatar Jul 26 '21 19:07 pslobo

This issue has been automatically marked as stale because it has not had any activity in the last 60 days. Thank you for your contributions.

github-actions[bot] avatar Nov 07 '21 02:11 github-actions[bot]

I can confirm

unintended avatar Jan 18 '22 10:01 unintended

I seem to be having the same issue using release-0.8. Any updates?

kristofferahl avatar Mar 21 '22 13:03 kristofferahl