prometheus配置
1.relabel_configs 和 metric_relabel_configs
relabel_configs:發生在抓取前選擇目標和做label配置
metric_relabel_configs:發生在抓取后落tsdb庫之前,最后修改metrics內容
elabel_config 發生在抓取之前,metric_relabel_configs 發生在抓取之后
2.其他配置
- source_labels: [__meta_kubernetes_service_name] #這個標簽可以在prom中查看詳細的值
separator: ;
regex: (.*) #正則匹配
target_label: k8s_svc
replacement: $1
action: replace
replace: 替換。
keep: 保留。如果只想發現某個與source_labels匹配的target,可以用這個keep
drop: 丟棄。可以根據source_labels丟棄某個匹配的target
labeldrop: 丟棄標簽。可以根據regex丟棄某個匹配的指標,vm-metrics處理的指標標簽有上限,太多會導致一些標簽被丟棄
3.只要某個端口的指標,其他接口的自動丟掉
relabel_configs: - source_labels: [__address__] regex: (.+):9327 action: keep
4.prometheus產生的告警無法發往alertmanager
在prometheus中經歷了完整的pending、firing
因為告警規則配置的指標不是連續的,而是斷點

參考連接:
https://blog.csdn.net/qq_43684922/article/details/131155357
https://prometheus.io/docs/prometheus/latest/configuration/configuration/

浙公網安備 33010602011771號