这些参数及对应仪表板小组件字段objects的可选属性值允许通过dashboard.create
和dashboard.update
方法配置Graph (classic)小组件。
小组件fields
的属性在仪表板创建或update过程中不会进行验证。 这使得用户可以修改built-in widgets和createcustom widgets,但也存在错误创建或更新小组件的风险。 为确保成功创建或update图表(经典)小组件,请参考下文表格中列出的参数行为规范。
Graph (classic) 小部件支持以下参数。
参数 | 仪表板小部件字段 | 名称 | 值 | |
---|---|---|---|---|
Refresh interval | 0 | rf_rate | 0 - 无刷新; 10 - 10 秒; 30 - 30 秒; 60 - (默认) 1 分钟; 120 - 2 分钟; 600 - 10 分钟; 900 - 15 分钟。 |
|
Source | 0 | source_type | 0 - (默认) 图表; 1 - 简单图表。 |
|
Graph | 6 | graphid.0 | Graph ID。 参数行为: - 必填 若 源 设置为 "Graph" |
|
图形 (小部件) | 1 | graphid._reference | 不使用 Graph ID:ABCDE._graphid - 设置一个 部件兼容性(将其Reference参数设置为"ABCDE ")作为图形的数据源。参数行为: - 如果Source设置为"Simple graph"且Graph未设置,则为必填 |
|
Item | 4 | itemid.0 | Item ID。 参数行为: - 必填,如果 源(Source) 设置为 "简单图表(Simple graph)" 且 监控项(小部件 Widget) 未设置 |
|
监控项(小部件) | 1 | itemid._reference | 不使用 Item ID:ABCDE._itemid — 而是设置一个 部件兼容性(将其参考(Reference)参数设为 "ABCDE ") 作为 监控项 的数据源。参数行为: - 如果 源(Source) 设置为 "简单图(Simple graph)" 且未设置 监控项,则为必填项。 |
|
Time period | 1 | time_period._reference | DASHBOARD._timeperiod - 将Time period selector设置为数据源;ABCDE._timeperiod - 将部件兼容性(将其Reference参数设置为"ABCDE ")设置为数据源。默认值: DASHBOARD._timeperiod 或者,您也可以仅在From和To参数中设置时间段。 |
|
从 | 1 | time_period.from | 绝对时间(YYYY-MM-DD hh:mm:ss )或relative时间格式(now 、now/d 、now/w-1w 等)内的有效时间 string。参数行为: - 时间周期 未设置时为 支持 |
|
至 | 1 | time_period.to | 绝对时间(YYYY-MM-DD hh:mm:ss )或relative相对时间(now 、now/d 、now/w-1w 等)格式的string有效时间段。参数行为: - 如果未设置时间段,则为支持 |
|
Show legend | 0 | show_legend | 0 - 已禁用; 1 - (默认) 已启用。 |
|
Override host | 1 | override_hostid._reference | ABCDE._hostid - 为 主机 设置一个 部件兼容性(将其 Reference 参数设置为 "ABCDE ")作为数据源;DASHBOARD._hostid - 将仪表板 覆盖主机 设置为 主机 的数据源。如果在 template dashboard 上配置 widget,则不支持此参数。 |
|
Reference | 1 | reference | 任何由 5 个字符组成的 string 值(例如 ABCDE 或 JBPNL )。此值在该 widget 所属的仪表板内必须唯一。参数行为: - 必填 |
以下示例仅用于描述仪表板中图形(经典)小部件的widget字段objects的配置。 有关配置仪表板的更多信息,请参见dashboard.create
。
配置一个图形(经典) widget,用于显示监控项 监控项 "42269" 的简单图形。
执行请求:
{
"jsonrpc": "2.0",
"method": "dashboard.create",
"params": {
"name": "My dashboard",
"display_period": 30,
"auto_start": 1,
"pages": [
{
"widgets": [
{
"type": "graph",
"name": "Graph (classic)",
"x": 0,
"y": 0,
"width": 36,
"height": 5,
"view_mode": 0,
"fields": [
{
"type": 0,
"name": "source_type",
"value": 1
},
{
"type": 4,
"name": "itemid.0",
"value": 42269
},
{
"type": 1,
"name": "reference",
"value": "RSTUV"
}
]
}
]
}
],
"userGroups": [
{
"usrgrpid": 7,
"permission": 2
}
],
"users": [
{
"userid": 1,
"permission": 3
}
]
},
"id": 1
}
响应: