预警,通知是任何监控以及运维的核心模块。所有报警信息肯定需要一个独立的系统进行存储整理,方便管理以及展示。 而alerta刚好就是负责这个。 alerta包含三大块内容:
- Heartbeat心跳包,不停采集心跳信息,如果没有发送,那么就产生超时,表示系统不可用。
- Housekeeping这是一个独立程序,定时检查更新告警信息状态,例如删除过期的消息。可以设置多久清除过期的告警信息。
- Alert告警信息,每个告警信息默认一天超时
http://alerta.readthedocs.io/en/latest/api/alert.html#severity-table
| Attribute | Description |
|---|---|
| resource | 报警设备 |
| event | 事件名称 |
| environment | 报警环境 是开发模式还是生产模式 |
| severity | 预警等级 (默认 normal). see Alert Severities table |
| correlate | 相关的预警名称 |
| status | 预警状态 (默认 open). see Alert Status table |
| service | 受影响的服务 |
| group | 预警分类 |
| value | 事件值. 100%, Down, PingFail, 55ms, ORA-1664 |
| text | 文字详细描述 |
| tags | 打tag aTag, aDouble:Tag, a:Triple=Tag |
| attributes | 键值对属性 |
| origin | 预警器例如curl bosun ... |
| type | 预警类型 syslog等等 |
| createTime | UTC date-time the alert was generated in ISO8601 format |
| timeout | 超时单位秒 |
| rawData | 附加参考信息,这个是原始数据,例如snmp陷阱信息,syslog错误信息等等 |
pip install alertavi ~/.alerta.conf[DEFAULT]
timezone = Australia/Sydney
output = json
[profile production]
endpoint = https://api.alerta.io
key = LMvzLsfJyGpSuLmaB9kp-8gCl4I3YZkV4i7IGb6S
[profile Development]
endpoint = http://localhost:8181/api
key = 3T4aJUyOZfAWVzMZ71tKjjcYfGiJB3JyZBQQT5Am
sslverify = off
timeout = 10.0
debug = yes
alerta send --resource web01 --event HttpError --correlate HttpOK --group Web --severity minor --environment Development --service service
Heartbeat
http://alerta.readthedocs.io/en/latest/api/heartbeat.html
以下两个属性会自动追加进去:
{ "origin": "macbook", "tags": [ "foo", "bar", "baz" ], "createTime": "2015-10-03T00:00:59.055Z", "href": "http://api.alerta.io/heartbeat/a8b97056-8415-4b4f-83c8-e84ffcc676a3", "timeout": 300, "receiveTime": "2015-10-03T00:00:59.681Z", "type": "Heartbeat", "id": "a8b97056-8415-4b4f-83c8-e84ffcc676a3" }