Skip to content

Instantly share code, notes, and snippets.

@leapar
Created August 24, 2017 09:52
Show Gist options
  • Save leapar/ec62d8aef6fcbdde927f5e19bcfcfb02 to your computer and use it in GitHub Desktop.
Save leapar/ec62d8aef6fcbdde927f5e19bcfcfb02 to your computer and use it in GitHub Desktop.
alerta,预警,通知

alerta

预警,通知是任何监控以及运维的核心模块。所有报警信息肯定需要一个独立的系统进行存储整理,方便管理以及展示。 而alerta刚好就是负责这个。 alerta包含三大块内容:

  1. Heartbeat心跳包,不停采集心跳信息,如果没有发送,那么就产生超时,表示系统不可用。
  2. Housekeeping这是一个独立程序,定时检查更新告警信息状态,例如删除过期的消息。可以设置多久清除过期的告警信息。
  3. Alert告警信息,每个告警信息默认一天超时
@leapar
Copy link
Author

leapar commented Aug 24, 2017

Heartbeat

http://alerta.readthedocs.io/en/latest/api/heartbeat.html

Attribute Description
id globally unique random UUID
origin name of monitoring component that generated the heartbeat
tags set of tags in any format eg. aTag, aDouble:Tag, a:Triple=Tag
type heartbeat type. only Heartbeat is currently supported
createTime UTC date and time the heartbeat was generated in ISO 8601 format
timeout number of seconds before heartbeat is considered stale

以下两个属性会自动追加进去:

Attribute Description
receiveTime UTC date and time the heartbeat was received by the Alerta server daemon
customer assigned based on the owner of the API key used when submitting the heartbeat, if “Customer Views” are enabled
{
  "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"
}

@leapar
Copy link
Author

leapar commented Aug 25, 2017

Alert Format

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错误信息等等

@leapar
Copy link
Author

leapar commented Aug 25, 2017

tmp1
tmp2
tmp3

@leapar
Copy link
Author

leapar commented Aug 25, 2017

alerta cli

 pip install alerta
vi ~/.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

@leapar
Copy link
Author

leapar commented Aug 25, 2017

tmp1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment