mirror of
https://github.com/mastodon/chart
synced 2025-03-14 21:11:50 +00:00
Add sidecar capability for statsd
This commit is contained in:
parent
94aa576b1e
commit
bc19788acc
54
templates/_statsd.yaml
Normal file
54
templates/_statsd.yaml
Normal file
|
@ -0,0 +1,54 @@
|
|||
{{/*
|
||||
The exporter container attached to every Mastodon pod
|
||||
*/}}
|
||||
|
||||
{{- define "mastodon.statsdExporterContainer" }}
|
||||
{{- with .Values.mastodon.metrics.statsd }}
|
||||
{{- if and .exporter.enabled (not .address) }}
|
||||
- name: statsd-exporter
|
||||
image: prom/statsd-exporter
|
||||
args:
|
||||
- "--statsd.mapping-config=/statsd-mappings/mastodon.yml"
|
||||
resources:
|
||||
requests:
|
||||
cpu: "0.1"
|
||||
memory: "180M"
|
||||
limits:
|
||||
cpu: "0.5"
|
||||
memory: "250M"
|
||||
ports:
|
||||
- name: statsd
|
||||
containerPort: {{ .exporter.port }}
|
||||
volumeMounts:
|
||||
- name: statsd-mappings
|
||||
mountPath: /statsd-mappings
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
The volume needed for the container above
|
||||
*/}}
|
||||
{{- define "mastodon.statsdExporterVolume" }}
|
||||
{{- with .Values.mastodon.metrics.statsd }}
|
||||
{{- if and .exporter.enabled (not .address) }}
|
||||
- name: statsd-mappings
|
||||
configMap:
|
||||
name: {{ include "mastodon.fullname" $ }}-statsd-mappings
|
||||
items:
|
||||
- key: mastodon-statsd-mappings.yml
|
||||
path: mastodon.yml
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Labels added to every statsd_exporter-enabled pod
|
||||
*/}}
|
||||
{{- define "mastodon.statsdExporterLabels" }}
|
||||
{{- with .Values.mastodon.metrics.statsd }}
|
||||
{{- if and .exporter.enabled (not .address) }}
|
||||
mastodon/statsd-exporter: "true"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -325,8 +325,10 @@ data:
|
|||
LDAP_UID_CONVERSION_REPLACE: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.mastodon.metrics.statsd.address }}
|
||||
STATSD_ADDR: {{ . }}
|
||||
{{- if .Values.mastodon.metrics.statsd.address }}
|
||||
STATSD_ADDR: {{ .Values.mastodon.metrics.statsd.address }}
|
||||
{{- else if .Values.mastodon.metrics.statsd.exporter.enabled }}
|
||||
STATSD_ADDR: localhost:9125
|
||||
{{- end }}
|
||||
{{- range $k, $v := .Values.mastodon.extraEnvVars }}
|
||||
{{ $k }}: {{ quote $v }}
|
||||
|
|
|
@ -38,6 +38,7 @@ spec:
|
|||
checksum/config-secrets: {{ include ( print $.Template.BasePath "/secret-smtp.yaml" ) $context | sha256sum | quote }}
|
||||
labels:
|
||||
{{- include "mastodon.selectorLabels" $context | nindent 8 }}
|
||||
{{- include "mastodon.statsdExporterLabels" $context | nindent 8 }}
|
||||
app.kubernetes.io/component: sidekiq-{{ .name }}
|
||||
app.kubernetes.io/part-of: rails
|
||||
spec:
|
||||
|
@ -63,6 +64,7 @@ spec:
|
|||
persistentVolumeClaim:
|
||||
claimName: {{ template "mastodon.fullname" $context }}-system
|
||||
{{- end }}
|
||||
{{- include "mastodon.statsdExporterVolume" $ | indent 8 }}
|
||||
containers:
|
||||
- name: {{ $context.Chart.Name }}
|
||||
securityContext:
|
||||
|
@ -127,6 +129,7 @@ spec:
|
|||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml (default (default $context.Values.resources $context.Values.mastodon.sidekiq.resources) .resources) | nindent 12 }}
|
||||
{{- include "mastodon.statsdExporterContainer" $ | indent 8 }}
|
||||
{{- with $context.Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
|
|
|
@ -25,6 +25,7 @@ spec:
|
|||
{{- include "mastodon.rollingPodAnnotations" . | nindent 8 }}
|
||||
labels:
|
||||
{{- include "mastodon.selectorLabels" . | nindent 8 }}
|
||||
{{- include "mastodon.statsdExporterLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: web
|
||||
app.kubernetes.io/part-of: rails
|
||||
spec:
|
||||
|
@ -45,6 +46,7 @@ spec:
|
|||
- name: system
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ template "mastodon.fullname" . }}-system
|
||||
{{- include "mastodon.statsdExporterVolume" $ | indent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}-web
|
||||
|
@ -134,6 +136,7 @@ spec:
|
|||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- include "mastodon.statsdExporterContainer" $ | indent 8 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
|
|
107
templates/statsd-exporter-mappings.yaml
Normal file
107
templates/statsd-exporter-mappings.yaml
Normal file
|
@ -0,0 +1,107 @@
|
|||
{{- if and .Values.mastodon.metrics.statsd.exporter.enabled (not .Values.mastodon.metrics.statsd.address) }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "mastodon.fullname" . }}-statsd-mappings
|
||||
labels:
|
||||
{{- include "mastodon.labels" . | nindent 4 }}
|
||||
data:
|
||||
mastodon-statsd-mappings.yml: |-
|
||||
## From https://ipng.ch/assets/mastodon/statsd-mapping.yaml
|
||||
## 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"
|
||||
|
||||
{{- end }}
|
|
@ -207,6 +207,11 @@ mastodon:
|
|||
statsd:
|
||||
# -- Enable statsd publishing via STATSD_ADDR environment variable
|
||||
address: ""
|
||||
# -- Alternatively, you can use this to have a statsd_exporter sidecar container running along all Mastodon containers and exposing metrics in OpenMetric/Prometheus format on each pod
|
||||
# Please note the exporter will not be enabled if metrics.statsd.address is not empty
|
||||
exporter:
|
||||
enabled: false
|
||||
port: 9102
|
||||
|
||||
# Sets the PREPARED_STATEMENTS environment variable: https://docs.joinmastodon.org/admin/config/#prepared_statements
|
||||
preparedStatements: true
|
||||
|
|
Loading…
Reference in New Issue
Block a user