Packaged for Cloudron

This commit is contained in:
Rafael Caricio 2022-12-24 21:49:43 +01:00
parent b8ace4ae2c
commit 92a1912abd
Signed by: rafaelcaricio
GPG key ID: 3C86DBCE8E93C947
4 changed files with 159 additions and 11 deletions

39
CloudronManifest.json Normal file
View file

@ -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"
}

View file

@ -1,13 +1,13 @@
ARG ARCH="amd64"
ARG OS="linux"
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest
LABEL maintainer="The Prometheus Authors <prometheus-developers@googlegroups.com>"
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" ]

13
start.sh Normal file
View file

@ -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

96
statsd-mapping.yaml Normal file
View file

@ -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"