我想构建水平扩展,实现一个完整的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
子节点配置如下:
slaves1.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: keep
slaves2.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: keep
mytest.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
答案 0 :(得分:0)
出现此问题的原因是因为通配符不匹配。该 官方网站提供___job____,但实际使用是工作。
具体还将查看目标的状态下的9090 具体配置页面,并非全部按照官方要求 提供配置