我希望构建水平扩展,实现一个完整的prometheus,并监视两个子prometheus节点。例如:节点A,B:监视Node_exporter和mysql_export数据; 总Prometheus位于主机C上,子节点分别位于主机A和B上。 主节点配置如下:
prometheus.yml(host_C):
global:
rule_files:
# - node_rules/zep.test.rules
scrape_configs:
- job_name: slaves
honor_labels: true
scrape_interval: 1s
metrics_path: /federate
params:
match[]:
- '{__name__=~"^job:.*"}'
- '{__job__=~"^job:.*"}'
static_configs:
- targets:
- hostA_ip:9090
- hostB_ip:9090子节点配置如下:
Slves1.yml(Host_A):
global:
external_labels:
slave: 0
rule_files:
scrape_configs:
- job_name: myjob_1
scrape_interval: 1s
file_sd_configs:
- files: ['./mytest.json']
relabel_configs:
- source_labels: [__address__]
modulus: 2
target_label: __tmp_hash
action: hashmod
- source_labels: [__tmp_hash]
regex: ^0$
action: keepSlves2.yml(Host_B):
global:
external_labels:
slave: 1
rule_files:
scrape_configs:
- job_name: myjob_2
scrape_interval: 1s
file_sd_configs:
- files: ['./mytest.json']
relabel_configs:
- source_labels: [__address__]
modulus: 2
target_label: __tmp_hash
action: hashmod
- source_labels: [__tmp_hash]
regex: ^1$
action: keepmytest.json:
[{
"targets": [
"hostA_ip:9100",
"hostA_ip:9104"
],
"labels": {
"services": "dba_test"
}
}]运行它:
./prometheus --web.listen-address="hostA_ip:9090" --storage.tsdb.path="global_data/" --config.file="prometheus.yml" --web.enable-admin-api
./prometheus --web.listen-address="hostB_ip:9090" --storage.tsdb.path="data1/" --config.file="slave1.yml" --web.enable-admin-api
./prometheus --web.listen-address="hostC_ip:9090" --storage.tsdb.path="data2/" --config.file="slave2.yml" --web.enable-admin-api发布于 2018-06-05 08:28:22
造成此问题的原因是通配符不匹配。官方网站提供___job____,但实际使用的是工作。 还将查看9090下的status of 特定配置页面,并不是全部按照官方提供的配置。
https://stackoverflow.com/questions/50001890
复制相似问题