Skip to content

Commit

Permalink
feat: add redis metrics support
Browse files Browse the repository at this point in the history
  • Loading branch information
pcfreak30 committed Dec 29, 2024
1 parent 1832dd4 commit ab46c54
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ ARG VALKEY_VERSION=8-alpine
ARG METRICS_EXPORTER_VERSION=develop

FROM ghcr.io/lumeweb/akash-metrics-exporter:${METRICS_EXPORTER_VERSION} AS metrics-exporter

FROM golang:1.21-alpine AS redis-exporter
RUN CGO_ENABLED=0 go install github.com/oliver006/redis_exporter@latest

FROM golang:1.21-alpine AS metrics-registrar
RUN CGO_ENABLED=0 go install go.lumeweb.com/akash-metrics-registrar@latest

# Extend from valgrind
FROM valkey/valkey:${VALKEY_VERSION}

Expand All @@ -26,21 +33,15 @@ RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc \
RUN wget https://github.com/aptible/supercronic/releases/download/v${SUPERCRONIC_VERSION}/supercronic-linux-amd64 -O /usr/local/bin/supercronic \
&& chmod +x /usr/local/bin/supercronic

# Environment variables for S3 backup configuration
ENV ENABLE_BACKUP=false
ENV S3_ENDPOINT=""
ENV S3_ACCESS_KEY=""
ENV S3_SECRET_KEY=""
ENV S3_BUCKET=""
ENV BACKUP_RETENTION_DAYS=7
ENV BACKUP_PREFIX="valkey-backup"
ENV BACKUP_SCHEDULE="0 0 * * *"
# Copy binaries from build stages
COPY --from=metrics-exporter /usr/bin/akash-metrics-exporter /usr/local/bin/
COPY --from=redis-exporter /go/bin/redis_exporter /usr/local/bin/
COPY --from=metrics-registrar /go/bin/akash-metrics-registrar /usr/local/bin/

# Copy our scripts
COPY backup.sh /usr/local/bin/
COPY entrypoint.sh /entrypoint.sh
COPY --from=metrics-exporter /usr/bin/metrics-exporter /usr/bin/akash-metrics-exporter

ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 6379
CMD ["valkey-server"]

CMD ["valkey-server"]
16 changes: 15 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,21 @@ if [ "$BACKUP_ENABLED" = "true" ]; then
supercronic /etc/crontab &
fi

akash-metrics-exporter &
# Start metrics components if METRICS_PASSWORD is set
if [ -n "$METRICS_PASSWORD" ]; then
# Start redis_exporter with authentication
redis_exporter --redis.addr="redis://127.0.0.1:${VALKEY_PORT}" \
--redis.password="$METRICS_PASSWORD" \
--web.listen-address=":9121" &

# Start metrics-registrar
akash-metrics-registrar --listen=":8081" \
--metrics-password="$METRICS_PASSWORD" \
--metrics-port="9121" &

# Start metrics-exporter
akash-metrics-exporter &
fi

# Delegate to the original entrypoint script with our generated config
exec /usr/local/bin/docker-entrypoint.sh valkey-server "$CONFIG_FILE"

0 comments on commit ab46c54

Please sign in to comment.