Skip to content

Commit

Permalink
chore: sync grafana dashboard and EMQX dashboard
Browse files Browse the repository at this point in the history
fix: #88

Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed May 6, 2024
1 parent e364f7d commit 9f8ab82
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 73 deletions.
6 changes: 3 additions & 3 deletions collector/collector_rule_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const (

ruleTopicHitCount = "topic_hit_count"
ruleExecPassCount = "exec_pass_count"
ruleExecFailureCount = "exec_failure_count"
ruleNoResultCount = "exec_no_result_count"
ruleExecExceptionCount = "exec_exception_count"
ruleExecFailureCount = "exec_failure_count" // failure count = no result count + exec exception count, it's didn't show in EMQX dashboard
ruleNoResultCount = "exec_no_result_count" // show in EMQX dashboard
ruleExecExceptionCount = "exec_exception_count" // show in EMQX dashboard
ruleExecRate = "exec_rate"
ruleExecLast5mRate = "exec_last5m_rate"
ruleExecMaxRate = "exec_max_rate"
Expand Down
44 changes: 26 additions & 18 deletions grafana-dashboard/grafanalib/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
# Makefile to run Python scripts with customizable arguments

# Default values for arguments
# EDITION_ARG can be ee or ce
EDITION_ARG ?= ee
# VERSION_ARG can be 4 or 5
VERSION_ARG ?= 5
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
JSON_DIR = $(PROJECT_DIR)/json

# Phony target to handle all tasks
.PHONY: all clean
ifeq ($(VERSION_ARG),4)
all: $(JSON_DIR) overview.json client-events.json messages.json rule-engine-rate.json rule-engine-count.json
else
all: $(JSON_DIR) overview.json authentication.json authorization.json client-events.json messages.json rule-engine-rate.json rule-engine-count.json
endif
.PHONY: all
all: emqx_4 emqx_ee_4 emqx_5 emqx_ee_5

.PHONY: emqx_4
emqx_4: EDITION_ARG=ce
emqx_4: VERSION_ARG=4
emqx_4: JSON_DIR = $(PROJECT_DIR)/../template/emqx-4
emqx_4: $(JSON_DIR) overview.json client-events.json messages.json rule-engine-rate.json rule-engine-count.json

.PHONY: emqx_ee_4
emqx_ee_4: EDITION_ARG=ee
emqx_ee_4: VERSION_ARG=4
emqx_ee_4: JSON_DIR = $(PROJECT_DIR)/../template/emqx-enterprise-4
emqx_ee_4: $(JSON_DIR) overview.json client-events.json messages.json rule-engine-rate.json rule-engine-count.json

.PHONY: emqx_5
emqx_5: EDITION_ARG=ce
emqx_5: VERSION_ARG=5
emqx_5: JSON_DIR = $(PROJECT_DIR)/../template/emqx-5
emqx_5: $(JSON_DIR) overview.json authentication.json authorization.json client-events.json messages.json rule-engine-rate.json rule-engine-count.json

.PHONY: emqx_ee_5
emqx_ee_5: EDITION_ARG=ee
emqx_ee_5: VERSION_ARG=5
emqx_ee_5: JSON_DIR = $(PROJECT_DIR)/../template/emqx-enterprise-5
emqx_ee_5: $(JSON_DIR) overview.json authentication.json authorization.json client-events.json messages.json rule-engine-rate.json rule-engine-count.json

# Create json directory if it doesn't exist
$(JSON_DIR):
Expand All @@ -41,8 +54,3 @@ rule-engine-rate.json:

rule-engine-count.json:
./rule-engine-count.py > $(JSON_DIR)/rule-engine-count.json

# Clean up by removing the json directory
clean:
rm -rf $(JSON_DIR)

26 changes: 0 additions & 26 deletions grafana-dashboard/grafanalib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,6 @@ pipenv shell

## Generate Dashboard JSON

- Generate EMQX 5.x Enterprise Dashboard

```shell
make
```

- Generate EMQX 5.x Community Edition Dashboard

```shell
make EDITION_ARG=ce VERSION_ARG=5
```

- Generate EMQX 4.x Enterprise Dashboard

```shell
make EDITION_ARG=ee VERSION_ARG=4
```

- Generate EMQX 4.x Community Edition Dashboard

```shell
make EDITION_ARG=ce VERSION_ARG=4
```

## Remove Dashboard JSON

```shell
make clean
```
10 changes: 5 additions & 5 deletions grafana-dashboard/grafanalib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@
"format": "timeseries"
},
"rule_engine_exec_failure": {
"title": "Rule Engine Exec Failure",
"title": "Rule Engine Exec Exception",
"subchart_links": (subcharts["rule-engine-count"], ["subchart_rule_engine_exec_failure"]),
"targets": [
{
"legendFormat": "{{rule}}",
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))"
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))"
}
],
"format": "timeseries"
Expand Down Expand Up @@ -1270,7 +1270,7 @@
},
{
"legendFormat": "Exec Exception last 15m",
"expr": "sum by(node, rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"expr": "sum by(node, rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"thresholds": {
"mode": "absolute",
"steps": [
Expand Down Expand Up @@ -1341,11 +1341,11 @@
"format": "timeseries"
},
"subchart_rule_engine_exec_failure": {
"title": "Rule Engine Exec Failure",
"title": "Rule Engine Exec Exception",
"targets": [
{
"legendFormat": "{{ node }}:{{ rule }}",
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",

}
],
Expand Down
6 changes: 3 additions & 3 deletions grafana-dashboard/grafanalib/submetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
},
{
"legendFormat": "Exec Exception last 15m",
"expr": "sum by(node, rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"expr": "sum by(node, rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"thresholds": {
"mode": "absolute",
"steps": [
Expand Down Expand Up @@ -388,11 +388,11 @@
"format": "timeseries"
},
"subchart_rule_engine_exec_failure": {
"title": "Rule Engine Exec Failure",
"title": "Rule Engine Exec Exception",
"targets": [
{
"legendFormat": "{{ node }}:{{ rule }}",
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",

}
],
Expand Down
8 changes: 4 additions & 4 deletions grafana-dashboard/template/emqx-4/overview.json
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@
{
"targetBlank": true,
"title": "Show Rule Engine Exec Failure Node Detail",
"url": "/d/rule-engine-count/Rule Engine Exec Failure?orgId=1&refresh=10s&var-node=All&viewPanel=3"
"url": "/d/rule-engine-count/Rule Engine Exec Exception?orgId=1&refresh=10s&var-node=All&viewPanel=3"
}
],
"maxDataPoints": 100,
Expand All @@ -1508,23 +1508,23 @@
"targets": [
{
"datasource": null,
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"format": "timeseries",
"hide": false,
"instant": false,
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{rule}}",
"metric": "",
"query": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"query": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"refId": "{{rule}}",
"step": 10,
"target": ""
}
],
"timeFrom": null,
"timeShift": null,
"title": "Rule Engine Exec Failure",
"title": "Rule Engine Exec Exception",
"transformations": [],
"transparent": false,
"type": "timeseries"
Expand Down
10 changes: 5 additions & 5 deletions grafana-dashboard/template/emqx-4/rule-engine-count.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@
},
{
"datasource": null,
"expr": "sum by(node, rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"expr": "sum by(node, rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"intervalFactor": 1,
"legendFormat": "Exec Exception last 15m",
"metric": "",
"query": "sum by(node, rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"query": "sum by(node, rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"refId": "exec_exception_last_15m",
"step": 10,
"target": ""
Expand Down Expand Up @@ -583,23 +583,23 @@
"targets": [
{
"datasource": null,
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"format": "timeseries",
"hide": false,
"instant": false,
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{ node }}:{{ rule }}",
"metric": "",
"query": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"query": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"refId": "{{_node_}}:{{_rule_}}",
"step": 10,
"target": ""
}
],
"timeFrom": null,
"timeShift": null,
"title": "Rule Engine Exec Failure",
"title": "Rule Engine Exec Exception",
"transformations": [],
"transparent": false,
"type": "timeseries"
Expand Down
8 changes: 4 additions & 4 deletions grafana-dashboard/template/emqx-enterprise-5/overview.json
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@
{
"targetBlank": true,
"title": "Show Rule Engine Exec Failure Node Detail",
"url": "/d/rule-engine-count/Rule Engine Exec Failure?orgId=1&refresh=10s&var-node=All&viewPanel=3"
"url": "/d/rule-engine-count/Rule Engine Exec Exception?orgId=1&refresh=10s&var-node=All&viewPanel=3"
}
],
"maxDataPoints": 100,
Expand All @@ -1879,23 +1879,23 @@
"targets": [
{
"datasource": null,
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"format": "timeseries",
"hide": false,
"instant": false,
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{rule}}",
"metric": "",
"query": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"query": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\".*\"}[$__rate_interval]))",
"refId": "{{rule}}",
"step": 10,
"target": ""
}
],
"timeFrom": null,
"timeShift": null,
"title": "Rule Engine Exec Failure",
"title": "Rule Engine Exec Exception",
"transformations": [],
"transparent": false,
"type": "timeseries"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@
},
{
"datasource": null,
"expr": "sum by(node, rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"expr": "sum by(node, rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"format": "table",
"hide": false,
"instant": true,
"interval": "",
"intervalFactor": 1,
"legendFormat": "Exec Exception last 15m",
"metric": "",
"query": "sum by(node, rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"query": "sum by(node, rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[15m]))",
"refId": "exec_exception_last_15m",
"step": 10,
"target": ""
Expand Down Expand Up @@ -583,23 +583,23 @@
"targets": [
{
"datasource": null,
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"format": "timeseries",
"hide": false,
"instant": false,
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{ node }}:{{ rule }}",
"metric": "",
"query": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"query": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\"$node\", rule=~\"$rule\"}[$__rate_interval]))",
"refId": "{{_node_}}:{{_rule_}}",
"step": 10,
"target": ""
}
],
"timeFrom": null,
"timeShift": null,
"title": "Rule Engine Exec Failure",
"title": "Rule Engine Exec Exception",
"transformations": [],
"transparent": false,
"type": "timeseries"
Expand Down

0 comments on commit 9f8ab82

Please sign in to comment.