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 秒范围内以 15 秒的查询分辨率评估表达式 up
- 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" } }