Skip to content

Commit

Permalink
update dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Feb 23, 2023
1 parent 0f0778c commit 81f80d2
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <!-- omit in toc -->
Expand Down
88 changes: 70 additions & 18 deletions dashboards/identify/identify.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
],
"__elements": {},
"__requires": [
{
"type": "panel",
"id": "gauge",
"name": "Gauge",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
Expand All @@ -35,6 +29,12 @@
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "timeseries",
Expand Down Expand Up @@ -304,6 +304,9 @@
},
"id": 9,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
Expand All @@ -312,8 +315,7 @@
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
"textMode": "auto"
},
"pluginVersion": "9.3.6",
"targets": [
Expand All @@ -331,7 +333,7 @@
}
],
"title": "Outgoing Address Count",
"type": "gauge"
"type": "stat"
},
{
"datasource": {
Expand Down Expand Up @@ -381,6 +383,9 @@
},
"id": 17,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
Expand All @@ -389,8 +394,7 @@
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
"textMode": "auto"
},
"pluginVersion": "9.3.6",
"targets": [
Expand All @@ -407,7 +411,7 @@
}
],
"title": "Outgoing Protocols Count",
"type": "gauge"
"type": "stat"
},
{
"datasource": {
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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"
}
],
Expand Down
2 changes: 1 addition & 1 deletion p2p/protocol/identify/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions p2p/protocol/identify/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
)
Expand Down Expand Up @@ -77,7 +77,7 @@ var (
pushesTriggered,
identify,
identifyPush,
peerPushSupport,
connPushSupportTotal,
protocolsCount,
addrsCount,
numProtocolsReceived,
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion p2p/protocol/identify/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)) },
}
Expand Down

0 comments on commit 81f80d2

Please sign in to comment.