prometheus operator servicemonitor 添加 label

serviceMonitorSepc.[]endpoint.relabelconfig

https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitorspecicon-default.png?t=M1FBhttps://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitorspec​​​​​​https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#endpointicon-default.png?t=M1FBhttps://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#endpointhttps://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfigicon-default.png?t=M1FBhttps://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig

来个 example

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app.kubernetes.io/component: exporter
    app.kubernetes.io/name: node-exporter
    app.kubernetes.io/part-of: kube-prometheus
    app.kubernetes.io/version: 1.1.2
  name: node-exporter
  namespace: monitoring
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 15s
    port: https
    relabelings:
    # 这就是添加的新的 label k8scluster=cluster-172.30.3.222
    - replacement: cluster-172.30.3.222
      targetLabel: k8scluster
    - action: replace
      regex: (.*)
      replacement: $1
      sourceLabels:
      - __meta_kubernetes_pod_node_name
      targetLabel: instance
    scheme: https
    tlsConfig:
      insecureSkipVerify: true
  jobLabel: app.kubernetes.io/name
  selector:
    matchLabels:
      app.kubernetes.io/component: exporter
      app.kubernetes.io/name: node-exporter
      app.kubernetes.io/part-of: kube-prometheus

因对 prometheus 不熟悉,才这般记录。。。。哎。。。羞羞。。。

你可能感兴趣的:(Prometheus,docker,容器,运维,kubernetes,监控类)