prometheus-operator / kube-prometheus

Use Prometheus to monitor Kubernetes and applications running on Kubernetes
https://prometheus-operator.dev/
Apache License 2.0
6.62k stars 1.92k forks source link

Adding additional datasources to Grafana config, removes Prometheus datasource #1280

Open pslobo opened 3 years ago

pslobo commented 3 years ago

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.

github-actions[bot] commented 2 years ago

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.

unintended commented 2 years ago

I can confirm

kristofferahl commented 2 years ago

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