From 1aec892a022d84b544b00c585cdc778fa2fad974 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Tue, 16 Jan 2024 15:33:56 +0100 Subject: [PATCH] Run container as keeper user, add basic auth to prometheus --- cloud-config.yaml | 2 +- docker-compose.yaml | 5 +++-- example.env | 20 +++++++++++++++++-- grafana/dashboards/drift-keeper.json | 14 ++++++------- .../provisioning/datasources/datasource.yml | 4 ++++ prometheus/prometheus.yml | 9 --------- prometheus/web.yml | 2 ++ 7 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 prometheus/web.yml diff --git a/cloud-config.yaml b/cloud-config.yaml index 4e6bd57..bf8bb76 100644 --- a/cloud-config.yaml +++ b/cloud-config.yaml @@ -34,7 +34,7 @@ runcmd: - git clone https://github.com/0x1d/drift-keeper /app/bot - mv /app/.env /app/bot/.env - mv /app/config.yaml /app/bot/config.yaml - - cd /app/bot && docker-compose up -d + - cd /app/bot && sudo -u keeper -g bot -- docker-compose up -d write_files: - path: /app/.env diff --git a/docker-compose.yaml b/docker-compose.yaml index 422f59a..a42687d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -20,8 +20,9 @@ services: container_name: prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - #ports: - # - 9090:9090 + - '--web.config.file=/etc/prometheus/web.yml' + ports: + - 9090:9090 restart: unless-stopped volumes: - ./prometheus:/etc/prometheus diff --git a/example.env b/example.env index 1382b02..36bacfc 100644 --- a/example.env +++ b/example.env @@ -9,10 +9,26 @@ GRAFANA_ADMIN_PASSWORD=grafana # Drift Config ENV=mainnet-beta -ENDPOINT=https://solana-mainnet.rpc.extrnode.com/your-api-key -WS_ENDPOINT=wss://solana-mainnet.rpc.extrnode.com/your-api-key KEEPER_PRIVATE_KEY="[123,345,...]" +# Hetzner DE +ENDPOINT=http://178.63.126.77:8899 +# OVH FR +#ENDPOINT=http://141.95.126.29:8899 +# Cloudvider GB +#ENDPOINT=http://194.127.173.58:8899 +#CherryServers LT +#ENDPOINT=http://84.32.189.122:8099 +# Teraswitch US +#ENDPOINT=http://74.118.139.251:8899 +# Teraswitch2 US +#ENDPOINT=http://74.118.139.68:8899 + + +# ExtrNode +#ENDPOINT=https://solana-mainnet.rpc.extrnode.com/your-api-key +#WS_ENDPOINT=wss://solana-mainnet.rpc.extrnode.com/your-api-key + # Jito Config # Required if useJito: true is set in config.yaml JITO_BLOCK_ENGINE_URL=frankfurt.mainnet.block-engine.jito.wtf diff --git a/grafana/dashboards/drift-keeper.json b/grafana/dashboards/drift-keeper.json index b4a6b1f..5dc4e4d 100644 --- a/grafana/dashboards/drift-keeper.json +++ b/grafana/dashboards/drift-keeper.json @@ -149,7 +149,7 @@ "orientation": "auto", "reduceOptions": { "calcs": [ - "lastNotNull" + "diff" ], "fields": "", "values": false @@ -166,7 +166,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "delta(total_collateral[24h])", + "expr": "total_collateral", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -176,7 +176,7 @@ "useBackend": false } ], - "title": "Profit 24h", + "title": "PNL", "type": "stat" }, { @@ -299,7 +299,7 @@ "mode": "scheme", "reverse": false, "scale": "exponential", - "scheme": "Turbo", + "scheme": "Viridis", "steps": 64 }, "exemplars": { @@ -436,7 +436,7 @@ "calcs": [], "displayMode": "list", "placement": "bottom", - "showLegend": true + "showLegend": false }, "tooltip": { "mode": "single", @@ -538,7 +538,7 @@ "calcs": [], "displayMode": "list", "placement": "bottom", - "showLegend": true + "showLegend": false }, "tooltip": { "mode": "single", @@ -957,6 +957,6 @@ "timezone": "", "title": "Drift Keeper", "uid": "f4c3a630-ffd0-41c8-a36a-52e0771b77fb", - "version": 7, + "version": 6, "weekStart": "" } \ No newline at end of file diff --git a/grafana/provisioning/datasources/datasource.yml b/grafana/provisioning/datasources/datasource.yml index d7b8286..9230003 100644 --- a/grafana/provisioning/datasources/datasource.yml +++ b/grafana/provisioning/datasources/datasource.yml @@ -7,3 +7,7 @@ datasources: isDefault: true access: proxy editable: true + basicAuth: true + basicAuthUser: prom + secureJsonData: + basicAuthPassword: prompass \ No newline at end of file diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 51b601b..47b8025 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -10,15 +10,6 @@ alerting: timeout: 10s api_version: v1 scrape_configs: -- job_name: prometheus - honor_timestamps: true - scrape_interval: 15s - scrape_timeout: 10s - metrics_path: /metrics - scheme: http - static_configs: - - targets: - - localhost:9090 - job_name: keeper honor_timestamps: true scrape_interval: 15s diff --git a/prometheus/web.yml b/prometheus/web.yml new file mode 100644 index 0000000..4d3b9b2 --- /dev/null +++ b/prometheus/web.yml @@ -0,0 +1,2 @@ +basic_auth_users: + prom: $2y$10$oWtHm79bh0D1CnNC4brGiOU7y6MbYa6cgklF/g6ek9YZYkgXfeOIu \ No newline at end of file