我使用有关CPU,RAM,磁盘使用情况等的数据创建了mysql数据库...我创建了图形但是我注意到当没有新数据时,显示最后一个值。这意味着如果我使用50%的CPU而不是关闭服务器,grafana仍将显示50%的使用率。
这是我在grafana的查询:
SELECT
UNIX_TIMESTAMP(date) as time_sec,
cpu as value,
'server' as metric
FROM server
这是我在monitoring.sh中查询的方式:
INSERT INTO database
VALUES ('$datetime', $cpu_percentage, $mem, $swap, $load1, $load5, $load15, $disk)
使用值示例:
INSERT INTO database
VALUES ('2018-03-25 14:05:41', 9.69, 56.65, 0.00, 1.52, 1.72, 1.82, 20)
我希望在没有出现新值时有间隙,例如服务器已关闭。
有没有办法如何配置grafana来达到这种状态?这甚至可能吗?
我正在使用Grafana v5.0.3。
编辑:
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 0.5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "",
"format": "time_series",
"rawSql": "SELECT\n UNIX_TIMESTAMP(date) as time_sec,\n cpu as value,\n 'server' as metric\nFROM server\n\n",
"refId": "A"
},
{
"alias": "",
"format": "time_series",
"rawSql": "SELECT\n UNIX_TIMESTAMP(date) as time_sec,\n cpu as value,\n 'raspberrypi' as metric\nFROM raspberrypi\n\n",
"refId": "B"
},
{
"alias": "",
"format": "time_series",
"rawSql": "SELECT\n UNIX_TIMESTAMP(date) as time_sec,\n cpu as value,\n 'dellpc' as metric\nFROM dellpc\n\n",
"refId": "C"
}
],
"thresholds": [
{
"colorMode": "critical",
"fill": true,
"line": true,
"op": "gt",
"value": 70
}
],
"timeFrom": null,
"timeShift": null,
"title": "CPU usage",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "percent",
"label": "Usage",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": false
}
]
},
{
"aliasColors": {
"dellpc": "#0a50a1",
"raspberrypi": "#962d82",
"test": "#fce2de"
},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"decimals": 2,
"fill": 1,
"gridPos": {
"h": 11,
"w": 12,
"x": 12,
"y": 0
},
"id": 6,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"hideEmpty": false,
"hideZero": false,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},