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 不熟悉,才这般记录。。。。哎。。。羞羞。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值