Prometheus是一个独立的开源监控系统。其组成主要有时序数据库、数据采集、数据查询(PromQL查询语言)和报警。
先看一下Prometheus结构图前端
数据采集两种方式:node
告警规则须要在Prometheus配置文件中配置mysql
原文档linux
配置文件定义了抑制规则,通知路由和通知接收者。
用以下命令查看全部可配置标签:web
alertmanager -h
使用目标配置文件启动Alertmanagersql
./alertmanager --config.file=simple.yml
route匹配数据库
# The root route with all parameters, which are inherited by the child # routes if they are not overwritten. route: receiver: 'default-receiver' group_wait: 30s group_interval: 5m repeat_interval: 4h group_by: [cluster, alertname] # All alerts that do not match the following child routes # will remain at the root node and be dispatched to 'default-receiver'. routes: # All alerts with service=mysql or service=cassandra # are dispatched to the database pager. - receiver: 'database-pager' group_wait: 10s match_re: service: mysql|cassandra # All alerts with the team=frontend label match this sub-route. # They are grouped by product and environment rather than cluster # and alertname. - receiver: 'frontend-pager' group_by: [product, environment] match: team: frontend
webhooks是一个api概念,是微服务api的使用范式之一,也被成为反向api,即:前端不主动发送请求,彻底由后端推送。 举个经常使用例子,好比你的好友发了一条朋友圈,后端将这条消息推送给全部其余好友的客户端,就是 Webhooks 的典型场景。
Prometheus经过webhook向Alertmanager推送警报,数据结构以下:
Alers结构以下:
每一个警报的标签用于标识警报的相同实例并执行重复数据删除。注释老是设置为最近收到的,而且没有标识警报。
KV是一组用于表示标签和注释的键/值字符串对。后端
type KV map[string]string
例如:api
{ summary: "alert summary", description: "alert description", }
关于对KV的操做:数据结构
GET /-/healthy
GET /-/ready
POST /-/reload