Use metrics with labels, fix #24 (#27)

This commit is contained in:
Kim De Mey 2020-06-09 13:44:39 +02:00 committed by GitHub
parent 89ced4253c
commit 37d8720d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 168 additions and 169 deletions

View File

@ -15,28 +15,23 @@
"editable": true, "editable": true,
"gnetId": null, "gnetId": null,
"graphTooltip": 0, "graphTooltip": 0,
"id": 8, "id": 2,
"links": [], "links": [],
"panels": [ "panels": [
{ {
"datasource": null, "datasource": null,
"gridPos": { "fieldConfig": {
"h": 4, "defaults": {
"w": 6, "color": {
"x": 0, "mode": "thresholds"
"y": 0 },
}, "custom": {},
"id": 16, "mappings": [],
"options": { "max": 100,
"fieldOptions": { "min": 0,
"calcs": [ "thresholds": {
"last" "mode": "absolute",
], "steps": [
"defaults": {
"mappings": [],
"max": 100,
"min": 0,
"thresholds": [
{ {
"color": "green", "color": "green",
"value": null "value": null
@ -46,15 +41,30 @@
"value": 80 "value": 80
} }
] ]
}, }
"override": {}, },
"overrides": []
},
"gridPos": {
"h": 4,
"w": 6,
"x": 0,
"y": 0
},
"id": 16,
"options": {
"orientation": "auto",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false "values": false
}, },
"orientation": "auto",
"showThresholdLabels": false, "showThresholdLabels": false,
"showThresholdMarkers": true "showThresholdMarkers": true
}, },
"pluginVersion": "6.4.5", "pluginVersion": "7.0.3",
"targets": [ "targets": [
{ {
"expr": "connected_peers{node=\"0\"}", "expr": "connected_peers{node=\"0\"}",
@ -76,6 +86,12 @@
"#d44a3a" "#d44a3a"
], ],
"datasource": null, "datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"format": "none", "format": "none",
"gauge": { "gauge": {
"maxValue": 100, "maxValue": 100,
@ -107,7 +123,6 @@
"maxDataPoints": 100, "maxDataPoints": 100,
"nullPointMode": "connected", "nullPointMode": "connected",
"nullText": null, "nullText": null,
"options": {},
"postfix": "", "postfix": "",
"postfixFontSize": "50%", "postfixFontSize": "50%",
"prefix": "", "prefix": "",
@ -127,10 +142,12 @@
"ymax": null, "ymax": null,
"ymin": null "ymin": null
}, },
"tableColumn": "", "tableColumn": "envelopes_valid_total{instance=\"127.0.0.1:8010\", job=\"wakusim\", node=\"0\"}",
"targets": [ "targets": [
{ {
"expr": "valid_envelopes_total{node=\"0\"}", "expr": "envelopes_valid_total{node=\"0\"}",
"interval": "",
"legendFormat": "",
"refId": "A" "refId": "A"
} }
], ],
@ -159,6 +176,12 @@
"#d44a3a" "#d44a3a"
], ],
"datasource": null, "datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"format": "none", "format": "none",
"gauge": { "gauge": {
"maxValue": 100, "maxValue": 100,
@ -190,7 +213,6 @@
"maxDataPoints": 100, "maxDataPoints": 100,
"nullPointMode": "connected", "nullPointMode": "connected",
"nullText": null, "nullText": null,
"options": {},
"pluginVersion": "6.4.5", "pluginVersion": "6.4.5",
"postfix": "", "postfix": "",
"postfixFontSize": "50%", "postfixFontSize": "50%",
@ -211,18 +233,19 @@
"ymax": null, "ymax": null,
"ymin": null "ymin": null
}, },
"tableColumn": "", "tableColumn": "Dropped envelopes",
"targets": [ "targets": [
{ {
"expr": "dropped_expired_envelopes_total{node=\"0\"} + dropped_from_future_envelopes_total{node=\"0\"} + dropped_low_pow_envelopes_total{node=\"0\"} + dropped_too_large_envelopes_total{node=\"0\"} + dropped_bloom_filter_mismatch_envelopes_total{node=\"0\"} + dropped_topic_mismatch_envelopes_total{node=\"0\"} +dropped_benign_duplicate_envelopes_total{node=\"0\"} + dropped_duplicate_envelopes_total{node=\"0\"}", "expr": "sum(envelopes_dropped_total{node=\"0\"})",
"legendFormat": "Invalid envelopes", "interval": "",
"legendFormat": "Dropped envelopes",
"refId": "A" "refId": "A"
} }
], ],
"thresholds": "", "thresholds": "",
"timeFrom": null, "timeFrom": null,
"timeShift": null, "timeShift": null,
"title": "Invalid Envelopes #0", "title": "Dropped Envelopes #0",
"type": "singlestat", "type": "singlestat",
"valueFontSize": "80%", "valueFontSize": "80%",
"valueMaps": [ "valueMaps": [
@ -236,23 +259,18 @@
}, },
{ {
"datasource": null, "datasource": null,
"gridPos": { "fieldConfig": {
"h": 4, "defaults": {
"w": 5, "color": {
"x": 14, "mode": "thresholds"
"y": 0 },
}, "custom": {},
"id": 14, "mappings": [],
"options": { "max": 200,
"fieldOptions": { "min": 0,
"calcs": [ "thresholds": {
"lastNotNull" "mode": "absolute",
], "steps": [
"defaults": {
"mappings": [],
"max": 200,
"min": 0,
"thresholds": [
{ {
"color": "green", "color": "green",
"value": null "value": null
@ -261,17 +279,32 @@
"color": "red", "color": "red",
"value": 200 "value": 200
} }
], ]
"unit": "percent"
}, },
"override": {}, "unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 5,
"x": 14,
"y": 0
},
"id": 14,
"options": {
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false "values": false
}, },
"orientation": "auto",
"showThresholdLabels": false, "showThresholdLabels": false,
"showThresholdMarkers": true "showThresholdMarkers": true
}, },
"pluginVersion": "6.4.5", "pluginVersion": "7.0.3",
"targets": [ "targets": [
{ {
"expr": "rate(process_cpu_seconds_total{node=\"0\"}[5s]) * 100", "expr": "rate(process_cpu_seconds_total{node=\"0\"}[5s]) * 100",
@ -286,23 +319,18 @@
}, },
{ {
"datasource": null, "datasource": null,
"gridPos": { "fieldConfig": {
"h": 4, "defaults": {
"w": 5, "color": {
"x": 19, "mode": "thresholds"
"y": 0 },
}, "custom": {},
"id": 18, "mappings": [],
"options": { "max": 2147483648,
"fieldOptions": { "min": 0,
"calcs": [ "thresholds": {
"lastNotNull" "mode": "absolute",
], "steps": [
"defaults": {
"mappings": [],
"max": 2147483648,
"min": 0,
"thresholds": [
{ {
"color": "green", "color": "green",
"value": null "value": null
@ -311,17 +339,32 @@
"color": "red", "color": "red",
"value": 2147483648 "value": 2147483648
} }
], ]
"unit": "bytes"
}, },
"override": {}, "unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 5,
"x": 19,
"y": 0
},
"id": 18,
"options": {
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false "values": false
}, },
"orientation": "auto",
"showThresholdLabels": false, "showThresholdLabels": false,
"showThresholdMarkers": true "showThresholdMarkers": true
}, },
"pluginVersion": "6.4.5", "pluginVersion": "7.0.3",
"targets": [ "targets": [
{ {
"expr": "process_resident_memory_bytes{node=\"0\"}", "expr": "process_resident_memory_bytes{node=\"0\"}",
@ -339,6 +382,12 @@
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": null, "datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0, "fillGradient": 0,
"gridPos": { "gridPos": {
@ -347,6 +396,7 @@
"x": 0, "x": 0,
"y": 4 "y": 4
}, },
"hiddenSeries": false,
"id": 6, "id": 6,
"legend": { "legend": {
"avg": false, "avg": false,
@ -374,72 +424,20 @@
"steppedLine": false, "steppedLine": false,
"targets": [ "targets": [
{ {
"expr": "valid_envelopes_total{node=\"0\"}", "expr": "envelopes_valid_total{node=\"0\"}",
"hide": false, "hide": false,
"instant": false, "instant": false,
"interval": "",
"legendFormat": "Valid", "legendFormat": "Valid",
"refId": "A" "refId": "A"
}, },
{ {
"expr": "dropped_benign_duplicate_envelopes_total{node=\"0\"}", "expr": "envelopes_dropped_total{node=\"0\"}",
"hide": false, "hide": false,
"instant": false, "instant": false,
"legendFormat": "Benign duplicate", "interval": "",
"legendFormat": "Dropped {{reason}}",
"refId": "B" "refId": "B"
},
{
"expr": "dropped_duplicate_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Duplicate",
"refId": "C"
},
{
"expr": "dropped_expired_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Expired",
"refId": "D"
},
{
"expr": "dropped_from_future_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Future timestamped",
"refId": "E"
},
{
"expr": "dropped_low_pow_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Too low PoW",
"refId": "F"
},
{
"expr": "dropped_bloom_filter_mismatch_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Bloom filter mismatch",
"refId": "G"
},
{
"expr": "dropped_topic_mismatch_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Topic mismatch",
"refId": "H"
},
{
"expr": "dropped_too_large_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Too Large",
"refId": "I"
},
{
"expr": "dropped_full_queue_new_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Full queue new",
"refId": "J"
},
{
"expr": "dropped_full_queue_old_envelopes_total{node=\"0\"}",
"hide": false,
"legendFormat": "Full queue old",
"refId": "K"
} }
], ],
"thresholds": [], "thresholds": [],
@ -489,6 +487,12 @@
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": null, "datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0, "fillGradient": 0,
"gridPos": { "gridPos": {
@ -497,6 +501,7 @@
"x": 12, "x": 12,
"y": 4 "y": 4
}, },
"hiddenSeries": false,
"id": 2, "id": 2,
"legend": { "legend": {
"avg": false, "avg": false,
@ -593,6 +598,12 @@
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": null, "datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0, "fillGradient": 0,
"gridPos": { "gridPos": {
@ -601,6 +612,7 @@
"x": 0, "x": 0,
"y": 13 "y": 13
}, },
"hiddenSeries": false,
"id": 8, "id": 8,
"legend": { "legend": {
"avg": false, "avg": false,
@ -684,6 +696,12 @@
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": null, "datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0, "fillGradient": 0,
"gridPos": { "gridPos": {
@ -692,6 +710,7 @@
"x": 12, "x": 12,
"y": 13 "y": 13
}, },
"hiddenSeries": false,
"id": 4, "id": 4,
"legend": { "legend": {
"avg": false, "avg": false,
@ -781,7 +800,7 @@
} }
], ],
"refresh": "5s", "refresh": "5s",
"schemaVersion": 20, "schemaVersion": 25,
"style": "dark", "style": "dark",
"tags": [], "tags": [],
"templating": { "templating": {
@ -793,7 +812,6 @@
}, },
"timepicker": { "timepicker": {
"refresh_intervals": [ "refresh_intervals": [
"5s",
"10s", "10s",
"30s", "30s",
"1m", "1m",
@ -806,7 +824,7 @@
] ]
}, },
"timezone": "", "timezone": "",
"title": "Waku Node", "title": "Waku Node2",
"uid": "K7Z6IoBZk", "uid": "K7Z6IoBZk",
"version": 2 "version": 5
} }

View File

@ -1,15 +1,14 @@
import import
unittest, strformat, options, stew/byteutils, json_rpc/[rpcserver, rpcclient], unittest, strformat, options, os, stew/byteutils,
json_rpc/[rpcserver, rpcclient],
eth/common as eth_common, eth/[rlp, keys, p2p], eth/common as eth_common, eth/[rlp, keys, p2p],
../../waku/protocol/v1/waku_protocol, ../../waku/protocol/v1/waku_protocol,
../../waku/node/v1/rpc/[hexstrings, rpc_types, waku, key_storage], ../../waku/node/v1/rpc/[hexstrings, rpc_types, waku, key_storage],
./test_helpers ./test_helpers
from os import DirSep, ParDir
## Generate client convenience marshalling wrappers from forward declarations ## Generate client convenience marshalling wrappers from forward declarations
## For testing, ethcallsigs needs to be kept in sync with ../waku/node/v1/rpc/waku ## For testing, ethcallsigs needs to be kept in sync with ../waku/node/v1/rpc/waku
const sigPath = &"{sourceDir}{DirSep}{ParDir}{DirSep}{ParDir}{DirSep}waku{DirSep}node{DirSep}v1{DirSep}rpc{DirSep}wakucallsigs.nim" const sigPath = sourceDir / ParDir / ParDir / "waku" / "node" / "v1" / "rpc" / "wakucallsigs.nim"
createRpcSigs(RpcSocketClient, sigPath) createRpcSigs(RpcSocketClient, sigPath)
proc setupNode(capabilities: varargs[ProtocolInfo, `protocolInfo`]): EthereumNode = proc setupNode(capabilities: varargs[ProtocolInfo, `protocolInfo`]): EthereumNode =

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit a110f091af38e070781de28fea400303d5b3cf43 Subproject commit be9a87848e068d68aa8fa1a7bfa07d7c7271eba7

2
vendor/nim-stew vendored

@ -1 +1 @@
Subproject commit a99dafab420bcbbffee35e9bd847a9014eafaffe Subproject commit cf82e2d51d12c3ca461cb170c2a4e2eada3bfe67

View File

@ -128,18 +128,11 @@ proc run(config: WakuNodeConf) =
proc logMetrics(udata: pointer) {.closure, gcsafe.} = proc logMetrics(udata: pointer) {.closure, gcsafe.} =
{.gcsafe.}: {.gcsafe.}:
let let
connectedPeers = connected_peers.value connectedPeers = connected_peers
validEnvelopes = waku_protocol.valid_envelopes.value validEnvelopes = waku_protocol.envelopes_valid
invalidEnvelopes = waku_protocol.dropped_expired_envelopes.value + droppedEnvelopes = waku_protocol.envelopes_dropped
waku_protocol.dropped_from_future_envelopes.value +
waku_protocol.dropped_low_pow_envelopes.value +
waku_protocol.dropped_too_large_envelopes.value +
waku_protocol.dropped_bloom_filter_mismatch_envelopes.value +
waku_protocol.dropped_topic_mismatch_envelopes.value +
waku_protocol.dropped_benign_duplicate_envelopes.value +
waku_protocol.dropped_duplicate_envelopes.value
info "Node metrics", connectedPeers, validEnvelopes, invalidEnvelopes info "Node metrics", connectedPeers, validEnvelopes, droppedEnvelopes
addTimer(Moment.fromNow(2.seconds), logMetrics) addTimer(Moment.fromNow(2.seconds), logMetrics)
addTimer(Moment.fromNow(2.seconds), logMetrics) addTimer(Moment.fromNow(2.seconds), logMetrics)

View File

@ -48,17 +48,6 @@ export
logScope: logScope:
topics = "waku" topics = "waku"
declarePublicCounter dropped_low_pow_envelopes,
"Dropped envelopes because of too low PoW"
declarePublicCounter dropped_too_large_envelopes,
"Dropped envelopes because larger than maximum allowed size"
declarePublicCounter dropped_bloom_filter_mismatch_envelopes,
"Dropped envelopes because not matching with bloom filter"
declarePublicCounter dropped_topic_mismatch_envelopes,
"Dropped envelopes because of not matching topics"
declarePublicCounter dropped_duplicate_envelopes,
"Dropped duplicate envelopes"
const const
defaultQueueCapacity = 2048 defaultQueueCapacity = 2048
wakuVersion* = 1 ## Waku version. wakuVersion* = 1 ## Waku version.
@ -191,23 +180,23 @@ proc allowed*(msg: Message, config: WakuConfig): bool =
# Check max msg size, already happens in RLPx but there is a specific waku # Check max msg size, already happens in RLPx but there is a specific waku
# max msg size which should always be < RLPx max msg size # max msg size which should always be < RLPx max msg size
if msg.size > config.maxMsgSize: if msg.size > config.maxMsgSize:
dropped_too_large_envelopes.inc() envelopes_dropped.inc(labelValues = ["too_large"])
warn "Message size too large", size = msg.size warn "Message size too large", size = msg.size
return false return false
if msg.pow < config.powRequirement: if msg.pow < config.powRequirement:
dropped_low_pow_envelopes.inc() envelopes_dropped.inc(labelValues = ["low_pow"])
warn "Message PoW too low", pow = msg.pow, minPow = config.powRequirement warn "Message PoW too low", pow = msg.pow, minPow = config.powRequirement
return false return false
if config.topics.isSome(): if config.topics.isSome():
if msg.env.topic notin config.topics.get(): if msg.env.topic notin config.topics.get():
dropped_topic_mismatch_envelopes.inc() envelopes_dropped.inc(labelValues = ["topic_mismatch"])
warn "Message topic does not match Waku topic list" warn "Message topic does not match Waku topic list"
return false return false
else: else:
if config.bloom.isSome() and not bloomFilterMatch(config.bloom.get(), msg.bloom): if config.bloom.isSome() and not bloomFilterMatch(config.bloom.get(), msg.bloom):
dropped_bloom_filter_mismatch_envelopes.inc() envelopes_dropped.inc(labelValues = ["bloom_filter_mismatch"])
warn "Message does not match node bloom filter" warn "Message does not match node bloom filter"
return false return false
@ -314,7 +303,7 @@ p2pProtocol Waku(version = wakuVersion,
# this node to a peer and that same message arriving from that peer (after # this node to a peer and that same message arriving from that peer (after
# it was received from another peer) here. # it was received from another peer) here.
if peer.state.received.containsOrIncl(msg.hash): if peer.state.received.containsOrIncl(msg.hash):
dropped_duplicate_envelopes.inc() envelopes_dropped.inc(labelValues = ["duplicate"])
trace "Peer sending duplicate messages", peer, hash = $msg.hash trace "Peer sending duplicate messages", peer, hash = $msg.hash
# await peer.disconnect(SubprotocolReason) # await peer.disconnect(SubprotocolReason)
continue continue