diff --git a/Makefile b/Makefile index 093f62ef697..535873614d3 100644 --- a/Makefile +++ b/Makefile @@ -179,7 +179,7 @@ BINS+=lotus-bench lotus-stats: rm -f lotus-stats - go build -o lotus-stats ./cmd/lotus-stats + go build $(GOFLAGS) -o lotus-stats ./cmd/lotus-stats go run github.com/GeertJohan/go.rice/rice append --exec lotus-stats -i ./build .PHONY: lotus-stats BINS+=lotus-stats diff --git a/cmd/lotus-stats/chain.dashboard.json b/cmd/lotus-stats/chain.dashboard.json index 5ff7654d016..8083c96b183 100644 --- a/cmd/lotus-stats/chain.dashboard.json +++ b/cmd/lotus-stats/chain.dashboard.json @@ -1,20 +1,11 @@ { - "__inputs": [ - { - "name": "DS_INFLUXDB", - "label": "InfluxDB", - "description": "", - "type": "datasource", - "pluginId": "influxdb", - "pluginName": "InfluxDB" - } - ], + "__inputs": [], "__requires": [ { "type": "grafana", "id": "grafana", "name": "Grafana", - "version": "6.5.0-pre" + "version": "7.3.0" }, { "type": "panel", @@ -36,8 +27,8 @@ }, { "type": "panel", - "id": "table", - "name": "Table", + "id": "table-old", + "name": "Table (old)", "version": "" } ], @@ -58,6 +49,7 @@ "gnetId": null, "graphTooltip": 0, "id": null, + "iteration": 1604018016916, "links": [], "panels": [ { @@ -65,8 +57,15 @@ "bars": true, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", "decimals": 2, + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 3, "fillGradient": 0, "gridPos": { @@ -75,6 +74,7 @@ "x": 0, "y": 0 }, + "hiddenSeries": false, "hideTimeOverride": false, "id": 38, "interval": "", @@ -93,15 +93,25 @@ }, "lines": false, "linewidth": 1, - "nullPointMode": "null", + "nullPointMode": "null as zero", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", - "seriesOverrides": [], + "seriesOverrides": [ + { + "alias": "all", + "bars": false, + "color": "rgb(99, 99, 99)", + "fill": 1, + "lines": true, + "stack": false + } + ], "spaceLength": 10, "stack": true, "steppedLine": false, @@ -128,10 +138,11 @@ "type": "fill" } ], + "hide": false, "measurement": "chain.election", "orderByTime": "ASC", "policy": "default", - "query": "SELECT count(\"value\") FROM \"chain.election\" WHERE $timeFilter -10m GROUP BY time($__interval), \"miner\" fill(null)", + "query": "SELECT sum(\"value\") FROM \"chain.election\" WHERE $timeFilter GROUP BY time($blockInterval), \"miner\" fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -156,13 +167,52 @@ ] ], "tags": [] + }, + { + "alias": "all", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "orderByTime": "ASC", + "policy": "defult", + "query": "SELECT TRIPLE_EXPONENTIAL_MOVING_AVERAGE(sum(\"value\"), 40) FROM \"chain.election\" WHERE $timeFilter -$blockInterval*40 AND time < now() - $blockInterval*3 GROUP BY time($blockInterval) fill(0)", + "rawQuery": true, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] } ], "thresholds": [], "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Blocks Won", + "title": "Blocks and Win Counts", "tooltip": { "shared": true, "sort": 2, @@ -207,7 +257,14 @@ "cacheTimeout": null, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -216,6 +273,7 @@ "x": 0, "y": 9 }, + "hiddenSeries": false, "id": 22, "interval": "", "legend": { @@ -232,9 +290,10 @@ "links": [], "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -318,7 +377,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "s", "gauge": { "maxValue": 100, @@ -350,7 +415,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -422,7 +486,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "bytes", "gauge": { "maxValue": 100, @@ -454,7 +524,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -493,7 +562,7 @@ ], "orderByTime": "ASC", "policy": "default", - "query": "SELECT sum(\"value\") FROM \"chain.miner_power\" WHERE $timeFilter GROUP BY time(45s)", + "query": "SELECT sum(\"value\") FROM \"chain.power\" WHERE $timeFilter GROUP BY time(25s)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -538,7 +607,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "none", "gauge": { "maxValue": 100, @@ -570,7 +645,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -596,7 +670,7 @@ "groupBy": [ { "params": [ - "$interval" + "$blockInterval" ], "type": "time" } @@ -616,7 +690,7 @@ }, { "params": [], - "type": "sum" + "type": "count" } ] ], @@ -648,7 +722,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "none", "gauge": { "maxValue": 100, @@ -680,7 +760,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -746,7 +825,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "s", "gauge": { "maxValue": 100, @@ -778,7 +863,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -848,7 +932,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "none", "gauge": { "maxValue": 100, @@ -880,7 +970,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -906,7 +995,7 @@ "groupBy": [ { "params": [ - "$__interval" + "$blockInterval" ], "type": "time" }, @@ -917,7 +1006,7 @@ "type": "fill" } ], - "measurement": "chain.message_gasprice", + "measurement": "chain.message_gaspremium", "orderByTime": "ASC", "policy": "default", "refId": "A", @@ -932,7 +1021,7 @@ }, { "params": [], - "type": "mean" + "type": "median" } ] ], @@ -942,7 +1031,7 @@ "thresholds": "", "timeFrom": null, "timeShift": null, - "title": "Avg Gas Price", + "title": "Avg Gas Premium", "type": "singlestat", "valueFontSize": "80%", "valueMaps": [ @@ -963,7 +1052,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "decbytes", "gauge": { "maxValue": 100, @@ -995,7 +1090,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -1021,7 +1115,7 @@ "groupBy": [ { "params": [ - "$__interval" + "$blockInterval" ], "type": "time" }, @@ -1078,7 +1172,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "bytes", "gauge": { "maxValue": 100, @@ -1110,7 +1210,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -1136,7 +1235,7 @@ "groupBy": [ { "params": [ - "$__interval" + "$blockInterval" ], "type": "time" }, @@ -1193,7 +1292,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "none", "gauge": { "maxValue": 100, @@ -1225,7 +1330,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "pluginVersion": "6.4.2", "postfix": "", "postfixFontSize": "50%", @@ -1252,7 +1356,7 @@ "groupBy": [ { "params": [ - "$__interval" + "$blockInterval" ], "type": "time" }, @@ -1311,8 +1415,14 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", "decimals": 0, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "dateTimeFromNow", "gauge": { "maxValue": 100, @@ -1344,7 +1454,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -1413,7 +1522,14 @@ "cacheTimeout": null, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -1422,6 +1538,7 @@ "x": 4, "y": 16 }, + "hiddenSeries": false, "id": 2, "legend": { "alignAsTable": true, @@ -1441,9 +1558,10 @@ "links": [], "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -1569,7 +1687,13 @@ "rgba(237, 129, 40, 0.89)", "#d44a3a" ], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "format": "none", "gauge": { "maxValue": 100, @@ -1601,7 +1725,6 @@ "maxDataPoints": 100, "nullPointMode": "connected", "nullText": null, - "options": {}, "postfix": "FIL", "postfixFontSize": "50%", "prefix": "", @@ -1660,7 +1783,13 @@ }, { "columns": [], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "fontSize": "100%", "gridPos": { "h": 21, @@ -1669,7 +1798,6 @@ "y": 19 }, "id": 28, - "options": {}, "pageSize": null, "showHeader": true, "sort": { @@ -1679,12 +1807,14 @@ "styles": [ { "alias": "Time", + "align": "auto", "dateFormat": "YYYY-MM-DD HH:mm:ss", "pattern": "Time", "type": "hidden" }, { "alias": "", + "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", @@ -1701,6 +1831,7 @@ }, { "alias": "", + "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", @@ -1741,7 +1872,7 @@ "timeShift": null, "title": "Top Power Table", "transform": "table", - "type": "table" + "type": "table-old" }, { "aliasColors": {}, @@ -1749,7 +1880,14 @@ "cacheTimeout": null, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 5, "fillGradient": 0, "gridPos": { @@ -1758,8 +1896,9 @@ "x": 4, "y": 19 }, + "hiddenSeries": false, "id": 40, - "interval": "", + "interval": "300s", "legend": { "alignAsTable": true, "avg": false, @@ -1778,11 +1917,12 @@ "lines": true, "linewidth": 1, "links": [], - "nullPointMode": "null", + "nullPointMode": "connected", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": true, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -1817,7 +1957,7 @@ "measurement": "chain.miner_power", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"value\") FROM \"chain.miner_power\" WHERE $timeFilter GROUP BY time($__interval), \"miner\" fill(previous)", + "query": "SELECT mean(\"value\") FROM \"chain.miner_power\" WHERE $timeFilter GROUP BY time($__interval), \"miner\" fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -1885,7 +2025,13 @@ }, { "columns": [], - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, "fontSize": "100%", "gridPos": { "h": 21, @@ -1894,7 +2040,6 @@ "y": 19 }, "id": 18, - "options": {}, "pageSize": null, "showHeader": true, "sort": { @@ -1904,6 +2049,7 @@ "styles": [ { "alias": "Height", + "align": "auto", "dateFormat": "YYYY-MM-DD HH:mm:ss", "link": false, "mappingType": 1, @@ -1914,6 +2060,7 @@ }, { "alias": "Tipset", + "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", @@ -1930,6 +2077,7 @@ }, { "alias": "", + "align": "auto", "colorMode": null, "colors": [ "rgba(245, 54, 54, 0.9)", @@ -1973,74 +2121,77 @@ "timeShift": null, "title": "Chain Table", "transform": "timeseries_to_columns", - "type": "table" + "type": "table-old" }, { "aliasColors": {}, "bars": false, - "cacheTimeout": null, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 1, "fillGradient": 0, "gridPos": { - "h": 6, + "h": 7, "w": 12, "x": 4, "y": 27 }, - "id": 24, + "hiddenSeries": false, + "id": 50, "legend": { - "alignAsTable": false, "avg": false, "current": false, "max": false, "min": false, - "rightSide": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 1, - "links": [], "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", - "seriesOverrides": [ - { - "alias": "/.*/", - "color": "rgb(31, 120, 193)" - } - ], + "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { + "alias": "Total GasLimit", "groupBy": [ { "params": [ - "$__interval" + "$blockInterval" ], "type": "time" }, { "params": [ - "previous" + "null" ], "type": "fill" } ], - "measurement": "chain.pledge_collateral", + "measurement": "chain.gas_limit_total", "orderByTime": "ASC", "policy": "default", + "query": "SELECT max(\"value\") FROM \"chain.gas_limit_total\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": false, "refId": "A", "resultFormat": "time_series", "select": [ @@ -2053,18 +2204,107 @@ }, { "params": [], - "type": "mean" + "type": "max" + } + ] + ], + "tags": [] + }, + { + "alias": "Total GasUsed", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.gas_used_total", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT max(\"value\") FROM \"chain.gas_used_total\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": false, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [] + }, + { + "alias": "Total Unique GasLimit", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.gas_limit_uniq_total", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT max(\"value\") FROM \"chain.gas_limit_total\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": false, + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "max" } ] ], "tags": [] } ], - "thresholds": [], + "thresholds": [ + { + "colorMode": "custom", + "fill": false, + "fillColor": "rgba(50, 116, 217, 0.2)", + "line": true, + "lineColor": "rgba(31, 96, 196, 0.6)", + "op": "gt", + "value": 25000000000, + "yaxis": "left" + } + ], "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Pledge Collateral", + "title": "Network Gas", "tooltip": { "shared": true, "sort": 0, @@ -2081,7 +2321,7 @@ "yaxes": [ { "format": "short", - "label": "FIL", + "label": null, "logBase": 1, "max": null, "min": null, @@ -2107,15 +2347,23 @@ "cacheTimeout": null, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 1, "fillGradient": 0, "gridPos": { - "h": 7, + "h": 6, "w": 12, "x": 4, - "y": 33 + "y": 34 }, + "hiddenSeries": false, "id": 44, "legend": { "avg": false, @@ -2131,9 +2379,10 @@ "links": [], "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -2146,7 +2395,7 @@ "groupBy": [ { "params": [ - "$__interval" + "$blockInterval" ], "type": "time" }, @@ -2228,7 +2477,14 @@ "bars": true, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -2237,6 +2493,7 @@ "x": 0, "y": 40 }, + "hiddenSeries": false, "id": 34, "legend": { "alignAsTable": true, @@ -2251,11 +2508,12 @@ }, "lines": false, "linewidth": 1, - "nullPointMode": "null", + "nullPointMode": "null as zero", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -2269,7 +2527,7 @@ "groupBy": [ { "params": [ - "$__interval" + "$blockInterval" ], "type": "time" }, @@ -2360,7 +2618,14 @@ "bars": true, "dashLength": 10, "dashes": false, - "datasource": "${DS_INFLUXDB}", + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -2369,6 +2634,7 @@ "x": 12, "y": 40 }, + "hiddenSeries": false, "id": 36, "legend": { "alignAsTable": true, @@ -2387,11 +2653,12 @@ }, "lines": false, "linewidth": 1, - "nullPointMode": "null", + "nullPointMode": "null as zero", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.3.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -2437,7 +2704,7 @@ "measurement": "chain.message_count", "orderByTime": "ASC", "policy": "default", - "query": "SELECT sum(\"value\") FROM \"chain.message_count\" WHERE $timeFilter GROUP BY time($__interval), \"method\", \"exitcode\", \"actor\" fill(null)", + "query": "SELECT sum(\"value\") FROM \"chain.message_count\" WHERE $timeFilter GROUP BY time($blockInterval), \"method\", \"exitcode\", \"actor\" fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -2498,14 +2765,701 @@ "align": false, "alignLevel": null } - } - ], - "refresh": "45s", - "schemaVersion": 20, - "style": "dark", - "tags": [], - "templating": { - "list": [] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 49 + }, + "hiddenSeries": false, + "id": 48, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Transfer Fee", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.basefee", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\")*1000000 FROM \"chain.basefee\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Cost of simple transfer [FIL]", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 2, + "format": "sci", + "label": "", + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 49 + }, + "hiddenSeries": false, + "id": 46, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Transfer Fee", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.basefee", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\") FROM \"chain.basefee\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Base Fee[FIL]", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$network", + "decimals": null, + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 57 + }, + "hiddenSeries": false, + "id": 51, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "hideEmpty": false, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Precommit Transfer Fee", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.basefee", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\")*24000000 FROM \"chain.basefee\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Commit Transfer Fee", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.basefee", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\")*56000000 FROM \"chain.basefee\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": true, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Message Gas fees [FIL]", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 2, + "format": "none", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$network", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 57 + }, + "hiddenSeries": false, + "id": 52, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "10 PIB PoSt Fee", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.basefee", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\")*940000000 FROM \"chain.basefee\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "750TiB miner PoSt Fee", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.basefee", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\")*580000000 FROM \"chain.basefee\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": true, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "10TiB miner PoSt Fee", + "groupBy": [ + { + "params": [ + "$blockInterval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.basefee", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\")*380000000 FROM \"chain.basefee\" WHERE $timeFilter GROUP BY time($blockInterval) fill(null)", + "rawQuery": true, + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Message Gas fees [FIL]", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 2, + "format": "none", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": false, + "schemaVersion": 26, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "filecoin-ntwk-testnet", + "value": "filecoin-ntwk-testnet" + }, + "error": null, + "hide": 0, + "includeAll": false, + "label": "Network", + "multi": false, + "name": "network", + "options": [], + "query": "influxdb", + "queryValue": "", + "refresh": 1, + "regex": "/^filecoin-ntwk-/", + "skipUrlSync": false, + "type": "datasource" + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "30s", + "value": "30s" + }, + "error": null, + "hide": 2, + "label": null, + "name": "blockInterval", + "options": [ + { + "selected": true, + "text": "30s", + "value": "30s" + } + ], + "query": "30s", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] }, "time": { "from": "now-30m", @@ -2515,6 +3469,7 @@ "refresh_intervals": [ "5s", "10s", + "25s", "30s", "45s", "1m", @@ -2527,7 +3482,7 @@ ] }, "timezone": "", - "title": "Chain", + "title": "Filecoin Chain Stats", "uid": "z6FtI92Zz", - "version": 9 + "version": 4 } diff --git a/cmd/lotus-stats/docker-compose.yml b/cmd/lotus-stats/docker-compose.yml index 03d573b94ab..b08a2157eea 100644 --- a/cmd/lotus-stats/docker-compose.yml +++ b/cmd/lotus-stats/docker-compose.yml @@ -4,10 +4,10 @@ services: influxdb: image: influxdb:latest container_name: influxdb + ports: + - "18086:8086" environment: - INFLUXDB_DB=lotus - ports: - - "8086:8086" volumes: - influxdb:/var/lib/influxdb @@ -15,7 +15,7 @@ services: image: grafana/grafana:latest container_name: grafana ports: - - "3000:3000" + - "13000:3000" links: - influxdb volumes: diff --git a/cmd/lotus-stats/env.stats b/cmd/lotus-stats/env.stats index a76e7554aa2..ad5ec1619ee 100644 --- a/cmd/lotus-stats/env.stats +++ b/cmd/lotus-stats/env.stats @@ -1,3 +1,3 @@ -export INFLUX_ADDR="http://localhost:8086" +export INFLUX_ADDR="http://localhost:18086" export INFLUX_USER="" export INFLUX_PASS="" diff --git a/cmd/lotus-stats/main.go b/cmd/lotus-stats/main.go index 3ca139b7dc0..b3fce79bf67 100644 --- a/cmd/lotus-stats/main.go +++ b/cmd/lotus-stats/main.go @@ -2,71 +2,158 @@ package main import ( "context" - "flag" "os" + "github.com/filecoin-project/lotus/build" + lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/tools/stats" + logging "github.com/ipfs/go-log/v2" + "github.com/urfave/cli/v2" ) var log = logging.Logger("stats") -const ( - influxAddrEnvVar = "INFLUX_ADDR" - influxUserEnvVar = "INFLUX_USER" - influxPassEnvVar = "INFLUX_PASS" -) - func main() { - var repo string = "~/.lotus" - var database string = "lotus" - var reset bool = false - var nosync bool = false - var height int64 = 0 - var headlag int = 3 - - flag.StringVar(&repo, "repo", repo, "lotus repo path") - flag.StringVar(&database, "database", database, "influx database") - flag.Int64Var(&height, "height", height, "block height to start syncing from (0 will resume)") - flag.IntVar(&headlag, "head-lag", headlag, "number of head events to hold to protect against small reorgs") - flag.BoolVar(&reset, "reset", reset, "truncate database before starting stats gathering") - flag.BoolVar(&nosync, "nosync", nosync, "skip waiting for sync") - - flag.Parse() - - ctx := context.Background() - - influx, err := stats.InfluxClient(os.Getenv(influxAddrEnvVar), os.Getenv(influxUserEnvVar), os.Getenv(influxPassEnvVar)) - if err != nil { - log.Fatal(err) + local := []*cli.Command{ + runCmd, + versionCmd, } - if reset { - if err := stats.ResetDatabase(influx, database); err != nil { - log.Fatal(err) - } + app := &cli.App{ + Name: "lotus-stats", + Usage: "Collect basic information about a filecoin network using lotus", + Version: build.UserVersion(), + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "lotus-path", + EnvVars: []string{"LOTUS_PATH"}, + Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME + }, + &cli.StringFlag{ + Name: "log-level", + EnvVars: []string{"LOTUS_STATS_LOG_LEVEL"}, + Value: "info", + }, + }, + Before: func(cctx *cli.Context) error { + return logging.SetLogLevel("stats", cctx.String("log-level")) + }, + Commands: local, + } + + if err := app.Run(os.Args); err != nil { + log.Errorw("exit in error", "err", err) + os.Exit(1) + return } +} + +var versionCmd = &cli.Command{ + Name: "version", + Usage: "Print version", + Action: func(cctx *cli.Context) error { + cli.VersionPrinter(cctx) + return nil + }, +} + +var runCmd = &cli.Command{ + Name: "run", + Usage: "", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "influx-database", + EnvVars: []string{"LOTUS_STATS_INFLUX_DATABASE"}, + Usage: "influx database", + Value: "", + }, + &cli.StringFlag{ + Name: "influx-hostname", + EnvVars: []string{"LOTUS_STATS_INFLUX_HOSTNAME"}, + Value: "http://localhost:8086", + Usage: "influx hostname", + }, + &cli.StringFlag{ + Name: "influx-username", + EnvVars: []string{"LOTUS_STATS_INFLUX_USERNAME"}, + Usage: "influx username", + Value: "", + }, + &cli.StringFlag{ + Name: "influx-password", + EnvVars: []string{"LOTUS_STATS_INFLUX_PASSWORD"}, + Usage: "influx password", + Value: "", + }, + &cli.IntFlag{ + Name: "height", + EnvVars: []string{"LOTUS_STATS_HEIGHT"}, + Usage: "tipset height to start processing from", + Value: 0, + }, + &cli.IntFlag{ + Name: "head-lag", + EnvVars: []string{"LOTUS_STATS_HEAD_LAG"}, + Usage: "the number of tipsets to delay processing on to smooth chain reorgs", + Value: int(build.MessageConfidence), + }, + &cli.BoolFlag{ + Name: "no-sync", + EnvVars: []string{"LOTUS_STATS_NO_SYNC"}, + Usage: "do not wait for chain sync to complete", + Value: false, + }, + }, + Action: func(cctx *cli.Context) error { + ctx := context.Background() + + resetFlag := cctx.Bool("reset") + noSyncFlag := cctx.Bool("no-sync") + heightFlag := cctx.Int("height") + headLagFlag := cctx.Int("head-lag") + + influxAddrFlag := cctx.String("influx-addr") + influxUserFlag := cctx.String("influx-user") + influxPassFlag := cctx.String("influx-pass") + influxDatabaseFlag := cctx.String("influx-database") - if !reset && height == 0 { - h, err := stats.GetLastRecordedHeight(influx, database) + influx, err := stats.InfluxClient(influxAddrFlag, influxUserFlag, influxPassFlag) if err != nil { - log.Info(err) + log.Fatal(err) } - height = h - } + if resetFlag { + if err := stats.ResetDatabase(influx, influxDatabaseFlag); err != nil { + log.Fatal(err) + } + } - api, closer, err := stats.GetFullNodeAPI(ctx, repo) - if err != nil { - log.Fatal(err) - } - defer closer() + height := int64(heightFlag) - if !nosync { - if err := stats.WaitForSyncComplete(ctx, api); err != nil { - log.Fatal(err) + if !resetFlag && height == 0 { + h, err := stats.GetLastRecordedHeight(influx, influxDatabaseFlag) + if err != nil { + log.Info(err) + } + + height = h } - } - stats.Collect(ctx, api, influx, database, height, headlag) + api, closer, err := lcli.GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + + if !noSyncFlag { + if err := stats.WaitForSyncComplete(ctx, api); err != nil { + log.Fatal(err) + } + } + + stats.Collect(ctx, api, influx, influxDatabaseFlag, height, headLagFlag) + + return nil + }, } diff --git a/cmd/lotus-stats/setup.bash b/cmd/lotus-stats/setup.bash index e2812b93a61..6510c2fc6d7 100755 --- a/cmd/lotus-stats/setup.bash +++ b/cmd/lotus-stats/setup.bash @@ -1,10 +1,10 @@ #!/usr/bin/env bash -GRAFANA_HOST="localhost:3000" +GRAFANA_HOST="http://localhost:13000" curl -s -XPOST http://admin:admin@$GRAFANA_HOST/api/datasources -H 'Content-Type: text/json' --data-binary @- > /dev/null << EOF { - "name":"InfluxDB", + "name":"filecoin-ntwk-localstats", "type":"influxdb", "database":"lotus", "url": "http://influxdb:8086",