Skip to content

Commit 45db97b

Browse files
authored
Prometheus Exporter (#33)
* Dedicated exporter image * Pin exporter to git hash * Add exporter to compose
1 parent 962b19c commit 45db97b

File tree

3 files changed

+142
-14
lines changed

3 files changed

+142
-14
lines changed

.github/workflows/docker.yml

Lines changed: 108 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,27 @@ name: Docker
33
on: [workflow_dispatch, push]
44

55
env:
6-
IMAGE_NAME: monero
6+
MONERO_IMAGE_NAME: monero
7+
EXPORTER_IMAGE_NAME: monero-exporter
78
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7
89

910
jobs:
10-
build:
11-
name: Build
11+
check-changes:
12+
name: Check Changes (Exporter)
13+
runs-on: ubuntu-latest
14+
outputs:
15+
exporter_changed: ${{ steps.changes.outputs.exporter }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- id: changes
19+
uses: dorny/paths-filter@v3
20+
with:
21+
filters: |
22+
exporter:
23+
- 'Dockerfile.prom-exporter'
24+
25+
build-monero:
26+
name: Build Monero
1227
runs-on: ${{ matrix.runs-on }}
1328
strategy:
1429
matrix:
@@ -18,11 +33,42 @@ jobs:
1833
runs-on: ubuntu-latest
1934
platform: linux/amd64
2035
- arch: arm64
21-
# https://github.blog/changelog/2025-01-16-linux-arm64-hosted-runners-now-available-for-free-in-public-repositories-public-preview/
2236
runs-on: ubuntu-24.04-arm
2337
platform: linux/arm64
2438
- arch: armv7
39+
runs-on: ubuntu-24.04-arm
40+
platform: linux/arm/v7
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: docker/setup-qemu-action@v3
44+
- uses: docker/setup-buildx-action@v3
45+
- uses: docker/build-push-action@v6
46+
with:
47+
platforms: ${{ matrix.platform }}
48+
push: false
49+
cache-from: |
50+
type=gha,scope=monero-build-${{ matrix.arch }}
51+
cache-to: |
52+
type=gha,mode=max,scope=monero-build-${{ matrix.arch }}
53+
context: .
54+
55+
build-exporter:
56+
name: Build Exporter
57+
needs: [check-changes]
58+
if: needs.check-changes.outputs.exporter_changed == 'true'
59+
runs-on: ${{ matrix.runs-on }}
60+
strategy:
61+
matrix:
62+
arch: [amd64, arm64, armv7]
63+
include:
64+
- arch: amd64
2565
runs-on: ubuntu-latest
66+
platform: linux/amd64
67+
- arch: arm64
68+
runs-on: ubuntu-24.04-arm
69+
platform: linux/arm64
70+
- arch: armv7
71+
runs-on: ubuntu-24.04-arm
2672
platform: linux/arm/v7
2773
steps:
2874
- uses: actions/checkout@v4
@@ -32,14 +78,16 @@ jobs:
3278
with:
3379
platforms: ${{ matrix.platform }}
3480
push: false
81+
file: Dockerfile.prom-exporter
3582
cache-from: |
36-
type=gha,scope=docker-build-${{ matrix.arch }}
83+
type=gha,scope=exporter-build-${{ matrix.arch }}
3784
cache-to: |
38-
type=gha,mode=max,scope=docker-build-${{ matrix.arch }}
85+
type=gha,mode=max,scope=exporter-build-${{ matrix.arch }}
3986
context: .
40-
combine:
41-
name: Combine
42-
needs: [build]
87+
88+
combine-monero:
89+
name: Combine Monero
90+
needs: [build-monero]
4391
runs-on: ubuntu-latest
4492
permissions:
4593
contents: read
@@ -74,9 +122,55 @@ jobs:
74122
tags: ${{ steps.meta.outputs.tags }}
75123
labels: ${{ steps.meta.outputs.labels }}
76124
cache-from: |
77-
type=gha,scope=docker-package
78-
type=gha,scope=docker-build-amd64
79-
type=gha,scope=docker-build-arm64
80-
type=gha,scope=docker-build-armv7
125+
type=gha,scope=monero-package
126+
type=gha,scope=monero-build-amd64
127+
type=gha,scope=monero-build-arm64
128+
type=gha,scope=monero-build-armv7
129+
cache-to: |
130+
type=gha,mode=max,scope=monero-package
131+
132+
combine-exporter:
133+
name: Combine Exporter
134+
needs: [check-changes, build-exporter]
135+
if: needs.check-changes.outputs.exporter_changed == 'true'
136+
runs-on: ubuntu-latest
137+
permissions:
138+
contents: read
139+
packages: write
140+
steps:
141+
- uses: actions/checkout@v4
142+
- uses: docker/setup-qemu-action@v3
143+
- uses: docker/setup-buildx-action@v3
144+
- uses: docker/login-action@v3
145+
with:
146+
registry: ghcr.io
147+
username: ${{ github.repository_owner }}
148+
password: ${{ github.token }}
149+
- uses: docker/login-action@v3
150+
with:
151+
username: ${{ secrets.DOCKERHUB_USERNAME }}
152+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
153+
- uses: docker/metadata-action@v5
154+
id: meta
155+
with:
156+
images: |
157+
ghcr.io/${{ github.repository_owner }}/monero-exporter
158+
docker.io/rblaine/monero-exporter
159+
tags: |
160+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
161+
type=raw,value={{branch}},enable=${{ github.ref != format('refs/heads/{0}', 'master') }}
162+
type=ref,event=tag
163+
- uses: docker/build-push-action@v6
164+
with:
165+
platforms: ${{ env.PLATFORMS }}
166+
push: true
167+
file: Dockerfile.prom-exporter
168+
tags: ${{ steps.meta.outputs.tags }}
169+
labels: ${{ steps.meta.outputs.labels }}
170+
cache-from: |
171+
type=gha,scope=exporter-package
172+
type=gha,scope=exporter-build-amd64
173+
type=gha,scope=exporter-build-arm64
174+
type=gha,scope=exporter-build-armv7
81175
cache-to: |
82-
type=gha,mode=max,scope=docker-package
176+
type=gha,mode=max,scope=exporter-package

Dockerfile.prom-exporter

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
##################
2+
# -- exporter -- #
3+
##################
4+
FROM docker.io/golang:1.23-alpine AS exporter
5+
6+
RUN GO111MODULE=on go install github.com/cirocosta/monero-exporter/cmd/monero-exporter@cf21000
7+
8+
##################
9+
# -- runner -- #
10+
##################
11+
FROM docker.io/alpine:3 AS runner
12+
13+
COPY --from=exporter /go/bin/monero-exporter /usr/local/bin/monero-exporter
14+
15+
EXPOSE 9000
16+
17+
ENTRYPOINT ["/usr/local/bin/monero-exporter"]
18+
CMD ["--bind-addr", ":9000", "--monero-addr", "http://127.0.0.1:18081", "--telemetry-path", "/metrics"]

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ services:
8282
- --add-peer=plowsoffjexmxalw73tkjmf422gq6575fc7vicuu4javzn2ynnte6tyd.onion:18083
8383
- --add-peer=qz43zul2x56jexzoqgkx2trzwcfnr6l3hbtfcfx54g4r3eahy3bssjyd.onion:18083
8484

85+
monero-exporter:
86+
container_name: monero-exporter
87+
image: ghcr.io/rblaine95/monero-exporter
88+
restart: unless-stopped
89+
network_mode: host
90+
depends_on:
91+
monerod:
92+
condition: service_healthy
93+
command:
94+
- --bind-addr
95+
- :9000
96+
- --monero-addr
97+
- http://127.0.0.1:18081
98+
- --telemetry-path
99+
- /metrics
100+
85101
prep-tor-data:
86102
container_name: prep-volume
87103
image: alpine

0 commit comments

Comments
 (0)