[英]Unable to push metrics in prometheus
我正在嘗試使用Pushgateway
在Prometheus
推送指標,但無法完成任務。 這是代碼:
var client = require('prom-client');
var gateway = new client.Pushgateway('http://localhost:9091');
gateway.pushAdd({ jobName: 'test', group : "production" }, function(err, resp, body){
});
Prometheus配置:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
scrape_configs:
- job_name: 'example-random'
scrape_interval: 5s
static_configs:
- targets: ['localhost:8080', 'localhost:8081']
labels:
group: 'production'
- targets: ['localhost:8082']
labels:
group: 'canary'
scrape_configs:
- job_name: 'test '
static_configs:
- targets: ['localhost:9091']
您的prometheus配置有一些問題-請查看Prometheus github存儲庫示例和文檔以供將來參考。
一個問題是您有多個scrape_configs
。 您在Prometheus的配置中只能有一個scrape_configs
。
另一個問題是,每個作業只能有一個static_configs
。
其余的主要是由於格式錯誤。
下面編輯的配置現在應該可以為您工作:
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'production'
static_configs:
- targets: ['localhost:8080', 'localhost:8081']
labels:
group: 'production'
- job_name: 'canary'
static_configs:
- targets: ['localhost:8082']
labels:
group: 'canary'
- job_name: 'test'
static_configs:
- targets: ['localhost:9091']
同樣重要的是要注意,來自Pushgateway的指標未推送到Prometheus。 Prometheus基於拉動,並將從Pushgateway本身拉動度量。 Pushgateway收集的度量標准通過臨時作業和批處理作業推送到了它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.