我有库贝-普罗米修斯-堆栈运行在库伯奈特集群和普罗米修斯-黑匣子出口商。我想监视多个http目标。我尝试过用一个服务程序设置它,但是当我添加一个目标时,目标没有得到正确的标签。
服务机构yaml:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations:
meta.helm.sh/release-name: blackbox
meta.helm.sh/release-namespace: default
generation: 1
labels:
app.kubernetes.io/instance: blackbox
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: prometheus-blackbox-exporter
app.kubernetes.io/version: 0.20.0
helm.sh/chart: prometheus-blackbox-exporter-5.7.0
release: kube-prometheus
name: blackbox-prometheus-blackbox-exporter
namespace: default
spec:
endpoints:
- interval: 10s
path: /probe
port: http
scheme: http
params:
module:
- http_2xx
target:
- https://google.com
- https://example.com
metricRelabelings:
- sourceLabels: [__address__]
targetLabel: __param_target
jobLabel: kube-prometheus
selector:
matchLabels:
app.kubernetes.io/instance: blackbox
app.kubernetes.io/name: prometheus-blackbox-exporter 但是在grafana中,我只得到了一个实例标签:grafana实例
发布于 2022-07-19 12:21:32
spec.endpoints是列表。在yaml中,每个lists元素都使用破折号定义。因此,您必须将服务监视器yaml修改为:
spec:
endpoints:
- interval: 10s
path: /probe
port: metrics
params:
module:
- http_2xx
target:
- https://www.google.com
relabelings:
- sourceLabels: [__param_target]
targetLabel: target
- interval: 10s
path: /probe
port: metrics
params:
module:
- http_2xx
target:
- https://www.example.com
relabelings:
- sourceLabels: [__param_target]
targetLabel: target它可以工作就像这里展示的那样
https://stackoverflow.com/questions/72120717
复制相似问题