prometheus-operator / kube-prometheus

Use Prometheus to monitor Kubernetes and applications running on Kubernetes

Home Page:https://prometheus-operator.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

done

zyz-1998 opened this issue · comments

What happened?

question

How can I change the relabel_config of the existing job_name? For example, I want the key-value relationship based on the external json storage to be the corresponding job_name: kube-state-metrics. Add a new label to the indicator. I think this is very necessary to manage multi-cluster indicators. I hope you can help me.

desired effect

before

``
kube_pod_labels{container="kube-rbac-proxy-main", endpoint="https-main", instance="10.244.140.84:8443", job="kube-state-metrics", label_app="example-app"}
`

{ "example-app": " testdata" }

after new add metrics

kube_pod_labels{container="kube-rbac-proxy-main", endpoint="https-main", instance="10.244.140.84:8443", job="kube-state-metrics", label_app="example-app", module="testdata"}

Prometheus Operator Version

kube-prometheus-0.13.0

Kubernetes Version

kube-prometheus-0.13.0

Kubernetes Cluster Type

kubeadm

How did you deploy Prometheus-Operator?

prometheus-operator/kube-prometheus

Manifests

kube-prometheus-0.13.0

prometheus-operator log output

kube-prometheus-0.13.0

Anything else?

No response

This looks to be question for kube-prometheus config

Did you check https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/customizing.md?

Is this scenario unable to be solved through prometheus-operator ? What methods can you recommend? Thank you.

This looks to be question for kube-prometheus config

Did you check https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/customizing.md?

The kube-prometheus has been deployed in the production environment. I hope it can be modified on the existing basis. What are the ways? Thank you.

https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.RelabelConfig is available if you want to add new relabelling. IIUC you are asking how to do this since you deploy operator through kube-prometheus?

如果您想添加新的重新标签,可以使用 https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.RelabelConfig。IIUC 您问如何做到这一点,因为您通过 kube-prometheus 部署了 operator?

We are from different teams. The previously deployed personnel have left. The current production environment is deployed with kube-prometheus version 0.8. We currently want the indicators collected by kube-state-metrics to be processed based on the external relationship file json, but the configuration of prometheus is done by Prometheus. Generated by operator, that is, the secret in the monitor and Prometheus.yaml.gz in prometheus-k8s. At present, I have not found the location to change the configuration. It seems that I can only redeploy it.

https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.RelabelConfig is available if you want to add new relabelling. IIUC you are asking how to do this since you deploy operator through kube-prometheus?

Would you like to know how to modify the prometheus configuration file deployed by prometheus-operator and ensure that it takes effect permanently? The current one is the default - --config.file=/etc/prometheus/config_out/prometheus.env.yaml. Thank you very much.

The scrape configuration comes from a ServiceMonitor object which you'd need to modify.
If the installation has been made via kube-prometheus, the object is named "kube-state-metrics":

kubectl get -n monitoring servicemonitors kube-state-metrics

The scrape configuration comes from a ServiceMonitor object which you'd need to modify. If the installation has been made via kube-prometheus, the object is named "kube-state-metrics":

kubectl get -n monitoring servicemonitors kube-state-metrics

image

The scrape configuration comes from a ServiceMonitor object which you'd need to modify. If the installation has been made via kube-prometheus, the object is named "kube-state-metrics":

kubectl get -n monitoring servicemonitors kube-state-metrics

Thanks for your help, but there still seems to be a problem
I edited kubeStateMetrics-serviceMonitor.yaml and added the following:
`
relabelings:
- action: labeldrop
regex: (pod|service|endpoint|namespace)

 - sourceLabels: [app]
   regex: nginx
   replacement: 'my-nginx-test'
   targetLabel: module

 - sourceLabels: [label_app]
   regex: nginx
   replacement: 'my-nginx-test-label'
   targetLabel: module

 - sourceLabels: [app]
   regex: tip-1
   replacement: '\u540e\u7aef\u6a21\u5757'
   targetLabel: module

 - sourceLabels: [app]
   regex: tip-2
   replacement: '\u524d\u7aef\u6a21\u5757'
   targetLabel: module

`
Enter the prometheus container and you can see that it has taken effect, but it seems that the indicators still have not changed.

image
image