Prometheus 查询指标集
编辑Prometheus 查询指标集
编辑这是 query
指标集,用于从 Prometheus 的查询 API 中进行查询。
配置
编辑即时查询
编辑以下配置对 up
指标在单个时间点执行即时查询
- module: prometheus period: 10s hosts: ["localhost:9090"] metricsets: ["query"] queries: - name: 'up' path: '/api/v1/query' params: query: "up"
也可以使用更复杂的 PromQL 表达式,例如以下表达式,该表达式计算过去 5 分钟内测量的每秒 HTTP 请求速率。
- module: prometheus period: 10s hosts: ["localhost:9090"] metricsets: ["query"] queries: - name: "rate_http_requests_total" path: "/api/v1/query" params: query: "rate(prometheus_http_requests_total[5m])"
范围查询
编辑以下示例在 30 秒范围内评估表达式 up
,查询分辨率为 15 秒
- module: prometheus period: 10s metricsets: ["query"] hosts: ["node:9100"] queries: - name: "up_master" path: "/api/v1/query_range" params: query: "up{node='master01'}" start: "2019-12-20T23:30:30.000Z" end: "2019-12-21T23:31:00.000Z" step: 15s
有关指标集中每个字段的描述,请参阅导出的字段部分。
这是此指标集生成的示例文档
{ "@timestamp": "2017-10-12T08:05:34.853Z", "event": { "dataset": "prometheus.query", "duration": 115000, "module": "prometheus" }, "metricset": { "name": "query", "period": 10000 }, "prometheus": { "labels": { "__name__": "go_threads", "instance": "localhost:9090", "job": "prometheus" }, "query": { "go_threads": 18 } }, "service": { "address": "localhost:32769", "type": "prometheus" } }