【发布时间】:2020-01-17 08:03:59
【问题描述】:
我正在使用 Prometheus 从我的 pod 中抓取指标。我感兴趣的应用程序通过一项提供访问的服务被复制了几次。 Prometheus 使用此服务来抓取指标。在我的应用中,指标设置如下:
import * as Prometheus from 'prom-client';
const httpRequestDurationMicroseconds = new Prometheus.Histogram({
name: 'transaction_amounts',
help: 'Amount',
labelNames: ['amount'],
buckets: [0, 5, 15, 50, 100, 200, 300, 400, 500, 10000],
});
const totalPayments = new Prometheus.Counter('transaction_totals', 'Total payments');
我正在使用 helm 安装 Prometheus,scrape 配置如下所示:
prometheus.yml:
rule_files:
- /etc/config/rules
- /etc/config/alerts
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- localhost:9090
- job_name: transactions
scrape_interval: 1s
static_configs:
- targets:
- transaction-metrics-service:3001
我可以看到 prometheus 内部的指标,但它似乎只来自一个 pod。例如,在 Prometheus 中,当我查询 transaction_totals 时,它给出:
我认为instance 标签不能唯一标识我的 pod。我应该怎么做才能查询所有 pod?
【问题讨论】:
标签: kubernetes prometheus metrics