diff --git a/metrics/grafana/pd.json b/metrics/grafana/pd.json index 62b2e7234ef..7a83b5d5448 100644 --- a/metrics/grafana/pd.json +++ b/metrics/grafana/pd.json @@ -12940,478 +12940,6 @@ "title": "Heartbeat", "type": "row" }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 31 - }, - "id": 1400, - "panels": [ - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": {}, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 24 - }, - "id": 1401, - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "targets": [ - { - "expr": "sum(rate(pd_scheduler_read_byte_hist_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "B" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Read Region Byte", - "transparent": true, - "type": "bargauge" - }, - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": {}, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 24 - }, - "id": 1402, - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "targets": [ - { - "expr": "sum(rate(pd_scheduler_write_byte_hist_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "B" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Write Region Byte", - "transparent": true, - "type": "bargauge" - }, - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": { - "align": null - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 32 - }, - "id": 1403, - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "targets": [ - { - "expr": "sum(rate(pd_scheduler_read_key_hist_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "C" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Read Region Key", - "transparent": true, - "type": "bargauge" - }, - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": { - "align": null - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 32 - }, - "id": 1404, - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "targets": [ - { - "expr": "sum(rate(pd_scheduler_write_key_hist_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "C" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Write Region Key", - "transparent": true, - "type": "bargauge" - }, - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": { - "align": null - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 40 - }, - "id": 1405, - "interval": "", - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "repeatDirection": "h", - "targets": [ - { - "expr": "sum(rate(pd_scheduler_store_heartbeat_interval_hist_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "A" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Store Heartbeat Interval", - "transparent": true, - "type": "bargauge" - }, - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": { - "align": null - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 40 - }, - "id": 1406, - "interval": "", - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "repeatDirection": "h", - "targets": [ - { - "expr": "sum(rate(pd_scheduler_region_heartbeat_interval_hist_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "A" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Region Heartbeat Interval", - "transparent": true, - "type": "bargauge" - }, - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": { - "align": null - }, - "mappings": [] - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 48 - }, - "id": 1407, - "interval": "", - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "repeatDirection": "h", - "targets": [ - { - "expr": "sum(rate(pd_server_bucket_report_interval_seconds_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=~\"$tidb_cluster.*\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "A" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Bucket Report Interval", - "transparent": true, - "type": "bargauge" - }, - { - "datasource": "${DS_TEST-CLUSTER}", - "fieldConfig": { - "defaults": { - "custom": { - "align": null - }, - "mappings": [] - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 48 - }, - "id": 1408, - "interval": "", - "options": { - "displayMode": "lcd", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "7.1.5", - "repeatDirection": "h", - "targets": [ - { - "expr": "sum(rate(pd_scheduler_buckets_hot_degree_hist_bucket{k8s_cluster=\"$k8s_cluster\", tidb_cluster=~\"$tidb_cluster.*\"}[1m])) by (le)", - "format": "heatmap", - "hide": false, - "interval": "", - "legendFormat": "{{le}}", - "refId": "A" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Hot Degree of Bucket", - "transparent": true, - "type": "bargauge" - } - ], - "title": "Heartbeat distribution ", - "type": "row" - }, { "collapsed": true, "gridPos": { diff --git a/pkg/mcs/scheduling/server/cluster.go b/pkg/mcs/scheduling/server/cluster.go index 43e0179412e..c07174762ff 100644 --- a/pkg/mcs/scheduling/server/cluster.go +++ b/pkg/mcs/scheduling/server/cluster.go @@ -414,9 +414,6 @@ func (c *Cluster) HandleStoreHeartbeat(heartbeat *schedulingpb.StoreHeartbeatReq nowTime := time.Now() newStore := store.Clone(core.SetStoreStats(stats), core.SetLastHeartbeatTS(nowTime)) - if store := c.GetStore(storeID); store != nil { - statistics.UpdateStoreHeartbeatMetrics(store) - } c.PutStore(newStore) c.hotStat.Observe(storeID, newStore.GetStoreStats()) c.hotStat.FilterUnhealthyStore(c) diff --git a/pkg/statistics/buckets/bucket_stat_informer.go b/pkg/statistics/buckets/bucket_stat_informer.go index 888027f1f5f..032c85b78b0 100644 --- a/pkg/statistics/buckets/bucket_stat_informer.go +++ b/pkg/statistics/buckets/bucket_stat_informer.go @@ -208,10 +208,3 @@ func (b *BucketTreeItem) calculateHotDegree() { } } } - -// collectBucketsMetrics collects the metrics of the hot stats. -func (b *BucketTreeItem) collectBucketsMetrics() { - for _, bucket := range b.stats { - bucketsHotDegreeHist.Observe(float64(bucket.HotDegree)) - } -} diff --git a/pkg/statistics/buckets/hot_bucket_cache.go b/pkg/statistics/buckets/hot_bucket_cache.go index f29ef1563e8..88c7c064727 100644 --- a/pkg/statistics/buckets/hot_bucket_cache.go +++ b/pkg/statistics/buckets/hot_bucket_cache.go @@ -201,7 +201,6 @@ func (h *HotBucketCache) checkBucketsFlow(buckets *metapb.Buckets) (newItem *Buc } newItem.inherit(overlaps) newItem.calculateHotDegree() - newItem.collectBucketsMetrics() return newItem, overlaps } diff --git a/pkg/statistics/buckets/metric.go b/pkg/statistics/buckets/metric.go index ebc911b1410..cf8b492346f 100644 --- a/pkg/statistics/buckets/metric.go +++ b/pkg/statistics/buckets/metric.go @@ -19,15 +19,6 @@ import ( ) var ( - bucketsHotDegreeHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "buckets_hot_degree_hist", - Help: "Bucketed histogram of bucket hot degree", - Buckets: prometheus.LinearBuckets(-20, 2, 20), // [-20 20] - }) - bucketsTaskDuration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: "pd", @@ -39,6 +30,5 @@ var ( ) func init() { - prometheus.MustRegister(bucketsHotDegreeHist) prometheus.MustRegister(bucketsTaskDuration) } diff --git a/pkg/statistics/hot_peer_cache.go b/pkg/statistics/hot_peer_cache.go index 77b5d567ca4..962290a8ba6 100644 --- a/pkg/statistics/hot_peer_cache.go +++ b/pkg/statistics/hot_peer_cache.go @@ -135,30 +135,6 @@ func (f *HotPeerCache) incMetrics(action utils.ActionType, storeID uint64) { f.metrics[storeID][action].Inc() } -func (f *HotPeerCache) collectPeerMetrics(loads []float64, interval uint64) { - regionHeartbeatIntervalHist.Observe(float64(interval)) - if interval == 0 { - return - } - // TODO: use unified metrics. (keep backward compatibility at the same time) - for _, k := range f.kind.RegionStats() { - switch k { - case utils.RegionReadBytes: - readByteHist.Observe(loads[int(k)]) - case utils.RegionReadKeys: - readKeyHist.Observe(loads[int(k)]) - case utils.RegionWriteBytes: - writeByteHist.Observe(loads[int(k)]) - case utils.RegionWriteKeys: - writeKeyHist.Observe(loads[int(k)]) - case utils.RegionWriteQueryNum: - writeQueryHist.Observe(loads[int(k)]) - case utils.RegionReadQueryNum: - readQueryHist.Observe(loads[int(k)]) - } - } -} - // CollectExpiredItems collects expired items, mark them as needDelete and puts them into inherit items func (f *HotPeerCache) CollectExpiredItems(region *core.RegionInfo) []*HotPeerStat { regionID := region.GetID() @@ -185,7 +161,6 @@ func (f *HotPeerCache) CheckPeerFlow(region *core.RegionInfo, peers []*metapb.Pe return nil } - f.collectPeerMetrics(deltaLoads, interval) // update metrics regionID := region.GetID() regionPeers := region.GetPeers() diff --git a/pkg/statistics/metrics.go b/pkg/statistics/metrics.go index 68cbf142479..64e040b8d66 100644 --- a/pkg/statistics/metrics.go +++ b/pkg/statistics/metrics.go @@ -81,70 +81,6 @@ var ( Name: "label_level", Help: "Number of regions in the different label level.", }, []string{"type"}) - readByteHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "read_byte_hist", - Help: "The distribution of region read bytes", - Buckets: prometheus.ExponentialBuckets(1, 8, 12), - }) - writeByteHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "write_byte_hist", - Help: "The distribution of region write bytes", - Buckets: prometheus.ExponentialBuckets(1, 8, 12), - }) - readKeyHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "read_key_hist", - Help: "The distribution of region read keys", - Buckets: prometheus.ExponentialBuckets(1, 2, 18), - }) - writeKeyHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "write_key_hist", - Help: "The distribution of region write keys", - Buckets: prometheus.ExponentialBuckets(1, 2, 18), - }) - readQueryHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "read_query_hist", - Help: "The distribution of region read query", - Buckets: prometheus.ExponentialBuckets(1, 2, 12), - }) - writeQueryHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "write_query_hist", - Help: "The distribution of region write query", - Buckets: prometheus.ExponentialBuckets(1, 2, 12), - }) - regionHeartbeatIntervalHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "region_heartbeat_interval_hist", - Help: "Bucketed histogram of the batch size of handled requests.", - Buckets: prometheus.LinearBuckets(0, 30, 20), - }) - storeHeartbeatIntervalHist = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: "pd", - Subsystem: "scheduler", - Name: "store_heartbeat_interval_hist", - Help: "Bucketed histogram of the batch size of handled requests.", - Buckets: prometheus.LinearBuckets(0, 5, 12), - }) regionAbnormalPeerDuration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ @@ -187,12 +123,6 @@ func init() { prometheus.MustRegister(configStatusGauge) prometheus.MustRegister(StoreLimitGauge) prometheus.MustRegister(regionLabelLevelGauge) - prometheus.MustRegister(readByteHist) - prometheus.MustRegister(readKeyHist) - prometheus.MustRegister(writeKeyHist) - prometheus.MustRegister(writeByteHist) - prometheus.MustRegister(regionHeartbeatIntervalHist) - prometheus.MustRegister(storeHeartbeatIntervalHist) prometheus.MustRegister(regionAbnormalPeerDuration) prometheus.MustRegister(hotCacheFlowQueueStatusGauge) prometheus.MustRegister(hotPeerSummary) diff --git a/pkg/statistics/store.go b/pkg/statistics/store.go index fbbfea72700..39c638caaff 100644 --- a/pkg/statistics/store.go +++ b/pkg/statistics/store.go @@ -129,11 +129,6 @@ func (s *StoresStats) FilterUnhealthyStore(cluster core.StoreSetInformer) { } } -// UpdateStoreHeartbeatMetrics is used to update store heartbeat interval metrics -func UpdateStoreHeartbeatMetrics(store *core.StoreInfo) { - storeHeartbeatIntervalHist.Observe(time.Since(store.GetLastHeartbeatTS()).Seconds()) -} - // RollingStoreStats are multiple sets of recent historical records with specified windows size. type RollingStoreStats struct { syncutil.RWMutex diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index 6a0416acd67..4a712e13698 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -1040,7 +1040,6 @@ func (c *RaftCluster) HandleStoreHeartbeat(heartbeat *pdpb.StoreHeartbeatRequest newStore = newStore.Clone(core.SetLastPersistTime(nowTime)) } } - statistics.UpdateStoreHeartbeatMetrics(store) // Supply NodeState in the response to help the store handle special cases // more conveniently, such as avoiding calling `remove_peer` redundantly under // NodeState_Removing.