【发布时间】:2017-09-07 07:27:03
【问题描述】:
我想使用 Prometheus 的 relabeling 添加标签 hostname,这应该是目标提供的 instance 的更简洁版本。这应该允许在 Grafana 仪表板中使用更紧凑的图例。
例如,当__address__ 已设置为myhost.mydomain.com:8080,hostname 应设置为myhost。我使用__address__ 而不是instance 作为source_label,因为第二个是apparently 在重新标记时尚未设置。
我的prometheus.yaml 的相关摘录如下(它打算使用lazy 正则表达式):
- job_name: 'node_exporter'
static_configs:
- targets: ['myhost1.mydomain.com:8080',
'myhost2.mydomain.com:8080']
relabel_configs:
- source_labels: ['__address__']
regex: '^([^\.:]+?)'
replacement: ${1}
target_label: 'hostname'
尚未添加预期的新标签hostname。我的设置可能有什么问题?
【问题讨论】:
标签: monitoring prometheus