7 实时导出协议

本节以换行符分隔的JSON格式详细说明real-time export协议,适用于:

所有文件均采用.ndjson扩展名。exportfile的每一行均为一个JSONobject。

触发器事件

以下信息针对问题事件导出:

字段 类型 描述
clock number 从Epoch到问题被检测时刻的秒数(integer部分).
ns number 需要加到clock上的纳秒数,用于get精确的问题检测时间.
value number 1 (固定值).
eventid number 问题事件ID.
name string 问题事件名称.
severity number 问题事件严重性(0 - 未分类, 1 - 信息, 2 - 警告, 3 - 一般, 4 - 严重, 5 - 灾难).
hosts array 触发器表达式中涉及的主机列表; array中应至少有一个元素.
- object
主机 string 主机名.
name string 可见主机名.
groups array 触发器表达式中所有主机的主机组列表; array中应至少有一个元素.
- string 主机组名称.
tags array 问题标签列表(可为空).
- object
tag string 标签名称.
value string 标签值(可为空).

以下信息针对恢复事件导出:

字段 类型 描述
clock number 从Epoch到问题被解决时刻的秒数(integer部分).
ns number 需要加到clock上的纳秒数,用于get精确的问题解决时间.
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":"Zabbix agent在主机 B上不可达或Zabbix server上的轮询程序过于繁忙","severity":3,"主机":[{"主机":"主机 B", "name":"主机 B可见"},{"主机":"Zabbix server","name":"Zabbix server可见"}],"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 监控项主机的主机名。
主机 string 主机名。
name string 可见主机名。
groups array 监控项主机的主机组列表;array中应至少有一个元素。
- string 主机组名称。
itemid number 监控项ID。
name string 可见监控项名称。
clock number 从Epoch到值收集时刻的秒数(integer部分)。
ns number 要添加到clock以get精确值收集时间的纳秒数。
timestamp
(Log only)
number 不可用时为0。
source
(Log only)
string 不可用时为空string。
severity
(Log only)
number 不可用时为0。
eventid
(Log only)
number 不可用时为0。
value number (for numeric items) or
string (for text items)
收集的监控项值。
type number 收集值类型:
0 - 数值型float, 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}

数值 (float) 值:

{"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}

日志值:

{"主机":{"主机":"主机 A","name":"主机 A 可见"},"groups":["组X","组Y","组Z"],"itemid":1,"name":"日志中的消息 file","clock":1519304285,"ns":123456789,"timestamp":1519304285,"source":"","severity":0,"eventid":0,"value":"日志 file 消息","type":2}

趋势数据

以下信息是为计算出的趋势值导出的:

字段 类型 描述
host object 主机名 的 监控项 主机.
主机 string 主机名.
name string 可见 主机名.
groups array 监控项 主机 的 主机 组列表; array 中应至少有一个元素.
- string 主机组 名称.
itemid number 监控项 ID.
name string 可见 监控项 名称.
clock number 自Epoch到值收集时刻的秒数 (integer 部分).
count number 给定小时收集的值的数量.
min number 给定小时的 监控项 最小值.
avg number 给定小时的 监控项 平均值.
max number 给定小时的 监控项 最大值.
type number 值类型:
0 - 数字 float, 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}

数值(float)值:

{"主机":{"主机":"主机 B","name":"主机 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}