diff --git a/CloudronManifest.json b/CloudronManifest.json new file mode 100644 index 0000000..4b1dee0 --- /dev/null +++ b/CloudronManifest.json @@ -0,0 +1,39 @@ +{ + "id": "io.caric.git.mirrors.statsd_exporter", + "title": "statsd_exporter", + "author": "Rafael Caricio", + "description": "file://README.md", + "changelog": "file://CHANGELOG.md", + "tagline": "StatsD to Prometheus metrics exporter", + "version": "1.0.0", + "memoryLimit": 589719142400, + "healthCheckPath": "/metrics", + "httpPort": 9102, + "udpPorts": { + "STATSD_PORT": { + "title": "StatsD receiver port", + "description": "Port over which the server listens for StatsD metrics", + "defaultValue": 9125, + "containerPort": 9125 + } + }, + "tcpPorts": { + "STATSD_TCP_PORT": { + "title": "StatsD receiver port over TCP", + "description": "Port over which the server listens for StatsD metrics", + "defaultValue": 9125, + "containerPort": 9125 + } + }, + "addons": { + "localstorage": {} + }, + "manifestVersion": 2, + "website": "https://docs.searxng.org", + "contactEmail": "support@caric.io", + "tags": [ + "metrics", "observability", "prometheus" + ], + "minBoxVersion": "5.3.0", + "documentationUrl": "https://git.caric.io/mirrors/statsd_exporter" +} diff --git a/Dockerfile b/Dockerfile index b6ec721..d302fac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ -ARG ARCH="amd64" -ARG OS="linux" -FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest -LABEL maintainer="The Prometheus Authors " +FROM prom/statsd-exporter:v0.23.0 -ARG ARCH="amd64" -ARG OS="linux" -COPY .build/${OS}-${ARCH}/statsd_exporter /bin/statsd_exporter - -USER 65534 EXPOSE 9102 9125 9125/udp -HEALTHCHECK CMD wget --spider -S "http://localhost:9102/metrics" -T 60 2>&1 || exit 1 -ENTRYPOINT [ "/bin/statsd_exporter" ] + +USER root +COPY start.sh /bin/start.sh +COPY statsd-mapping.yaml /bin/statsd-mapping.yaml +RUN mkdir /app +RUN mkdir /app/data +RUN chmod 777 /app/data +RUN chmod +x /bin/start.sh + +ENTRYPOINT [ "/bin/start.sh" ] diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..b31e256 --- /dev/null +++ b/start.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -eu + +echo "==> Starting statd_exporter" + +# if file not exist, create +if [[ ! -f /app/data/statsd-mapping.yaml ]]; then + echo "==> Copying mappings on first run" + cp /bin/statsd-mapping.yaml /app/data/statsd-mapping.yaml +fi + +exec /bin/statsd_exporter --statsd.mapping-config=/app/data/statsd-mapping.yaml \ No newline at end of file diff --git a/statsd-mapping.yaml b/statsd-mapping.yaml new file mode 100644 index 0000000..2f79cab --- /dev/null +++ b/statsd-mapping.yaml @@ -0,0 +1,96 @@ +## Prometheus Statsd Exporter mapping for Mastodon 4.0+ +## +## Version 1.0, November 2022 +## +## Documentation: https://ipng.ch/s/articles/2022/11/27/mastodon-3.html + +mappings: + ## Web collector + - match: Mastodon\.production\.web\.(.+)\.(.+)\.(.+)\.status\.(.+) + match_type: regex + name: "mastodon_controller_status" + labels: + controller: $1 + action: $2 + format: $3 + status: $4 + mastodon: "web" + - match: Mastodon\.production\.web\.(.+)\.(.+)\.(.+)\.db_time + match_type: regex + name: "mastodon_controller_db_time" + labels: + controller: $1 + action: $2 + format: $3 + mastodon: "web" + - match: Mastodon\.production\.web\.(.+)\.(.+)\.(.+)\.view_time + match_type: regex + name: "mastodon_controller_view_time" + labels: + controller: $1 + action: $2 + format: $3 + mastodon: "web" + - match: Mastodon\.production\.web\.(.+)\.(.+)\.(.+)\.total_duration + match_type: regex + name: "mastodon_controller_duration" + labels: + controller: $1 + action: $2 + format: $3 + mastodon: "web" + + ## Database collector + - match: Mastodon\.production\.db\.tables\.(.+)\.queries\.(.+)\.duration + match_type: regex + name: "mastodon_db_operation" + labels: + table: "$1" + operation: "$2" + mastodon: "db" + + ## Cache collector + - match: Mastodon\.production\.cache\.(.+)\.duration + match_type: regex + name: "mastodon_cache_duration" + labels: + operation: "$1" + mastodon: "cache" + + ## Sidekiq collector + - match: Mastodon\.production\.sidekiq\.(.+)\.processing_time + match_type: regex + name: "mastodon_sidekiq_worker_processing_time" + labels: + worker: "$1" + mastodon: "sidekiq" + - match: Mastodon\.production\.sidekiq\.(.+)\.success + match_type: regex + name: "mastodon_sidekiq_worker_success_total" + labels: + worker: "$1" + mastodon: "sidekiq" + - match: Mastodon\.production\.sidekiq\.(.+)\.failure + match_type: regex + name: "mastodon_sidekiq_worker_failure_total" + labels: + worker: "$1" + mastodon: "sidekiq" + - match: Mastodon\.production\.sidekiq\.queues\.(.+)\.enqueued + match_type: regex + name: "mastodon_sidekiq_queue_enqueued" + labels: + queue: "$1" + mastodon: "sidekiq" + - match: Mastodon\.production\.sidekiq\.queues\.(.+)\.latency + match_type: regex + name: "mastodon_sidekiq_queue_latency" + labels: + queue: "$1" + mastodon: "sidekiq" + - match: Mastodon\.production\.sidekiq\.(.+) + match_type: regex + name: "mastodon_sidekiq_$1" + labels: + mastodon: "sidekiq" +