povilasv / coredns-mixin

A set of Prometheus alerts & grafana dashboards for CoreDNS.
Apache License 2.0
22 stars 17 forks source link

Does not work without providing entire grafana configuration in _config #7

Open ananthdas opened 4 years ago

ananthdas commented 4 years ago

Hi, I am trying to get this to work with kube-prometheus customization but am unable to do so. To narrow the issue, I started with a fresh workspace and then modified their all-namespaces.jsonnet to include coredns mixin as follows:

local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
           (import 'kube-prometheus/kube-prometheus-all-namespaces.libsonnet') +
           (import 'coredns-mixin/mixin.libsonnet') +{
  _config+:: {
    namespace: 'monitoring',

    prometheus+:: {
      namespaces: [],
    },
  },
};

{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }

I get the below error:

  • jsonnet -J vendor -m manifests example1.jsonnet
  • xargs '-I{}' sh -c 'cat {} | gojsontoyaml > {}.yaml' -- '{}' RUNTIME ERROR: Field does not exist: config vendor/grafana/grafana.libsonnet:47:20-44 thunk from <object > vendor/grafana/grafana.libsonnet:47:9-45 object example1.jsonnet:19:70-80 thunk from <$>

    :1293:24-25 thunk from > :1293:5-33 function example1.jsonnet:19:53-81 $ During evaluation

I tried by adding config for Grafana as follows in the _config section

grafana+:: {
      config+: {
        sections+: {
          server+: {
            root_url: 'https://grafana.10-0-2-15.nip.io/',
          },
        },
        ldap: null,
      },
    },

This results in the below error:

  • jsonnet -J vendor -m manifests example1.jsonnet
  • xargs '-I{}' sh -c 'cat {} | gojsontoyaml > {}.yaml' -- '{}' RUNTIME ERROR: Field does not exist: ldap vendor/grafana/grafana.libsonnet:50:32-54 thunk from <object > vendor/grafana/grafana.libsonnet:51:36-49 thunk from <object > vendor/ksonnet/ksonnet.beta.4/k8s.libsonnet:9656:82-86 vendor/ksonnet/ksonnet.beta.4/k8s.libsonnet:9658:41-45 object During manifestation

I ended up providing entire grafana configuration. Below is my final _config+::

 _config+:: {
    namespace: 'monitoring',
    grafana+:: {
      config+: {
        sections+: {
          server+: {
            root_url: 'https://grafana.10-0-2-15.nip.io/',
          },
        },
      },
      ldap: null,
      datasources: [{
      }],
      dashboards: {},
      folderDashboards: {},
      rawDashboards: {},
      container: {
        requests: { cpu: '100m', memory: '100Mi' },
        limits: { cpu: '200m', memory: '200Mi' },
      },
      containers: [],
      env: [],
      plugins: [],
      port: 3000,
    },

    prometheus+:: {
      namespaces: [],
    },
  },
amoghk commented 3 years ago

@ananthdas The PR https://github.com/povilasv/coredns-mixin/pull/9 fixes this issue