From b93b2f530b4340adf958ec517a375cee173cccb0 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Sun, 5 Nov 2023 19:48:41 -0800 Subject: [PATCH] metrics: distinguish events of server level and connection level (#48290) close pingcap/tidb#48289 --- pkg/metrics/grafana/tidb.json | 2 +- pkg/metrics/server.go | 8 ++++---- pkg/server/server.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/metrics/grafana/tidb.json b/pkg/metrics/grafana/tidb.json index d5cc9bff17181..71ed9167e636c 100644 --- a/pkg/metrics/grafana/tidb.json +++ b/pkg/metrics/grafana/tidb.json @@ -2915,7 +2915,7 @@ "expr": "increase(tidb_server_event_total{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}[10m])", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{instance}}-server {{type}}", + "legendFormat": "{{instance}}-{{type}}", "refId": "A" } ], diff --git a/pkg/metrics/server.go b/pkg/metrics/server.go index 27f1f0c9b8ee6..51864ba44ce53 100644 --- a/pkg/metrics/server.go +++ b/pkg/metrics/server.go @@ -37,11 +37,11 @@ var ( ExecuteErrorCounter *prometheus.CounterVec CriticalErrorCounter prometheus.Counter - EventStart = "start" - EventGracefulDown = "graceful_shutdown" + ServerStart = "server-start" + ServerStop = "server-stop" + // Eventkill occurs when the server.Kill() function is called. - EventKill = "kill" - EventClose = "close" + EventKill = "kill" ServerEventCounter *prometheus.CounterVec TimeJumpBackCounter prometheus.Counter diff --git a/pkg/server/server.go b/pkg/server/server.go index 6b3a08ceef8c1..b3c3d8037dfbf 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -419,7 +419,7 @@ func (s *Server) reportConfig() { // Run runs the server. func (s *Server) Run() error { - metrics.ServerEventCounter.WithLabelValues(metrics.EventStart).Inc() + metrics.ServerEventCounter.WithLabelValues(metrics.ServerStart).Inc() s.reportConfig() // Start HTTP API to report tidb info such as TPS. @@ -579,7 +579,7 @@ func (s *Server) closeListener() { s.authTokenCancelFunc() } s.wg.Wait() - metrics.ServerEventCounter.WithLabelValues(metrics.EventClose).Inc() + metrics.ServerEventCounter.WithLabelValues(metrics.ServerStop).Inc() } // Close closes the server.