diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f30228324..7fe709896c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ Metrics were added to: - [IP Version](https://github.com/libp2p/go-libp2p/pull/2114): Added ip_version label to connection metrics * Identify: - Metrics for Identify, IdentifyPush, PushesTriggered (https://github.com/libp2p/go-libp2p/pull/2069) - - Address Count, Protocol Count, Peer Protocol Support (https://github.com/libp2p/go-libp2p/pull/2126) + - Address Count, Protocol Count, Connection IDPush Support (https://github.com/libp2p/go-libp2p/pull/2126) ## 🐞 Bugfixes diff --git a/dashboards/identify/identify.json b/dashboards/identify/identify.json index 373aa43b49..491766dbb9 100644 --- a/dashboards/identify/identify.json +++ b/dashboards/identify/identify.json @@ -11,12 +11,6 @@ ], "__elements": {}, "__requires": [ - { - "type": "panel", - "id": "gauge", - "name": "Gauge", - "version": "" - }, { "type": "grafana", "id": "grafana", @@ -35,6 +29,12 @@ "name": "Prometheus", "version": "1.0.0" }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, { "type": "panel", "id": "timeseries", @@ -304,6 +304,9 @@ }, "id": 9, "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", "orientation": "auto", "reduceOptions": { "calcs": [ @@ -312,8 +315,7 @@ "fields": "", "values": false }, - "showThresholdLabels": false, - "showThresholdMarkers": true + "textMode": "auto" }, "pluginVersion": "9.3.6", "targets": [ @@ -331,7 +333,7 @@ } ], "title": "Outgoing Address Count", - "type": "gauge" + "type": "stat" }, { "datasource": { @@ -381,6 +383,9 @@ }, "id": 17, "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", "orientation": "auto", "reduceOptions": { "calcs": [ @@ -389,8 +394,7 @@ "fields": "", "values": false }, - "showThresholdLabels": false, - "showThresholdMarkers": true + "textMode": "auto" }, "pluginVersion": "9.3.6", "targets": [ @@ -407,7 +411,7 @@ } ], "title": "Outgoing Protocols Count", - "type": "gauge" + "type": "stat" }, { "datasource": { @@ -600,10 +604,34 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "sum( rate(libp2p_identify_addrs_received_sum[$__rate_interval])) / sum( rate(libp2p_identify_addrs_received_count[$__rate_interval]))", - "legendFormat": "address count", + "expr": "histogram_quantile(0.5, sum(rate(libp2p_identify_addrs_received_bucket[$__rate_interval])) by (le))", + "legendFormat": "50th percentile", "range": true, "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.90, sum(rate(libp2p_identify_addrs_received_bucket[$__rate_interval])) by (le))", + "hide": false, + "legendFormat": "90th percentile", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.99, sum(rate(libp2p_identify_addrs_received_bucket[$__rate_interval])) by (le))", + "hide": false, + "legendFormat": "99 percentile", + "range": true, + "refId": "C" } ], "title": "Incoming Address Count (Avg)", @@ -708,10 +736,34 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "sum(rate( libp2p_identify_protocols_received_sum[$__rate_interval])) / sum(rate(libp2p_identify_protocols_received_count[$__rate_interval]))", - "legendFormat": "protocols count", + "expr": "histogram_quantile(0.5, sum(rate(libp2p_identify_protocols_received_bucket[$__rate_interval])) by (le))", + "legendFormat": "50th percentile", "range": true, "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.90, sum(rate(libp2p_identify_protocols_received_bucket[$__rate_interval])) by (le))", + "hide": false, + "legendFormat": "90th percentile", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.99, sum(rate(libp2p_identify_protocols_received_bucket[$__rate_interval])) by (le))", + "hide": false, + "legendFormat": "99th percentile", + "range": true, + "refId": "C" } ], "title": "Incoming Protocols Count (Avg)", @@ -771,13 +823,13 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "libp2p_identify_conn_push_support", + "expr": "increase(libp2p_identify_conn_push_support_total[$__rate_interval])", "legendFormat": "{{support}}", "range": true, "refId": "A" } ], - "title": "Peers: Push Support", + "title": "New Connections: Push Support", "type": "piechart" } ], diff --git a/p2p/protocol/identify/id.go b/p2p/protocol/identify/id.go index 7b21bc194e..390e8afb7a 100644 --- a/p2p/protocol/identify/id.go +++ b/p2p/protocol/identify/id.go @@ -501,7 +501,7 @@ func (ids *idService) handleIdentifyResponse(s network.Stream, isPush bool) erro } if ids.metricsTracer != nil { - ids.metricsTracer.PeerPushSupport(e.PushSupport) + ids.metricsTracer.ConnPushSupport(e.PushSupport) } ids.conns[c] = e diff --git a/p2p/protocol/identify/metrics.go b/p2p/protocol/identify/metrics.go index 3536bb53f5..28598fa33b 100644 --- a/p2p/protocol/identify/metrics.go +++ b/p2p/protocol/identify/metrics.go @@ -35,11 +35,11 @@ var ( }, []string{"dir"}, ) - peerPushSupport = prometheus.NewCounterVec( + connPushSupportTotal = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: metricNamespace, - Name: "peer_push_support_total", - Help: "Identify Peer Push Support", + Name: "conn_push_support_total", + Help: "Identify Connection Push Support", }, []string{"support"}, ) @@ -77,7 +77,7 @@ var ( pushesTriggered, identify, identifyPush, - peerPushSupport, + connPushSupportTotal, protocolsCount, addrsCount, numProtocolsReceived, @@ -94,8 +94,8 @@ type MetricsTracer interface { // TriggeredPushes counts IdentifyPushes triggered by event TriggeredPushes(event any) - // PeerPushSupport counts peers by Push Support - PeerPushSupport(identifyPushSupport) + // ConnPushSupport counts peers by Push Support + ConnPushSupport(identifyPushSupport) // IdentifyReceived tracks metrics on receiving an identify response IdentifyReceived(isPush bool, numProtocols int, numAddrs int) @@ -151,7 +151,7 @@ func (t *metricsTracer) IncrementPushSupport(s identifyPushSupport) { defer metricshelper.PutStringSlice(tags) *tags = append(*tags, getPushSupport(s)) - peerPushSupport.WithLabelValues(*tags...).Inc() + connPushSupportTotal.WithLabelValues(*tags...).Inc() } func (t *metricsTracer) IdentifySent(isPush bool, numProtocols int, numAddrs int) { @@ -186,12 +186,12 @@ func (t *metricsTracer) IdentifyReceived(isPush bool, numProtocols int, numAddrs numAddrsReceived.Observe(float64(numAddrs)) } -func (t *metricsTracer) PeerPushSupport(support identifyPushSupport) { +func (t *metricsTracer) ConnPushSupport(support identifyPushSupport) { tags := metricshelper.GetStringSlice() defer metricshelper.PutStringSlice(tags) *tags = append(*tags, getPushSupport(support)) - peerPushSupport.WithLabelValues(*tags...).Inc() + connPushSupportTotal.WithLabelValues(*tags...).Inc() } func getPushSupport(s identifyPushSupport) string { diff --git a/p2p/protocol/identify/metrics_test.go b/p2p/protocol/identify/metrics_test.go index b13eba2530..2cf5a209a1 100644 --- a/p2p/protocol/identify/metrics_test.go +++ b/p2p/protocol/identify/metrics_test.go @@ -25,7 +25,7 @@ func TestMetricsNoAllocNoCover(t *testing.T) { tr := NewMetricsTracer() tests := map[string]func(){ "TriggeredPushes": func() { tr.TriggeredPushes(events[rand.Intn(len(events))]) }, - "PeerPushSupport": func() { tr.PeerPushSupport(pushSupport[rand.Intn(len(pushSupport))]) }, + "ConnPushSupport": func() { tr.ConnPushSupport(pushSupport[rand.Intn(len(pushSupport))]) }, "IdentifyReceived": func() { tr.IdentifyReceived(rand.Intn(2) == 0, rand.Intn(20), rand.Intn(20)) }, "IdentifySent": func() { tr.IdentifySent(rand.Intn(2) == 0, rand.Intn(20), rand.Intn(20)) }, }