7 实时导出协议
本节以 JSON 格式提供real-time export协议的详细信息:
所有文件的扩展名都为 .ndjson 。导出文件的每一行都是一个 JSON 对象。
触发器事件
为问题事件导出以下信息:
字段 | 类型 | 描述 | ||
---|---|---|---|---|
clock | number | 检测到问题的那一刻的时间秒数(整数部分) | ||
ns | number | 要添加到clock 以获得精确问题检测时间的纳秒数。 | ||
value | number | 1 (总是). | ||
eventid | number | 问题事件ID. | ||
name | string | 问题事件名称. | ||
severity | number | 问题事件严重性 (0 - 未分类, 1 - 信息, 2 - 警告, 3 - 一般严重, 4 - 严重, 5 - 灾难). | ||
hosts | array | 触发器表达式中涉及的主机列表;数组中应至少有一个元素。 | ||
- | object | |||
host | string | 主机名. | ||
name | string | 可见主机名 | ||
groups | array | 触发器表达式中涉及的所有主机的主机组列表;数组中应至少有一个元素. | ||
- | string | 主机组名称. | ||
tags | array | 问题标签列表(可以为空). | ||
- | object | |||
tag | string | 标签名称. | ||
value | string | 标签值(可以为空). |
为恢复事件导出以下信息:
字段 | 类型 | 描述 |
---|---|---|
clock | number | 问题恢复那一刻的时间秒数(整数部分). |
ns | number | 要添加到clock 以获得精确问题恢复时间的纳秒数。 |
value | number | 0 (总是). |
eventid | number | 恢复事件ID. |
p_eventid | number | 问题事件ID. |
例
问题:
{"clock":1519304285,"ns":123456789,"value":1,"name":"Either Zabbix agent is unreachable on Host B or pollers are too busy on Zabbix Server","severity":3,"eventid":42, "hosts":[{"host":"Host B", "name":"Host B visible"},{"host":"Zabbix Server","name":"Zabbix Server visible"}],"groups":["Group X","Group Y","Group Z","Zabbix servers"],"tags":[{"tag":"availability","value":""},{"tag":"data center","value":"Riga"}]}
恢复:
{"clock":1519304345,"ns":987654321,"value":0,"eventid":43,"p_eventid":42}
问题(多个问题事件生成):
{"clock":1519304286,"ns":123456789,"value":1,"eventid":43,"name":"Either Zabbix agent is unreachable on Host B or pollers are too busy on Zabbix Server","severity":3,"hosts":[{"host":"Host B", "name":"Host B visible"},{"host":"Zabbix Server","name":"Zabbix Server visible"}],"groups":["Group X","Group Y","Group Z","Zabbix servers"],"tags":[{"tag":"availability","value":""},{"tag":"data center","value":"Riga"}]}
{"clock":1519304286,"ns":123456789,"value":1,"eventid":43,"name":"Either Zabbix agent is unreachable on Host B or pollers are too busy on Zabbix Server","severity":3,"hosts":[{"host":"Host B", "name":"Host B visible"},{"host":"Zabbix Server","name":"Zabbix Server visible"}],"groups":["Group X","Group Y","Group Z","Zabbix servers"],"tags":[{"tag":"availability","value":""},{"tag":"data center","value":"Riga"}]}
恢复:
{"clock":1519304346,"ns":987654321,"value":0,"eventid":44,"p_eventid":43}
{"clock":1519304346,"ns":987654321,"value":0,"eventid":44,"p_eventid":42}
监控项值
为收集的监控项值导出以下信息:
字段 | 类型 | 描述 | |
---|---|---|---|
host | object | 监控项主机的主机名. | |
host | string | 主机名. | |
name | string | 可见的主机名. | |
groups | array | 监控项主机的主机组列表;数组中应至少有一个元素 | |
- | string | 主机组名. | |
itemid | number | 监控项 ID. | |
name | string | 可见监控项名称. | |
clock | number | 收集值那一刻的时间秒数(整数部分). | |
ns | number | 要添加到clock 以获得精确收集值时间的纳秒数。 | |
timestamp (Log only) | number | 如果不可用,则为 0 | |
source (Log only) | string | 如果不可用,则为空字符串 | |
severity (Log only) | number | 如果不可用,则为 0 | |
eventid (Log only) | number | 如果不可用,则为 0 | |
value | number (用于数字型监控项) or string (用于文本型监控项) | 收集的监控项值。 | |
type | number | 收集的值类型: 0 - 浮点数, 1 - 字符, 2 - 日志, 3 - 无符号数字, 4 -文本 |
例
数值(无符号):
{"host":{"host":"Host B","name":"Host B visible"},"groups":["Group X","Group Y","Group Z"],"itemid":3,"name":"Agent availability","clock":1519304285,"ns":123456789,"value":1,"type":3}
数值(浮点数):
{"host":{"host":"Host B","name":"Host B visible"},"groups":["Group X","Group Y","Group Z"],"itemid":4,"name":"CPU Load","clock":1519304285,"ns":123456789,"value":0.1,"type":0}
字符, 文本:
{"host":{"host":"Host B","name":"Host B visible"},"groups":["Group X","Group Y","Group Z"],"itemid":2,"name":"Agent version","clock":1519304285,"ns":123456789,"value":"3.4.4","type":4}
日志:
{"host":{"host":"Host A","name":"Host A visible"},"groups":["Group X","Group Y","Group Z"],"itemid":1,"name":"Messages in log file","clock":1519304285,"ns":123456789,"timestamp":1519304285,"source":"","severity":0,"eventid":0,"value":"log file message","type":2}
趋势
导出以下信息以获取计算的趋势值:
Field | Type | Description | |
---|---|---|---|
host | object | 监控项主机的主机名 | |
host | string | 主机名 | |
name | string | 可见的主机名. | |
groups | array | 监控项主机的主机组列表;数组中应至少有一个元素 | |
- | string | 主机组名. | |
itemid | number | 监控项ID. | |
name | string | 可见监控项名称. | |
clock | number | 收集值那一刻的时间秒数(整数部分). | |
count | number | 一小时内收集的值的数量。 | |
min | number | 一小时内最小监控项值 | |
avg | number | 一小时内平均监控项值 | |
max | number | 一小时内最大监控项值 | |
type | number | 值类型: 0 - 浮点数, 3 - 无符号数字 |
例
数值(无符号):
{"host":{"host":"Host B","name":"Host B visible"},"groups":["Group X","Group Y","Group Z"],"itemid":3,"name":"Agent availability","clock":1519311600,"count":60,"min":1,"avg":1,"max":1,"type":3}
数值(浮点数):
{"host":{"host":"Host B","name":"Host B visible"},"groups":["Group X","Group Y","Group Z"],"itemid":4,"name":"CPU Load","clock":1519311600,"count":60,"min":0.01,"avg":0.15,"max":1.5,"type":0}