Fork me on GitHub

Prometheus监控之API接口实践

Prometheus提供了一组API促进自动化和其他系统集成。

概述

Prometheus提供了两类接口,一类是管理Prometheus实例的操作,例如健康检查、就绪检查、加载配置及退出。第二类则是对Prometheus数据的操作,包括增删改查4大大类。

接口能做什么?例如: 监控数据自动备份、统计Prometheus实例信息、监控完整性检查、资源利用率系统数据来源等等

API接口

查询接口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Instant queries
GET /api/v1/query
POST /api/v1/query

# Range queries
GET /api/v1/query_range
POST /api/v1/query_range

# Formatting query expressions
GET /api/v1/format_query
POST /api/v1/format_query

# Querying metadata
GET /api/v1/series
POST /api/v1/series

GET /api/v1/labels
POST /api/v1/labels

GET /api/v1/label/<label_name>/values

GET /api/v1/query_exemplars
POST /api/v1/query_exemplars

# Targets
GET /api/v1/targets

# Rules
GET /api/v1/rules

# Alerts
GET /api/v1/alerts

# Querying target metadata
GET /api/v1/targets/metadata

# Querying metric metadata
GET /api/v1/metadata

# Alertmanagers
GET /api/v1/alertmanagers

# Status
# Config
GET /api/v1/status/config

# Flags
GET /api/v1/status/flags

# Runtime Information
GET /api/v1/status/runtimeinfo

# Build Information
GET /api/v1/status/buildinfo

# TSDB Stats
GET /api/v1/status/tsdb

# WAL Replay Stats
GET /api/v1/status/walreplay

# Snapshot
POST /api/v1/admin/tsdb/snapshot
PUT /api/v1/admin/tsdb/snapshot

# Delete Series
POST /api/v1/admin/tsdb/delete_series
PUT /api/v1/admin/tsdb/delete_series

# Clean Tombstones
POST /api/v1/admin/tsdb/clean_tombstones
PUT /api/v1/admin/tsdb/clean_tombstones

# Remote Write Receiver(依赖配置--web.enable-remote-write-receiver)
/api/v1/write

管理接口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 健康检查Health check
GET /-/healthy
HEAD /-/healthy

# 就绪检查Readiness check
GET /-/ready
HEAD /-/ready

# 重新加载配置Reload(依赖配置--web.enable-lifecycle)
PUT /-/reload
POST /-/reload

# 退出Quit(依赖配置--web.enable-lifecycle)
PUT /-/quit
POST /-/quit

接口实践

利用监控接口实现Prometheus实例信息监控

参照资料

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/94ebcc6.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!