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

Setup Error for custom-metrics.libsonnet

Open jnccneto opened this issue 3 years ago • 6 comments

Discussed in https://github.com/prometheus-operator/kube-prometheus/discussions/1585

Originally posted by jnccneto January 17, 2022 Hello

I have setup the bundle following the repo instructions: https://github.com/prometheus-operator/kube-prometheus

Standart is ok, and I have CPU/MEMORY POD metrics. Now I need custom metrics but I get an error when building with jsonet and enabled custom-metrics.libsonnet. Any ideas on how to fix it?

error output:

RUNTIME ERROR: max stack frames exceeded. vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object ... vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/addons/custom-metrics.libsonnet:7:18-54 object vendor/kube-prometheus/components/prometheus-adapter.libsonnet:141:20-40 object During manifestation

my jsonet file:

`local kp = (import 'kube-prometheus/main.libsonnet') + // Uncomment the following imports to enable its patches // (import 'kube-prometheus/addons/anti-affinity.libsonnet') + // (import 'kube-prometheus/addons/managed-cluster.libsonnet') + (import 'kube-prometheus/addons/node-ports.libsonnet') + // (import 'kube-prometheus/addons/static-etcd.libsonnet') + (import 'kube-prometheus/addons/custom-metrics.libsonnet') + // (import 'kube-prometheus/addons/external-metrics.libsonnet') + { values+:: { common+: { namespace: 'monitoring', }, }, };

{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } + { ['setup/prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator)) } + // serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready { 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } + { 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } + { 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } + { ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } + { ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } + { ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } + { ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } + { ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) } { ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } + { ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } + { ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }`

jnccneto avatar Jan 18 '22 08:01 jnccneto

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 Mar 20 '22 02:03 github-actions[bot]

I have the same problem!

Dspatharakis avatar Apr 06 '22 15:04 Dspatharakis

I ended up using the Helm chart installation. Works better

jnccneto avatar Apr 07 '22 06:04 jnccneto

I got the same issue (as discussed in #1585 ), and the problem was in the custom-metrics.libsonnet. The offending lines are at

{
  values+:: {
    prometheusAdapter+: {
      namespace: $.values.prometheusAdapter.namespace,

I think (Not really sure) that this is looping back to including the local variable initialization in example.jsonnet (and into the custom-metrics.libsonnet), which then loops back to this and then back to the original file. When I changed that value from $.values.prometheusAdapter.namespace to my namespace, say, monitoring, the build works properly and I was able to get the manifests.

I havent really worked out how to separate out the variables included in the example.jsonnet separately so that this wont loop itself again but thought Id share in case anyone faces this.

rajasaur avatar May 01 '22 07:05 rajasaur

Did what @rajasaur proposed and it worked, but the prometheus-adapter pod keeps restarting...

MatTerra avatar May 20 '22 21:05 MatTerra

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 Jul 20 '22 03:07 github-actions[bot]

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 Jan 13 '23 03:01 github-actions[bot]

This issue was closed because it has not had any activity in the last 120 days. Please reopen if you feel this is still valid.

github-actions[bot] avatar May 14 '23 03:05 github-actions[bot]

We're experiencing this issue on the release-0.11 branch (commit e3066575dc8b)

edwargix avatar Jul 18 '23 14:07 edwargix