Prometheus 设置 scrape_interval 特定于 http_sd_config 中的目标
Prometheus setting scrape_interval specific to target in http_sd_config
我正在使用 Prometheus http service discovery to add targets dynamically, But it looks like I can only add labels and targets URLs <static_config>。我想知道有没有办法为每个目标指定 scrape_interval?
如果我手动将目标添加到 Prometheus 配置文件中,我可以做到这一点。
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
scrape_configs:
- job_name: 'target-1'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'target-2'
scrape_interval: 5s
static_configs:
- targets: ['localhost:1010']
我从普罗米修斯 GitHub 讨论中得到了答案。
使用 http_sd_config 您可以为每个目标设置抓取间隔:
[
{
"targets": ["10.0.40.3:9100"],
"labels": {
"__meta_datacenter": "london",
"__scrape_interval__": "1m",
"__scrape_timeout__": "5m"
}
},
{
"targets": ["10.0.40.1:9100"],
"labels": {
"__meta_datacenter": "london",
"__scrape_interval__": "1m",
"__scrape_timeout__": "5m"
}
}
]
但也要注意这些标签是实验性的,可能会在未来的版本中发生变化。
来自 Prometheus 文档。
The scrape_interval and scrape_timeout labels are set to the
target's interval and timeout. This is experimental and could change
in the future.
我正在使用 Prometheus http service discovery to add targets dynamically, But it looks like I can only add labels and targets URLs <static_config>。我想知道有没有办法为每个目标指定 scrape_interval?
如果我手动将目标添加到 Prometheus 配置文件中,我可以做到这一点。
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
scrape_configs:
- job_name: 'target-1'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'target-2'
scrape_interval: 5s
static_configs:
- targets: ['localhost:1010']
我从普罗米修斯 GitHub 讨论中得到了答案。
使用 http_sd_config 您可以为每个目标设置抓取间隔:
[
{
"targets": ["10.0.40.3:9100"],
"labels": {
"__meta_datacenter": "london",
"__scrape_interval__": "1m",
"__scrape_timeout__": "5m"
}
},
{
"targets": ["10.0.40.1:9100"],
"labels": {
"__meta_datacenter": "london",
"__scrape_interval__": "1m",
"__scrape_timeout__": "5m"
}
}
]
但也要注意这些标签是实验性的,可能会在未来的版本中发生变化。
来自 Prometheus 文档。
The scrape_interval and scrape_timeout labels are set to the target's interval and timeout. This is experimental and could change in the future.