refactor linux dashboard

This commit is contained in:
Ulric Qin 2022-07-27 19:05:00 +08:00
parent 7c351e09e5
commit 64646d2ace
3 changed files with 1572 additions and 1526 deletions

View File

@ -1,5 +1,5 @@
{ {
"name": "Linux Host", "name": "Linux Host by Categraf",
"tags": "", "tags": "",
"configs": { "configs": {
"var": [ "var": [
@ -31,7 +31,8 @@
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 0, "y": 0,
"i": "e5d14dd7-4417-42bd-b7ba-560f34d299a2" "i": "e5d14dd7-4417-42bd-b7ba-560f34d299a2",
"isResizable": false
}, },
"collapsed": true "collapsed": true
}, },
@ -62,7 +63,8 @@
"w": 3, "w": 3,
"x": 0, "x": 0,
"y": 1, "y": 1,
"i": "41f37540-e695-492a-9d2f-24bfd2d36805" "i": "41f37540-e695-492a-9d2f-24bfd2d36805",
"isResizable": true
}, },
"id": "41f37540-e695-492a-9d2f-24bfd2d36805" "id": "41f37540-e695-492a-9d2f-24bfd2d36805"
}, },
@ -70,35 +72,40 @@
"targets": [ "targets": [
{ {
"refId": "A", "refId": "A",
"expr": "topk(10, (mem_used_percent))" "expr": "topk(10, (mem_used_percent))",
"legend": "{{ident}}"
} }
], ],
"name": "内存率 top10", "name": "内存使用率 top10",
"options": {
"tooltip": {
"mode": "all",
"sort": "none"
},
"legend": {
"displayMode": "hidden"
},
"standardOptions": {},
"thresholds": {}
},
"custom": { "custom": {
"drawStyle": "lines", "calc": "lastNotNull",
"lineInterpolation": "smooth", "baseColor": "#cd75eb",
"fillOpacity": 0.5, "serieWidth": 20,
"stack": "off" "sortOrder": "desc"
},
"options": {
"valueMappings": [
{
"type": "range",
"result": {
"color": "#f8070e"
},
"match": {
"from": 60
}
}
],
"standardOptions": {}
}, },
"version": "2.0.0", "version": "2.0.0",
"type": "timeseries", "type": "barGauge",
"layout": { "layout": {
"h": 3, "h": 3,
"w": 9, "w": 9,
"x": 3, "x": 3,
"y": 1, "y": 1,
"i": "585bfc50-7c92-42b1-88ee-5b725b640418" "i": "585bfc50-7c92-42b1-88ee-5b725b640418",
"isResizable": true
}, },
"id": "585bfc50-7c92-42b1-88ee-5b725b640418" "id": "585bfc50-7c92-42b1-88ee-5b725b640418"
}, },
@ -134,7 +141,8 @@
"w": 12, "w": 12,
"x": 12, "x": 12,
"y": 1, "y": 1,
"i": "60b1e833-3f03-45bb-9385-a3825904a0ac" "i": "60b1e833-3f03-45bb-9385-a3825904a0ac",
"isResizable": true
}, },
"id": "60b1e833-3f03-45bb-9385-a3825904a0ac" "id": "60b1e833-3f03-45bb-9385-a3825904a0ac"
}, },
@ -143,35 +151,39 @@
{ {
"refId": "A", "refId": "A",
"expr": "topk(10, (disk_used_percent{path!~\"/var.*\"}))", "expr": "topk(10, (disk_used_percent{path!~\"/var.*\"}))",
"legend": "{{ident}}-{{path}}" "legend": "{{ident}} {{path}}"
} }
], ],
"name": "磁盘分区使用率 top10", "name": "磁盘分区使用率 top10",
"options": {
"tooltip": {
"mode": "all",
"sort": "none"
},
"legend": {
"displayMode": "hidden"
},
"standardOptions": {},
"thresholds": {}
},
"custom": { "custom": {
"drawStyle": "lines", "calc": "lastNotNull",
"lineInterpolation": "smooth", "baseColor": "#9470ff",
"fillOpacity": 0.5, "serieWidth": 20,
"stack": "off" "sortOrder": "desc"
},
"options": {
"valueMappings": [
{
"type": "range",
"result": {
"color": "#f00404"
},
"match": {
"from": 85
}
}
],
"standardOptions": {}
}, },
"version": "2.0.0", "version": "2.0.0",
"type": "timeseries", "type": "barGauge",
"layout": { "layout": {
"h": 3, "h": 3,
"w": 12, "w": 12,
"x": 0, "x": 0,
"y": 2, "y": 4,
"i": "69351db9-e646-4e5d-925a-cba29823b00d" "i": "69351db9-e646-4e5d-925a-cba29823b00d",
"isResizable": true
}, },
"id": "69351db9-e646-4e5d-925a-cba29823b00d" "id": "69351db9-e646-4e5d-925a-cba29823b00d"
}, },
@ -207,8 +219,9 @@
"h": 3, "h": 3,
"w": 12, "w": 12,
"x": 12, "x": 12,
"y": 2, "y": 4,
"i": "e3675ed9-6d3b-4a41-8d16-d6e82037dce3" "i": "e3675ed9-6d3b-4a41-8d16-d6e82037dce3",
"isResizable": true
}, },
"id": "e3675ed9-6d3b-4a41-8d16-d6e82037dce3" "id": "e3675ed9-6d3b-4a41-8d16-d6e82037dce3"
}, },
@ -220,8 +233,9 @@
"h": 1, "h": 1,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 5, "y": 7,
"i": "2b2de3d1-65c8-4c39-9bea-02b754e0d751" "i": "2b2de3d1-65c8-4c39-9bea-02b754e0d751",
"isResizable": false
}, },
"collapsed": true "collapsed": true
}, },
@ -229,10 +243,10 @@
"targets": [ "targets": [
{ {
"refId": "A", "refId": "A",
"expr": "system_uptime{ident=\"$ident\"}" "expr": "system_uptime{ident=\"$ident\"}/3600/24"
} }
], ],
"name": "启动时长", "name": "启动时长(单位:天)",
"custom": { "custom": {
"textMode": "value", "textMode": "value",
"colorMode": "value", "colorMode": "value",
@ -245,7 +259,7 @@
"options": { "options": {
"valueMappings": [], "valueMappings": [],
"standardOptions": { "standardOptions": {
"util": "humantimeSeconds", "util": "none",
"decimals": 1 "decimals": 1
} }
}, },
@ -255,8 +269,9 @@
"h": 3, "h": 3,
"w": 6, "w": 6,
"x": 0, "x": 0,
"y": 6, "y": 8,
"i": "deec579b-3090-4344-a9a6-c1455c4a8e50" "i": "deec579b-3090-4344-a9a6-c1455c4a8e50",
"isResizable": true
}, },
"id": "deec579b-3090-4344-a9a6-c1455c4a8e50" "id": "deec579b-3090-4344-a9a6-c1455c4a8e50"
}, },
@ -311,8 +326,9 @@
"h": 3, "h": 3,
"w": 6, "w": 6,
"x": 6, "x": 6,
"y": 6, "y": 8,
"i": "7a7bd5db-d12e-49f0-92a8-15958e99ee54" "i": "7a7bd5db-d12e-49f0-92a8-15958e99ee54",
"isResizable": true
}, },
"id": "7a7bd5db-d12e-49f0-92a8-15958e99ee54" "id": "7a7bd5db-d12e-49f0-92a8-15958e99ee54"
}, },
@ -367,8 +383,9 @@
"h": 3, "h": 3,
"w": 6, "w": 6,
"x": 12, "x": 12,
"y": 6, "y": 8,
"i": "8a814265-54ad-419c-8cb7-e1f84a242de0" "i": "8a814265-54ad-419c-8cb7-e1f84a242de0",
"isResizable": true
}, },
"id": "8a814265-54ad-419c-8cb7-e1f84a242de0" "id": "8a814265-54ad-419c-8cb7-e1f84a242de0"
}, },
@ -423,8 +440,9 @@
"h": 3, "h": 3,
"w": 3, "w": 3,
"x": 18, "x": 18,
"y": 6, "y": 8,
"i": "d7d11972-5c5b-4bc6-98f8-bbbe9f018896" "i": "d7d11972-5c5b-4bc6-98f8-bbbe9f018896",
"isResizable": true
}, },
"id": "d7d11972-5c5b-4bc6-98f8-bbbe9f018896" "id": "d7d11972-5c5b-4bc6-98f8-bbbe9f018896"
}, },
@ -458,8 +476,9 @@
"h": 3, "h": 3,
"w": 3, "w": 3,
"x": 21, "x": 21,
"y": 6, "y": 8,
"i": "209d3aba-5e02-4b8f-a364-65f20ba92a2c" "i": "209d3aba-5e02-4b8f-a364-65f20ba92a2c",
"isResizable": true
}, },
"id": "209d3aba-5e02-4b8f-a364-65f20ba92a2c" "id": "209d3aba-5e02-4b8f-a364-65f20ba92a2c"
}, },
@ -498,8 +517,9 @@
"h": 3, "h": 3,
"w": 8, "w": 8,
"x": 0, "x": 0,
"y": 7, "y": 11,
"i": "b3c5dd9d-e82a-4b15-8b23-c510e2bee152" "i": "b3c5dd9d-e82a-4b15-8b23-c510e2bee152",
"isResizable": true
}, },
"id": "b3c5dd9d-e82a-4b15-8b23-c510e2bee152" "id": "b3c5dd9d-e82a-4b15-8b23-c510e2bee152"
}, },
@ -538,8 +558,9 @@
"h": 3, "h": 3,
"w": 8, "w": 8,
"x": 8, "x": 8,
"y": 7, "y": 11,
"i": "0de74cd9-cc74-4a96-bcb2-05d3a8bde2ea" "i": "0de74cd9-cc74-4a96-bcb2-05d3a8bde2ea",
"isResizable": true
}, },
"id": "0de74cd9-cc74-4a96-bcb2-05d3a8bde2ea" "id": "0de74cd9-cc74-4a96-bcb2-05d3a8bde2ea"
}, },
@ -578,8 +599,9 @@
"h": 3, "h": 3,
"w": 8, "w": 8,
"x": 16, "x": 16,
"y": 7, "y": 11,
"i": "59afa167-434d-496c-a3ef-ceff6db7c1f6" "i": "59afa167-434d-496c-a3ef-ceff6db7c1f6",
"isResizable": true
}, },
"id": "59afa167-434d-496c-a3ef-ceff6db7c1f6" "id": "59afa167-434d-496c-a3ef-ceff6db7c1f6"
}, },
@ -591,8 +613,9 @@
"h": 1, "h": 1,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 10, "y": 14,
"i": "aabb8263-1a9b-43fb-bee1-6c532f5012a3" "i": "aabb8263-1a9b-43fb-bee1-6c532f5012a3",
"isResizable": false
}, },
"collapsed": true "collapsed": true
}, },
@ -634,8 +657,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 0, "x": 0,
"y": 11, "y": 15,
"i": "1b4da538-29d4-4c58-b3f4-773fabb8616c" "i": "1b4da538-29d4-4c58-b3f4-773fabb8616c",
"isResizable": true
}, },
"id": "1b4da538-29d4-4c58-b3f4-773fabb8616c" "id": "1b4da538-29d4-4c58-b3f4-773fabb8616c"
}, },
@ -676,8 +700,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 8, "x": 8,
"y": 11, "y": 15,
"i": "aa7adae0-ae3b-4e28-a8ce-801c65961552" "i": "aa7adae0-ae3b-4e28-a8ce-801c65961552",
"isResizable": true
}, },
"id": "aa7adae0-ae3b-4e28-a8ce-801c65961552" "id": "aa7adae0-ae3b-4e28-a8ce-801c65961552"
}, },
@ -720,8 +745,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 16, "x": 16,
"y": 11, "y": 15,
"i": "71e22f58-5b9a-4604-bca8-55bcef59b5fe" "i": "71e22f58-5b9a-4604-bca8-55bcef59b5fe",
"isResizable": true
}, },
"id": "71e22f58-5b9a-4604-bca8-55bcef59b5fe" "id": "71e22f58-5b9a-4604-bca8-55bcef59b5fe"
}, },
@ -733,8 +759,9 @@
"h": 1, "h": 1,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 18, "y": 22,
"i": "10f34f8f-f94d-4a28-9551-16e6667e3833" "i": "10f34f8f-f94d-4a28-9551-16e6667e3833",
"isResizable": false
}, },
"collapsed": true "collapsed": true
}, },
@ -777,8 +804,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 0, "x": 0,
"y": 19, "y": 23,
"i": "1559d880-7e26-4e42-9427-4e55fb6f67be" "i": "1559d880-7e26-4e42-9427-4e55fb6f67be",
"isResizable": true
}, },
"id": "1559d880-7e26-4e42-9427-4e55fb6f67be" "id": "1559d880-7e26-4e42-9427-4e55fb6f67be"
}, },
@ -843,8 +871,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 8, "x": 8,
"y": 19, "y": 23,
"i": "043c26de-d19f-4fe8-a615-2b7c10ceb828" "i": "043c26de-d19f-4fe8-a615-2b7c10ceb828",
"isResizable": true
}, },
"id": "043c26de-d19f-4fe8-a615-2b7c10ceb828" "id": "043c26de-d19f-4fe8-a615-2b7c10ceb828"
}, },
@ -887,8 +916,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 16, "x": 16,
"y": 19, "y": 23,
"i": "a420ce25-6968-47f8-8335-60cde70fd062" "i": "a420ce25-6968-47f8-8335-60cde70fd062",
"isResizable": true
}, },
"id": "a420ce25-6968-47f8-8335-60cde70fd062" "id": "a420ce25-6968-47f8-8335-60cde70fd062"
}, },
@ -900,8 +930,9 @@
"h": 1, "h": 1,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 26, "y": 30,
"i": "b7a3c99f-a796-4b76-89b5-cbddd566f91c" "i": "b7a3c99f-a796-4b76-89b5-cbddd566f91c",
"isResizable": false
}, },
"collapsed": true "collapsed": true
}, },
@ -961,8 +992,9 @@
"h": 7, "h": 7,
"w": 12, "w": 12,
"x": 0, "x": 0,
"y": 27, "y": 31,
"i": "239aacdf-1982-428b-b240-57f4ce7f946d" "i": "239aacdf-1982-428b-b240-57f4ce7f946d",
"isResizable": true
}, },
"id": "239aacdf-1982-428b-b240-57f4ce7f946d" "id": "239aacdf-1982-428b-b240-57f4ce7f946d"
}, },
@ -1013,8 +1045,9 @@
"h": 7, "h": 7,
"w": 12, "w": 12,
"x": 12, "x": 12,
"y": 27, "y": 31,
"i": "00ed6e4d-c979-4938-a20e-56d42ca452cf" "i": "00ed6e4d-c979-4938-a20e-56d42ca452cf",
"isResizable": true
}, },
"id": "00ed6e4d-c979-4938-a20e-56d42ca452cf" "id": "00ed6e4d-c979-4938-a20e-56d42ca452cf"
}, },
@ -1026,8 +1059,9 @@
"h": 1, "h": 1,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 34, "y": 38,
"i": "842a8c48-0e93-40bf-8f28-1b2f837e5c19" "i": "842a8c48-0e93-40bf-8f28-1b2f837e5c19",
"isResizable": false
}, },
"collapsed": true "collapsed": true
}, },
@ -1073,8 +1107,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 0, "x": 0,
"y": 35, "y": 39,
"i": "bc894871-1c03-4d12-91be-6867f394a8a6" "i": "bc894871-1c03-4d12-91be-6867f394a8a6",
"isResizable": true
}, },
"id": "bc894871-1c03-4d12-91be-6867f394a8a6" "id": "bc894871-1c03-4d12-91be-6867f394a8a6"
}, },
@ -1113,8 +1148,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 8, "x": 8,
"y": 35, "y": 39,
"i": "d825671f-7dc5-46a2-89dc-4fff084a3ae0" "i": "d825671f-7dc5-46a2-89dc-4fff084a3ae0",
"isResizable": true
}, },
"id": "d825671f-7dc5-46a2-89dc-4fff084a3ae0" "id": "d825671f-7dc5-46a2-89dc-4fff084a3ae0"
}, },
@ -1155,8 +1191,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 16, "x": 16,
"y": 35, "y": 39,
"i": "d27b522f-9c70-42f2-9e31-fed3816fd675" "i": "d27b522f-9c70-42f2-9e31-fed3816fd675",
"isResizable": true
}, },
"id": "d27b522f-9c70-42f2-9e31-fed3816fd675" "id": "d27b522f-9c70-42f2-9e31-fed3816fd675"
}, },
@ -1197,8 +1234,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 0, "x": 0,
"y": 37, "y": 46,
"i": "f645741e-c632-4685-b267-c7ad26b5c10e" "i": "f645741e-c632-4685-b267-c7ad26b5c10e",
"isResizable": true
}, },
"id": "f645741e-c632-4685-b267-c7ad26b5c10e" "id": "f645741e-c632-4685-b267-c7ad26b5c10e"
}, },
@ -1242,8 +1280,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 8, "x": 8,
"y": 37, "y": 46,
"i": "bbd1ebda-99f6-419c-90a5-5f84973976dd" "i": "bbd1ebda-99f6-419c-90a5-5f84973976dd",
"isResizable": true
}, },
"id": "bbd1ebda-99f6-419c-90a5-5f84973976dd" "id": "bbd1ebda-99f6-419c-90a5-5f84973976dd"
}, },
@ -1279,8 +1318,9 @@
"h": 7, "h": 7,
"w": 8, "w": 8,
"x": 16, "x": 16,
"y": 37, "y": 46,
"i": "d6b45598-54c6-4b36-a896-0a7529ac21f8" "i": "d6b45598-54c6-4b36-a896-0a7529ac21f8",
"isResizable": true
}, },
"id": "d6b45598-54c6-4b36-a896-0a7529ac21f8" "id": "d6b45598-54c6-4b36-a896-0a7529ac21f8"
}, },
@ -1292,8 +1332,9 @@
"h": 1, "h": 1,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 44, "y": 53,
"i": "307152d2-708c-4736-98cf-08b886cbf7f2" "i": "307152d2-708c-4736-98cf-08b886cbf7f2",
"isResizable": false
}, },
"collapsed": true "collapsed": true
}, },
@ -1337,8 +1378,9 @@
"h": 7, "h": 7,
"w": 6, "w": 6,
"x": 0, "x": 0,
"y": 45, "y": 54,
"i": "f2ee5d32-737c-4095-b6b7-b15b778ffdb9" "i": "f2ee5d32-737c-4095-b6b7-b15b778ffdb9",
"isResizable": true
}, },
"id": "f2ee5d32-737c-4095-b6b7-b15b778ffdb9" "id": "f2ee5d32-737c-4095-b6b7-b15b778ffdb9"
}, },
@ -1381,8 +1423,9 @@
"h": 7, "h": 7,
"w": 6, "w": 6,
"x": 6, "x": 6,
"y": 45, "y": 54,
"i": "9113323a-98f5-4bff-a8ce-3b459e7e2190" "i": "9113323a-98f5-4bff-a8ce-3b459e7e2190",
"isResizable": true
}, },
"id": "9113323a-98f5-4bff-a8ce-3b459e7e2190" "id": "9113323a-98f5-4bff-a8ce-3b459e7e2190"
}, },
@ -1425,8 +1468,9 @@
"h": 7, "h": 7,
"w": 6, "w": 6,
"x": 12, "x": 12,
"y": 45, "y": 54,
"i": "9634c41c-e124-4d7f-9406-0f86753e8d70" "i": "9634c41c-e124-4d7f-9406-0f86753e8d70",
"isResizable": true
}, },
"id": "9634c41c-e124-4d7f-9406-0f86753e8d70" "id": "9634c41c-e124-4d7f-9406-0f86753e8d70"
}, },
@ -1469,8 +1513,9 @@
"h": 7, "h": 7,
"w": 6, "w": 6,
"x": 18, "x": 18,
"y": 45, "y": 54,
"i": "4123f4c1-bf8e-400e-b267-8d7f6a92691a" "i": "4123f4c1-bf8e-400e-b267-8d7f6a92691a",
"isResizable": true
}, },
"id": "4123f4c1-bf8e-400e-b267-8d7f6a92691a" "id": "4123f4c1-bf8e-400e-b267-8d7f6a92691a"
}, },
@ -1513,8 +1558,9 @@
"h": 7, "h": 7,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 47, "y": 61,
"i": "cfb80689-de7b-47fb-9155-052b796dd7f5" "i": "cfb80689-de7b-47fb-9155-052b796dd7f5",
"isResizable": true
}, },
"id": "cfb80689-de7b-47fb-9155-052b796dd7f5" "id": "cfb80689-de7b-47fb-9155-052b796dd7f5"
} }

View File

@ -13,10 +13,10 @@ import (
type TagFilter struct { type TagFilter struct {
Key string `json:"key"` // tag key Key string `json:"key"` // tag key
Func string `json:"func"` // == | =~ | in Func string `json:"func"` // `==` | `=~` | `in` | `!=` | `!~` | `not in`
Value string `json:"value"` // tag value Value string `json:"value"` // tag value
Regexp *regexp.Regexp // parse value to regexp if func = '=~' Regexp *regexp.Regexp // parse value to regexp if func = '=~' or '!~'
Vset map[string]struct{} // parse value to regexp if func = 'in' Vset map[string]struct{} // parse value to regexp if func = 'in' or 'not in'
} }
type AlertMute struct { type AlertMute struct {

View File

@ -88,12 +88,12 @@ func (s *AlertSubscribe) Parse() error {
} }
for i := 0; i < len(s.ITags); i++ { for i := 0; i < len(s.ITags); i++ {
if s.ITags[i].Func == "=~" { if s.ITags[i].Func == "=~" || s.ITags[i].Func == "!~" {
s.ITags[i].Regexp, err = regexp.Compile(s.ITags[i].Value) s.ITags[i].Regexp, err = regexp.Compile(s.ITags[i].Value)
if err != nil { if err != nil {
return err return err
} }
} else if s.ITags[i].Func == "in" { } else if s.ITags[i].Func == "in" || s.ITags[i].Func == "not in" {
arr := strings.Fields(s.ITags[i].Value) arr := strings.Fields(s.ITags[i].Value)
s.ITags[i].Vset = make(map[string]struct{}) s.ITags[i].Vset = make(map[string]struct{})
for j := 0; j < len(arr); j++ { for j := 0; j < len(arr); j++ {