diff --git a/.dockerignore b/.dockerignore index ff5d02e8d9..3711472802 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,7 @@ /.githooks /.github !/.github/workflows/staging +/docker /docs /.deepsource.toml /.dockerignore @@ -12,5 +13,4 @@ /docker-compose.yml /Dockerfile /Dockerfile.staging -/prometheus.yml /README.md diff --git a/docker-compose.yml b/docker-compose.yml index 092f5eb0aa..8a300720e2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,60 @@ -version: '3.7' +# This docker-compose.yml configuration contains: +# - a Gossamer node on the Kusama chain +# - a Prometheus server scrapping metrics from Gossamer +# - a Grafana server using the Prometheus server as source +# +# Prometheus and Grafana are both provisioned to give you a dashboard to play with. +# They are tailored for local development, and Grafana gives you anonymous admin access. +# +# You can run all of the containers with: `docker-compose up` +# Alternatively, you can run select containers with for example: `docker-compose up gossamer` +# +# To rebuild the Gossamer Docker image: `docker-compose build` + +version: '3' + +services: + gossamer: + image: chainsafe/gossamer + build: . + volumes: + # Remove with: docker volume rm gossamer + - gossamer:/data/gossamer + command: + - --basepath=/data/gossamer + - --chain=kusama + - --log=info + - --publish-metrics + - --metrics-address=:9876 + - --pprofserver + ports: + - 6060:6060/tcp # Pprof server + - 7001:7001/tcp # Network port + - 8545:8545/tcp # RPC HTTP port + - 8546:8546/tcp # RPC Websocket port + expose: + - 9876/tcp # Prometheus metrics for Prometheus server -services: prometheus: image: prom/prometheus volumes: - - ./prometheus.yml:/etc/prometheus/prometheus.yml - command: - - '--config.file=/etc/prometheus/prometheus.yml' - - '--storage.tsdb.path=/prometheus' - - '--web.console.libraries=/usr/share/prometheus/console_libraries' - - '--web.console.templates=/usr/share/prometheus/consoles' + - ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro + # The following line can be uncommented to persist metrics data. + # - gossamer-prometheus:/prometheus + expose: + - 9090/tcp # Prometheus metrics for Grafana + + grafana: + image: grafana/grafana-oss ports: - - 9090:9090 - restart: always \ No newline at end of file + - 3000:3000/tcp # HTTP Web interface at http://localhost:3000/ + volumes: + - ./docker/grafana/grafana.ini:/etc/grafana/grafana.ini:ro + - ./docker/grafana/provisioning:/etc/grafana/provisioning:ro + # The following line can be uncommented to persist modifications. + # - gossamer-grafana:/var/lib/grafana + +volumes: + gossamer: + gossamer-prometheus: + gossamer-grafana: diff --git a/docker/grafana/grafana.ini b/docker/grafana/grafana.ini new file mode 100644 index 0000000000..b0149ca1ed --- /dev/null +++ b/docker/grafana/grafana.ini @@ -0,0 +1,12 @@ +# See https://github.com/grafana/grafana/blob/main/conf/sample.ini + +[dashboards] +min_refresh_interval = 5s +default_home_dashboard_path = /etc/grafana/provisioning/dashboards/gossamer.json + +[users] +allow_sign_up = false + +[auth.anonymous] +enabled = true +org_role = Admin diff --git a/docker/grafana/provisioning/dashboards/gossamer.json b/docker/grafana/provisioning/dashboards/gossamer.json new file mode 100644 index 0000000000..315f253aff --- /dev/null +++ b/docker/grafana/provisioning/dashboards/gossamer.json @@ -0,0 +1,1610 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 1, + "links": [], + "liveNow": false, + "panels": [ + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 36, + "title": "Resource usage", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 3, + "x": 0, + "y": 1 + }, + "id": 34, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "expr": "go_goroutines{instance=~\".*gossamer.*\"}", + "refId": "A" + } + ], + "title": "Goroutines", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 3, + "x": 3, + "y": 1 + }, + "id": 37, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "expr": "go_threads{instance=~\".*gossamer.*\"}", + "refId": "A" + } + ], + "title": "Threads", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 3, + "x": 6, + "y": 1 + }, + "id": 38, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "expr": "process_resident_memory_bytes{instance=~\".*gossamer.*\"}", + "refId": "A" + } + ], + "title": "Memory usage", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 7 + }, + "id": 39, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "process_resident_memory_bytes{instance=~\".*gossamer.*\"}", + "legendFormat": "Resident memory", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "go_memstats_heap_inuse_bytes{instance=~\".*gossamer.*\"}", + "hide": false, + "legendFormat": "Heap", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "go_memstats_stack_inuse_bytes{instance=~\".*gossamer.*\"}", + "hide": false, + "legendFormat": "Stack", + "range": true, + "refId": "C" + } + ], + "title": "Memory usage", + "type": "timeseries" + }, + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 31, + "title": "Top", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "light-blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 0, + "y": 17 + }, + "id": 18, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_syncer_blocks_synced_total", + "hide": false, + "legendFormat": "Blocks synced", + "range": true, + "refId": "E" + } + ], + "title": "Blocks synced", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "0": { + "color": "orange", + "index": 0, + "text": "Bootstrap" + }, + "1": { + "color": "green", + "index": 1, + "text": "Tip" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 3, + "x": 4, + "y": 17 + }, + "id": 19, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_syncer_is_synced", + "hide": false, + "legendFormat": "Inbound total", + "range": true, + "refId": "E" + } + ], + "title": "Sync status", + "type": "stat" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 28, + "panels": [], + "title": "State tries", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Tries in memory" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 23 + }, + "id": 26, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_storage_tries_set_total - gossamer_storage_tries_delete_total", + "legendFormat": "Tries in memory", + "range": true, + "refId": "A" + } + ], + "title": "Number of tries in memory", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 29 + }, + "id": 10, + "panels": [], + "title": "Network", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 10 + }, + { + "color": "#EAB839", + "value": 20 + }, + { + "color": "super-light-green", + "value": 30 + }, + { + "color": "light-green", + "value": 40 + }, + { + "color": "green", + "value": 50 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 0, + "y": 30 + }, + "id": 12, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_node_peer_count_total", + "legendFormat": "Peers count", + "range": true, + "refId": "A" + } + ], + "title": "Peers count", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 10 + }, + { + "color": "#EAB839", + "value": 20 + }, + { + "color": "super-light-green", + "value": 30 + }, + { + "color": "light-green", + "value": 40 + }, + { + "color": "green", + "value": 50 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 4, + "y": 30 + }, + "id": 32, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_node_connections_total", + "legendFormat": "Peers count", + "range": true, + "refId": "A" + } + ], + "title": "Connections count", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 40 + }, + { + "color": "semi-dark-orange", + "value": 100 + }, + { + "color": "red", + "value": 200 + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 8, + "y": 30 + }, + "id": 14, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_node_latency_ms", + "legendFormat": "Latency", + "range": true, + "refId": "A" + } + ], + "title": "Latency", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Inbound total" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Outbounds total" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-yellow", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 36 + }, + "id": 17, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_streams_inbound_total", + "hide": false, + "legendFormat": "Inbound total", + "range": true, + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_streams_outbound_total", + "hide": false, + "legendFormat": "Outbounds total", + "range": true, + "refId": "F" + } + ], + "title": "Messages traffic", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Block announce inbound" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Inbound" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 42 + }, + "id": 16, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_streams_block_announce_inbound_total", + "interval": "", + "legendFormat": "Inbound", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_streams_block_announce_outbound_total", + "hide": false, + "legendFormat": "Outbound", + "range": true, + "refId": "B" + } + ], + "title": "Block announce messages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Inbound" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 48 + }, + "id": 29, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_streams_grandpa_inbound_total", + "hide": false, + "legendFormat": "Inbound", + "range": true, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_network_streams_grandpa_outbound_total", + "hide": false, + "legendFormat": "Outbount", + "range": true, + "refId": "D" + } + ], + "title": "Grandpa messages", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 54 + }, + "id": 25, + "panels": [], + "title": "State", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 55 + }, + "id": 21, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_state_transaction_pool_total", + "legendFormat": "Transactions in pool", + "range": true, + "refId": "A" + } + ], + "title": "Number of transactions in pool", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 55 + }, + "id": 22, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_state_transaction_queue_total", + "legendFormat": "Queued transactions", + "range": true, + "refId": "A" + } + ], + "title": "Number of queued transactions", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 61 + }, + "id": 4, + "panels": [], + "title": "Grandpa", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 62 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_grandpa_round", + "legendFormat": "Grandpa round", + "range": true, + "refId": "A" + } + ], + "title": "Grandpa round", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 62 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_id" + }, + "editorMode": "code", + "expr": "gossamer_block_leaves_total", + "legendFormat": "Block leaves total", + "range": true, + "refId": "A" + } + ], + "title": "Block leaves total", + "type": "timeseries" + } + ], + "refresh": "5s", + "schemaVersion": 36, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Gossamer", + "uid": "xEr0aRzVz", + "version": 3, + "weekStart": "" +} \ No newline at end of file diff --git a/docker/grafana/provisioning/dashboards/gossamer.yml b/docker/grafana/provisioning/dashboards/gossamer.yml new file mode 100644 index 0000000000..18588b38f2 --- /dev/null +++ b/docker/grafana/provisioning/dashboards/gossamer.yml @@ -0,0 +1,9 @@ +apiVersion: 1 + +providers: + - name: "JSON files" + orgId: 1 + updateIntervalSeconds: 300 + allowUiUpdates: true + options: + path: /etc/grafana/provisioning/dashboards diff --git a/docker/grafana/provisioning/datasources/source.yml b/docker/grafana/provisioning/datasources/source.yml new file mode 100644 index 0000000000..76755daa4b --- /dev/null +++ b/docker/grafana/provisioning/datasources/source.yml @@ -0,0 +1,10 @@ +apiVersion: 1 +datasources: + - name: Prometheus + version: 1 + type: prometheus + access: proxy + uid: prometheus_id + url: http://prometheus:9090 + isDefault: true + editable: true diff --git a/docker/prometheus/prometheus.yml b/docker/prometheus/prometheus.yml new file mode 100644 index 0000000000..88d165df8a --- /dev/null +++ b/docker/prometheus/prometheus.yml @@ -0,0 +1,13 @@ +global: + scrape_interval: 5s + evaluation_interval: 5s + +scrape_configs: + - job_name: prometheus + static_configs: + - targets: ["localhost:9090"] + + - job_name: gossamer + metrics_path: /metrics + static_configs: + - targets: ["gossamer:9876"] diff --git a/docs/docs/integrate/using-prometheus.md b/docs/docs/integrate/using-prometheus.md index 256c54d691..3bf8dd7252 100644 --- a/docs/docs/integrate/using-prometheus.md +++ b/docs/docs/integrate/using-prometheus.md @@ -4,28 +4,11 @@ title: Using Prometheus permalink: /integrate/using-prometheus/ --- -# Using Prometheus Locally - -To get started with Prometheus locally make sure you have installed [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/). - -The docker-compose.yml file has, currently, the Prometheus to collect metrics, so to start that service you can execute (in the project root folder): - -``` -docker-compose up (-d to disatach the terminal) - -or - -docker-compose up prometheus (-d to disatach the terminal) -``` - -the above command will starts the Prometheus service on `0.0.0.0:9090`. - -### Prometheus - -Actually the Prometheus service reads a file `prometheus.yml` placed in the root level project folder, this file contains the definitions that Prometheus needs to collect the metrics. - -Linux: In the **job_name == gossamer** the **targets** property should be `[localhost:9876]` - -To publish metrics from the node use the flag `--publish-metrics`; i.e, `./bin/gossamer --chain {chain} --key {key} --publish-metrics`. - -By default, the Prometheus server listens on `localhost:9876`, which you can change with `--metrics-address`. To listen on all interfaces, you can use `--metrics-address=":9876"`. +1. Install [Docker](https://docs.docker.com/engine/install/) +1. Install [Docker Compose](https://docs.docker.com/compose/install/). +1. 📥 [Download the repository](https://github.com/ChainSafe/gossamer/archive/refs/heads/development.zip) or `git clone https://github.com/ChainSafe/gossamer.git` it. +1. 🏃 You can run the repository [docker-compose.yml](https://github.com/ChainSafe/gossamer/blob/development/docker-compose.yml) with `docker-compose up`. +By default, it will run a Gossamer node running on the Kusama chain, together with a Prometheus server and Grafana server. Both Prometheus and Grafana are pre-configured to show a nice dashboard of the metrics. All the relevant configuration lives in the `docker` directory of the repository. +1. 🖱️ Access the Grafana dashboard at [localhost:3000](http://localhost:3000/), there is no login required. + +💁 You can modify the `docker` directory and the `docker-compose.yml` file to match the desired configuration. diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index ac766a3772..0826ff9704 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -57,7 +57,7 @@ func NewServer(address string) (s *Server) { // Start will start a dedicated metrics server at the given address. func (s *Server) Start(address string) (err error) { - logger.Infof("Starting metrics server at http://%s/metrics", address) + logger.Infof("Starting metrics server to listen on %s", address) ctx, cancel := context.WithCancel(context.Background()) s.cancel = cancel diff --git a/prometheus.yml b/prometheus.yml deleted file mode 100644 index fc6ccfb55d..0000000000 --- a/prometheus.yml +++ /dev/null @@ -1,15 +0,0 @@ -global: - scrape_interval: 5s - evaluation_interval: 5s - -scrape_configs: - - job_name: prometheus - static_configs: - - targets: ['localhost:9090'] - - job_name: gossamer_alice - metrics_path: /metrics - static_configs: - - targets: ['alice:9876'] - - job_name: substrate_bob - static_configs: - - targets: ['bob:9876'] \ No newline at end of file