From b7c328369bc4186336e70a54ee793e4c1454aa5e Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 28 Sep 2020 23:16:26 -0700 Subject: [PATCH] adding dockerfiles and compose file --- .gitignore | 1 + Dockerfile-monero | 34 ++ Dockerfile-monerod_exporter | 11 + docker-compose.yaml | 63 ++++ files/grafana/daemon_metrics.json | 506 ++++++++++++++++++++++++++++++ files/grafana/dashboards.yaml | 13 + files/grafana/prometheus.yaml | 9 + files/prometheus/prometheus.yml | 17 + 8 files changed, 654 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile-monero create mode 100644 Dockerfile-monerod_exporter create mode 100644 docker-compose.yaml create mode 100644 files/grafana/daemon_metrics.json create mode 100644 files/grafana/dashboards.yaml create mode 100644 files/grafana/prometheus.yaml create mode 100644 files/prometheus/prometheus.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1269488 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data diff --git a/Dockerfile-monero b/Dockerfile-monero new file mode 100644 index 0000000..7610a7c --- /dev/null +++ b/Dockerfile-monero @@ -0,0 +1,34 @@ +FROM ubuntu:19.10 as og + +WORKDIR /opt/monero + +RUN apt-get update && apt-get install -y \ + build-essential cmake pkg-config libboost-all-dev \ + libssl-dev libzmq3-dev libunbound-dev libsodium-dev libpgm-dev git + +RUN git clone https://github.com/monero-project/monero --branch=v0.17.0.1 --depth=1 . + +RUN git submodule update --init --force + +RUN make -j2 + +FROM ubuntu:19.10 + +WORKDIR /data + +COPY --from=og /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ +COPY --from=og /opt/monero/build/Linux/_no_branch_/release/bin/monerod /bin/monerod +COPY --from=og /opt/monero/build/Linux/_no_branch_/release/bin/monero-wallet-cli /bin/monero-wallet-cli +COPY --from=og /opt/monero/build/Linux/_no_branch_/release/bin/monero-wallet-rpc /bin/monero-wallet-rpc + +RUN adduser --system --group --disabled-password monero && \ + mkdir -p /data && \ + chown -R monero:monero /data + +USER monero + +EXPOSE 18080 +EXPOSE 18081 +EXPOSE 18083 + +ENTRYPOINT ["monerod", "--data-dir=/data", "--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=18080", "--rpc-bind-ip=0.0.0.0", "--rpc-bind-port=18083", "--non-interactive", "--confirm-external-bind", "--public-node", "--rpc-restricted-bind-port=18081", "--log-level=0"] diff --git a/Dockerfile-monerod_exporter b/Dockerfile-monerod_exporter new file mode 100644 index 0000000..6b3b2c4 --- /dev/null +++ b/Dockerfile-monerod_exporter @@ -0,0 +1,11 @@ +FROM node:8 + +WORKDIR /opt/monerod_exporter + +RUN git clone https://github.com/lalanza808/monerod_exporter.git --branch=docker --depth=1 . + +RUN npm install + +EXPOSE 8080 + +ENTRYPOINT ["node", "index.js"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..10dece5 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,63 @@ +version: '3' +volumes: + grafana: + prometheus: +services: + prometheus: + image: prom/prometheus:v2.18.0 + container_name: prometheus + restart: unless-stopped + 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 + - --web.enable-admin-api + volumes: + - prometheus:/prometheus + - ./files/prometheus:/etc/prometheus + ports: + - 9090:9090 + grafana: + image: grafana/grafana:6.5.0 + container_name: grafana + restart: unless-stopped + ports: + - 3000:3000 + environment: + HOSTNAME: grafana + GF_SECURITY_ADMIN_USER: admin + GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD} + GF_SERVER_ROOT_URL: ${GRAFANA_URL} + GF_ANALYTICS_REPORTING_ENABLED: "false" + GF_ANALYTICS_CHECK_FOR_UPDATES: "false" + GF_USERS_ALLOW_SIGN_UP: "false" + GF_USERS_ALLOW_ORG_CREATE: "false" + GF_LOG_LEVEL: "debug" + volumes: + - ./files/grafana/dashboards.yaml:/etc/grafana/provisioning/dashboards/default.yaml:ro + - ./files/grafana/prometheus.yaml:/etc/grafana/provisioning/datasources/prometheus.yaml:ro + - ./files/grafana/daemon_metrics.json:/var/lib/grafana/dashboards/daemon_metrics.json:ro + - grafana:/var/lib/grafana + exporter: + container_name: exporter + build: + context: . + dockerfile: Dockerfile-monerod_exporter + restart: unless-stopped + environment: + DAEMON_HOST: http://monerod:18083 + PORT: 8080 + ports: + - 8080:8080 + monerod: + container_name: monerod + build: + context: . + dockerfile: Dockerfile-monero + volumes: + - ./data:/data + ports: + - 18080:18080 + - 18081:18081 + - 18083:18083 diff --git a/files/grafana/daemon_metrics.json b/files/grafana/daemon_metrics.json new file mode 100644 index 0000000..89b967c --- /dev/null +++ b/files/grafana/daemon_metrics.json @@ -0,0 +1,506 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 1, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "avg(monerod_connections_incoming)", + "legendFormat": "Incoming", + "refId": "A" + }, + { + "expr": "avg(monerod_connections_outgoing)", + "legendFormat": "Outgoing", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Connections", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "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": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "/.*/", + "color": "#C4162A" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": true, + "targets": [ + { + "expr": "avg(monerod_block_difficulty)", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Difficulty", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "none", + "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": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 8, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "/.*/", + "color": "#FA6400" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "avg(monerod_block_reward)", + "legendFormat": "Block Reward (XMR)", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Block Reward (XMR)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 9 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "/.*/", + "color": "#8F3BB8" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": true, + "targets": [ + { + "expr": "avg(monerod_tx_mempool)", + "legendFormat": "Pool Transactions", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Mempool Transactions", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "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 + } + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorPostfix": false, + "colorPrefix": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 5, + "w": 8, + "x": 8, + "y": 17 + }, + "id": 10, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "expr": "avg(monerod_tx_chain)", + "instant": true, + "refId": "A" + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Total Transactions", + "type": "singlestat", + "valueFontSize": "100%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + } + ], + "refresh": "30s", + "schemaVersion": 21, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Daemon Stats", + "uid": "0ktA4KDGk", + "version": 2 +} diff --git a/files/grafana/dashboards.yaml b/files/grafana/dashboards.yaml new file mode 100644 index 0000000..ce46f5a --- /dev/null +++ b/files/grafana/dashboards.yaml @@ -0,0 +1,13 @@ +apiVersion: 1 + +providers: +- name: 'default' + orgId: 1 + folder: '' + type: file + disableDeletion: true + editable: true + updateIntervalSeconds: 60 + allowUiUpdates: true + options: + path: /var/lib/grafana/dashboards diff --git a/files/grafana/prometheus.yaml b/files/grafana/prometheus.yaml new file mode 100644 index 0000000..c80e238 --- /dev/null +++ b/files/grafana/prometheus.yaml @@ -0,0 +1,9 @@ +apiVersion: 1 + +datasources: +- name: Prometheus + type: prometheus + url: http://prometheus:9090 + access: proxy + isDefault: true + timeInterval: 10s diff --git a/files/prometheus/prometheus.yml b/files/prometheus/prometheus.yml new file mode 100644 index 0000000..aadcb08 --- /dev/null +++ b/files/prometheus/prometheus.yml @@ -0,0 +1,17 @@ +global: + scrape_interval: 30s + evaluation_interval: 60s + + external_labels: + monitor: monerod-exporter + +scrape_configs: + - job_name: "monerod-exporter" + static_configs: + - targets: ["exporter:8080"] + +alerting: + alertmanagers: + - static_configs: + - targets: + # - alertmanager:9093