Skip to content

Commit

Permalink
chore: add metrics of exception and no result
Browse files Browse the repository at this point in the history
  • Loading branch information
jacky-xbb authored and Rory-Z committed Sep 20, 2023
1 parent 952c0ee commit 443f5af
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
29 changes: 15 additions & 14 deletions client/client_4.x.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,22 @@ func (n *cluster4x) getRuleEngineMetrics() (metrics []collector.RuleEngine, err
resp := struct {
Data []struct {
Metrics []struct {
Node string
Node string `json:"node"`
SpeedMax float64 `json:"speed_max"`
SpeedLast5m float64 `json:"speed_last5m"`
Speed float64 `json:"speed"`
Matched int64
Passed int64
//NoResult int64
//Exception int64
Failed int64
Matched int64 `json:"matched"`
Passed int64 `json:"passed"`
NoResult int64 `json:"no_result"`
Exception int64 `json:"exception"`
Failed int64 `json:"failed"`
}
Actions []struct {
Metrics []struct {
Node string
Taken int64
Success int64
Failed int64
Node string `json:"node"`
Taken int64 `json:"taken"`
Success int64 `json:"success"`
Failed int64 `json:"failed"`
}
}
ID string `json:"id"`
Expand Down Expand Up @@ -208,10 +208,11 @@ func (n *cluster4x) getRuleEngineMetrics() (metrics []collector.RuleEngine, err
NodeName: cutNodeName(m.Node),
RuleID: rule.ID,
//ResStatus: unknown,
TopicHitCount: m.Matched,
ExecPassCount: m.Passed,
ExecFailureCount: m.Failed,
//NoResultCount: m.NoResult,
TopicHitCount: m.Matched,
ExecPassCount: m.Passed,
ExecFailureCount: m.Failed,
NoResultCount: m.NoResult,
ExecExceptionCount: m.Exception,
ExecRate: m.Speed,
ExecLast5mRate: m.SpeedLast5m,
ExecMaxRate: m.SpeedMax,
Expand Down
3 changes: 2 additions & 1 deletion client/client_5.x.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (n *cluster5x) getRuleEngineMetrics() (metrics []collector.RuleEngine, err
Matched int64
Passed int64
Failed int64
//Exception int64 `json:"failed.exception"`
Exception int64 `json:"failed.exception"`
NoResult int64 `json:"failed.no_result"`
ActionTotal int64 `json:"actions.total"`
ActionSuccess int64 `json:"actions.success"`
Expand All @@ -166,6 +166,7 @@ func (n *cluster5x) getRuleEngineMetrics() (metrics []collector.RuleEngine, err
TopicHitCount: node.Metrics.Matched,
ExecPassCount: node.Metrics.Passed,
ExecFailureCount: node.Metrics.Failed,
ExecExceptionCount: node.Metrics.Exception,
NoResultCount: node.Metrics.NoResult,
ExecRate: node.Metrics.Rate,
ExecLast5mRate: node.Metrics.RateLast5m,
Expand Down
1 change: 1 addition & 0 deletions collector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type RuleEngine struct {
TopicHitCount int64
ExecPassCount int64
ExecFailureCount int64
ExecExceptionCount int64
NoResultCount int64
ExecRate float64
ExecLast5mRate float64
Expand Down
10 changes: 10 additions & 0 deletions collector/rule_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
ruleExecPassCount = "exec_pass_count"
ruleExecFailureCount = "exec_failure_count"
ruleNoResultCount = "exec_no_result_count"
ruleExecExceptionCount = "exec_exception_count"
ruleExecRate = "exec_rate"
ruleExecLast5mRate = "exec_last5m_rate"
ruleExecMaxRate = "exec_max_rate"
Expand Down Expand Up @@ -111,6 +112,11 @@ func NewRuleEngineCollector(client Cluster, logger log.Logger) (Collector, error
help: "The failure count of rule exec",
labels: []string{"node", "rule"},
},
{
name: ruleExecExceptionCount,
help: "The exception count of rule exec",
labels: []string{"node", "rule"},
},
{
name: ruleNoResultCount,
help: "The no result count of rule exec",
Expand Down Expand Up @@ -199,6 +205,10 @@ func (c *ruleEngineCollector) Update(ch chan<- prometheus.Metric) error {
c.desc[ruleExecFailureCount],
prometheus.CounterValue, float64(metric.ExecFailureCount), metric.NodeName, metric.RuleID,
)
ch <- prometheus.MustNewConstMetric(
c.desc[ruleExecExceptionCount],
prometheus.CounterValue, float64(metric.ExecExceptionCount), metric.NodeName, metric.RuleID,
)
ch <- prometheus.MustNewConstMetric(
c.desc[ruleNoResultCount],
prometheus.CounterValue, float64(metric.NoResultCount), metric.NodeName, metric.RuleID,
Expand Down
8 changes: 4 additions & 4 deletions config/grafana-template/grafanalib-emqx/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@
"expr": "sum by(rule) (emqx_rule_exec_pass_count{cluster=\"$cluster\", node=~\".*\"})",
},
{
"legendFormat": "Exec Failed last 15m",
"expr": "sum by(rule) (irate(emqx_rule_exec_failure_count{cluster=\"$cluster\", node=~\".*\"}[15m]))",
"legendFormat": "Exec Exception last 15m",
"expr": "sum by(rule) (irate(emqx_rule_exec_exception_count{cluster=\"$cluster\", node=~\".*\"}[15m]))",
"thresholds": {
"mode": "absolute",
"steps": [
Expand All @@ -618,8 +618,8 @@
}
},
{
"legendFormat": "Exec No Result",
"expr": "sum by(rule) (emqx_rule_exec_no_result_count{cluster=\"$cluster\", node=~\".*\"})",
"legendFormat": "Exec No Result 15m",
"expr": "sum by(rule) (irate(emqx_rule_exec_no_result_count{cluster=\"$cluster\", node=~\".*\"}[15m]))",
"thresholds": {
"mode": "absolute",
"steps": [
Expand Down

0 comments on commit 443f5af

Please sign in to comment.