Skip to content

Commit 797647f

Browse files
committed
Add statsd-exporter deployment
1 parent e8a9775 commit 797647f

4 files changed

Lines changed: 162 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# StatsD Exporter
2+
3+
We used to use a StatsD/Graphite stack for monitoring, but it was fairly bad and had a whole additional volume required.
4+
5+
We have decided to standardise on Prometheus for best-effort monitoring and use the StatsD Exporter to convert StatsD metrics to Prometheus format. This allows us to continue using our existing StatsD instrumentation without needing to maintain a separate monitoring stack.
6+
7+
## Components
8+
9+
- `deployment.yaml` - Contains the pod deployment for the StatsD exporter.
10+
- `service.yaml` - Contains the service definition for the StatsD exporter, this exposes both the statsd endpoint (TCP/UDP 8125) and the Prometheus metrics endpoint (HTTP 9102).
11+
- `configmap.yaml` - Contains the mapping for StatsD metrics to Prometheus metrics. This is where you can define how your StatsD metrics should be translated into Prometheus metrics (notably, how metric name components should be translated to labels)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: statsd-exporter-config
5+
namespace: monitoring
6+
data:
7+
mapping.yaml: |-
8+
mappings:
9+
- match: "bot.channels.*"
10+
name: "bot_channel_messages"
11+
help: "Number of messages by Discord channel name"
12+
labels:
13+
channel: "$1"
14+
- match: "bot.commands.*"
15+
name: "bot_command_calls"
16+
help: "Number of calls to each bot command"
17+
labels:
18+
command: "$1"
19+
- match: "bot.tags.usages.*"
20+
name: "bot_tag_usages"
21+
help: "Number of times each tag is used"
22+
labels:
23+
tag: "$1"
24+
- match: "bot.errors.*"
25+
name: "bot_errors"
26+
help: "Number of errors by type"
27+
labels:
28+
error_type: "$1"
29+
- match: "bot.dormant_invoke.*"
30+
name: "bot_dormant_invoke"
31+
help: "Number of dormant command invocations by claimant/staff"
32+
labels:
33+
invoker: "$1"
34+
- match: "bot.slowmode.*"
35+
name: "bot_slowmode"
36+
help: "Number of slowmode activations by channel"
37+
labels:
38+
channel: "$1"
39+
- match: "bot.filters.*"
40+
name: "bot_filter_activations"
41+
help: "Number of filter activations by filter name"
42+
labels:
43+
filter: "$1"
44+
- match: "bot.voice_gate.failed.*"
45+
name: "bot_voice_gate_reason"
46+
help: "Number of failed voice gate attempts by reason"
47+
labels:
48+
reason: "$1"
49+
- match: "bot.snekbox.python.*"
50+
name: "bot_snekbox_python_executions"
51+
help: "Number of Python code executions in Snekbox by result type"
52+
labels:
53+
result: "$1"
54+
- match: "bot.snekbox_usages.roles.*"
55+
name: "bot_snekbox_role_usages"
56+
help: "Number of Snekbox role usages by role"
57+
labels:
58+
role: "$1"
59+
- match: "bot.snekbox_usages.channels.*"
60+
name: "bot_snekbox_channel_usages"
61+
help: "Number of Snekbox channel usages by channel"
62+
labels:
63+
channel: "$1"
64+
- match: "bot.python_news.posted.*"
65+
name: "bot_python_news_posted"
66+
help: "Number of Python news posts by source"
67+
labels:
68+
source: "$1"
69+
- match: "bot.rule_uses.*"
70+
name: "bot_rule_uses"
71+
help: "Number of rule uses by rule number"
72+
labels:
73+
rule: "$1"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: statsd-exporter
5+
namespace: monitoring
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: statsd-exporter
11+
template:
12+
metadata:
13+
labels:
14+
app: statsd-exporter
15+
spec:
16+
containers:
17+
- name: statsd-exporter
18+
image: docker.io/prom/statsd-exporter:latest
19+
imagePullPolicy: Always
20+
args:
21+
- "--statsd.listen-udp=:8125"
22+
- "--statsd.listen-tcp=:8125"
23+
- "--statsd.mapping-config=/etc/statsd_exporter/mapping.yaml"
24+
resources:
25+
requests:
26+
cpu: 250m
27+
memory: 300Mi
28+
limits:
29+
cpu: 250m
30+
memory: 400Mi
31+
ports:
32+
- containerPort: 9102
33+
protocol: TCP
34+
name: prom-scrape
35+
- containerPort: 8125
36+
protocol: UDP
37+
name: statsd-udp
38+
- containerPort: 8125
39+
protocol: TCP
40+
name: statsd-tcp
41+
volumeMounts:
42+
- name: statsd-exporter-config
43+
mountPath: /etc/statsd_exporter
44+
readOnly: true
45+
securityContext:
46+
readOnlyRootFilesystem: true
47+
securityContext:
48+
fsGroup: 2000
49+
runAsUser: 1000
50+
runAsNonRoot: true
51+
volumes:
52+
- name: statsd-exporter-config
53+
configMap:
54+
name: statsd-exporter-config
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: statsd-exporter
5+
namespace: monitoring
6+
annotations:
7+
prometheus.io/scrape: "true"
8+
prometheus.io/port: "9102"
9+
spec:
10+
selector:
11+
app: statsd-exporter
12+
ports:
13+
- name: prom-scrape
14+
protocol: TCP
15+
port: 9102
16+
targetPort: prom-scrape
17+
- name: statsd-udp
18+
protocol: UDP
19+
port: 8125
20+
targetPort: statsd-udp
21+
- name: statsd-tcp
22+
protocol: TCP
23+
port: 8125
24+
targetPort: statsd-tcp

0 commit comments

Comments
 (0)