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

View File

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

View File

@ -88,12 +88,12 @@ func (s *AlertSubscribe) Parse() error {
}
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)
if err != nil {
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)
s.ITags[i].Vset = make(map[string]struct{})
for j := 0; j < len(arr); j++ {