Skip to content

Commit

Permalink
Prometheus Exporter (#33)
Browse files Browse the repository at this point in the history
* Dedicated exporter image
* Pin exporter to git hash
* Add exporter to compose
  • Loading branch information
rblaine95 authored Jan 17, 2025
1 parent 962b19c commit 45db97b
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 14 deletions.
122 changes: 108 additions & 14 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ name: Docker
on: [workflow_dispatch, push]

env:
IMAGE_NAME: monero
MONERO_IMAGE_NAME: monero
EXPORTER_IMAGE_NAME: monero-exporter
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7

jobs:
build:
name: Build
check-changes:
name: Check Changes (Exporter)
runs-on: ubuntu-latest
outputs:
exporter_changed: ${{ steps.changes.outputs.exporter }}
steps:
- uses: actions/checkout@v4
- id: changes
uses: dorny/paths-filter@v3
with:
filters: |
exporter:
- 'Dockerfile.prom-exporter'
build-monero:
name: Build Monero
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
Expand All @@ -18,11 +33,42 @@ jobs:
runs-on: ubuntu-latest
platform: linux/amd64
- arch: arm64
# https://github.blog/changelog/2025-01-16-linux-arm64-hosted-runners-now-available-for-free-in-public-repositories-public-preview/
runs-on: ubuntu-24.04-arm
platform: linux/arm64
- arch: armv7
runs-on: ubuntu-24.04-arm
platform: linux/arm/v7
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
push: false
cache-from: |
type=gha,scope=monero-build-${{ matrix.arch }}
cache-to: |
type=gha,mode=max,scope=monero-build-${{ matrix.arch }}
context: .

build-exporter:
name: Build Exporter
needs: [check-changes]
if: needs.check-changes.outputs.exporter_changed == 'true'
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
arch: [amd64, arm64, armv7]
include:
- arch: amd64
runs-on: ubuntu-latest
platform: linux/amd64
- arch: arm64
runs-on: ubuntu-24.04-arm
platform: linux/arm64
- arch: armv7
runs-on: ubuntu-24.04-arm
platform: linux/arm/v7
steps:
- uses: actions/checkout@v4
Expand All @@ -32,14 +78,16 @@ jobs:
with:
platforms: ${{ matrix.platform }}
push: false
file: Dockerfile.prom-exporter
cache-from: |
type=gha,scope=docker-build-${{ matrix.arch }}
type=gha,scope=exporter-build-${{ matrix.arch }}
cache-to: |
type=gha,mode=max,scope=docker-build-${{ matrix.arch }}
type=gha,mode=max,scope=exporter-build-${{ matrix.arch }}
context: .
combine:
name: Combine
needs: [build]

combine-monero:
name: Combine Monero
needs: [build-monero]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -74,9 +122,55 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=docker-package
type=gha,scope=docker-build-amd64
type=gha,scope=docker-build-arm64
type=gha,scope=docker-build-armv7
type=gha,scope=monero-package
type=gha,scope=monero-build-amd64
type=gha,scope=monero-build-arm64
type=gha,scope=monero-build-armv7
cache-to: |
type=gha,mode=max,scope=monero-package
combine-exporter:
name: Combine Exporter
needs: [check-changes, build-exporter]
if: needs.check-changes.outputs.exporter_changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/${{ github.repository_owner }}/monero-exporter
docker.io/rblaine/monero-exporter
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
type=raw,value={{branch}},enable=${{ github.ref != format('refs/heads/{0}', 'master') }}
type=ref,event=tag
- uses: docker/build-push-action@v6
with:
platforms: ${{ env.PLATFORMS }}
push: true
file: Dockerfile.prom-exporter
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=exporter-package
type=gha,scope=exporter-build-amd64
type=gha,scope=exporter-build-arm64
type=gha,scope=exporter-build-armv7
cache-to: |
type=gha,mode=max,scope=docker-package
type=gha,mode=max,scope=exporter-package
18 changes: 18 additions & 0 deletions Dockerfile.prom-exporter
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
##################
# -- exporter -- #
##################
FROM docker.io/golang:1.23-alpine AS exporter

RUN GO111MODULE=on go install github.com/cirocosta/monero-exporter/cmd/monero-exporter@cf21000

##################
# -- runner -- #
##################
FROM docker.io/alpine:3 AS runner

COPY --from=exporter /go/bin/monero-exporter /usr/local/bin/monero-exporter

EXPOSE 9000

ENTRYPOINT ["/usr/local/bin/monero-exporter"]
CMD ["--bind-addr", ":9000", "--monero-addr", "http://127.0.0.1:18081", "--telemetry-path", "/metrics"]
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ services:
- --add-peer=plowsoffjexmxalw73tkjmf422gq6575fc7vicuu4javzn2ynnte6tyd.onion:18083
- --add-peer=qz43zul2x56jexzoqgkx2trzwcfnr6l3hbtfcfx54g4r3eahy3bssjyd.onion:18083

monero-exporter:
container_name: monero-exporter
image: ghcr.io/rblaine95/monero-exporter
restart: unless-stopped
network_mode: host
depends_on:
monerod:
condition: service_healthy
command:
- --bind-addr
- :9000
- --monero-addr
- http://127.0.0.1:18081
- --telemetry-path
- /metrics

prep-tor-data:
container_name: prep-volume
image: alpine
Expand Down

0 comments on commit 45db97b

Please sign in to comment.