fix(jellyfin): add monitoring

This commit is contained in:
WrenIX 2024-06-29 12:42:46 +02:00
parent 2efaee8c2c
commit d03a21ee11
Signed by: wrenix
GPG key ID: 7AFDB012974B1BB5
9 changed files with 723 additions and 3 deletions

View file

@ -3,7 +3,7 @@ name: jellyfin
description: The Free Software Media System
icon: https://raw.githubusercontent.com/jellyfin/jellyfin-ux/master/branding/SVG/icon-transparent.svg
type: application
version: 0.1.8
version: 0.2.0
# renovate: image=ghcr.io/jellyfin/jellyfin
appVersion: "10.9.7"
maintainers:

View file

@ -2,7 +2,7 @@
= jellyfin
image::https://img.shields.io/badge/Version-0.1.8-informational?style=flat-square[Version: 0.1.8]
image::https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square[Version: 0.2.0]
image::https://img.shields.io/badge/Version-application-informational?style=flat-square[Type: application]
image::https://img.shields.io/badge/AppVersion-10.9.7-informational?style=flat-square[AppVersion: 10.9.7]
== Maintainers
@ -72,6 +72,21 @@ helm uninstall jellyfin-release
| `80`
|
| config.enabled
| bool
| `false`
|
| config.image
| object
| `{"pullPolicy":"IfNotPresent","registry":"ghcr.io","repository":"tomwright/dasel","tag":"2.8.0"}`
| image to patch config
| config.metrics
| bool
| `false`
|
| fullnameOverride
| string
| `""`
@ -87,6 +102,21 @@ helm uninstall jellyfin-release
| `nil`
| if set it will overwrite all registry entries
| grafana.dashboards.annotations
| object
| `{}`
|
| grafana.dashboards.enabled
| bool
| `false`
|
| grafana.dashboards.labels.grafana_dashboard
| string
| `"1"`
|
| image.pullPolicy
| string
| `"IfNotPresent"`
@ -217,6 +247,16 @@ helm uninstall jellyfin-release
| `{}`
|
| prometheus.servicemonitor.enabled
| bool
| `false`
|
| prometheus.servicemonitor.labels
| object
| `{}`
|
| replicaCount
| int
| `1`

View file

@ -0,0 +1,2 @@
#!/bin/sh
dasel -f /config/config/system.xml put ServerConfiguration.EnableMetrics -t bool -v {{ .Values.config.metrics | quote}}

View file

@ -0,0 +1,585 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"id": 4,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"maxHeight": 600,
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"exemplar": true,
"expr": "sum(dotnet_total_memory_bytes{container=\"jellyfin\"}) without (endpoint,instance,pod)",
"interval": "",
"legendFormat": "Dotnet total memory",
"range": true,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"exemplar": true,
"expr": "sum(process_private_memory_bytes{container=\"jellyfin\"}) without (endpoint,instance,pod)",
"hide": false,
"interval": "",
"legendFormat": "Process private memory",
"range": true,
"refId": "B"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"exemplar": true,
"expr": "sum(process_working_set_bytes{container=\"jellyfin\"}) without (endpoint,instance,pod)",
"hide": false,
"interval": "",
"legendFormat": "Process working set",
"range": true,
"refId": "C"
}
],
"title": "Memory usage",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"maxHeight": 600,
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"exemplar": true,
"expr": "sum(rate(dotnet_exceptions_total{container=\"jellyfin\"}[$__rate_interval])) without (endpoint,instance,pod)",
"interval": "",
"legendFormat": "{{type}}",
"range": true,
"refId": "A"
}
],
"title": "Exceptions",
"type": "timeseries"
},
{
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 9
},
"id": 11,
"title": "HTTP Requests",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 0,
"y": 10
},
"id": 8,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"maxHeight": 600,
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"exemplar": true,
"expr": "sum(irate(http_requests_received_total{container=\"jellyfin\"}[$__rate_interval])) without (endpoint,instance,pod)",
"interval": "",
"legendFormat": "{{method}} {{controller}} {{action}} {{code}}",
"range": true,
"refId": "A"
}
],
"title": "Requests per Seconds",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"scaleDistribution": {
"type": "linear"
}
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 7,
"x": 8,
"y": 10
},
"id": 9,
"options": {
"calculate": false,
"cellGap": 1,
"color": {
"exponent": 0.5,
"fill": "dark-orange",
"mode": "scheme",
"reverse": false,
"scale": "exponential",
"scheme": "Oranges",
"steps": 64
},
"exemplars": {
"color": "rgba(255,0,255,0.7)"
},
"filterValues": {
"le": 1e-9
},
"legend": {
"show": true
},
"rowsFrame": {
"layout": "auto"
},
"tooltip": {
"maxHeight": 600,
"mode": "single",
"showColorScale": false,
"yHistogram": false
},
"yAxis": {
"axisPlacement": "left",
"reverse": false
}
},
"pluginVersion": "11.0.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"exemplar": true,
"expr": "sum(increase(http_request_duration_seconds_bucket{container=\"jellyfin\"}[$__rate_interval])) by(le)",
"format": "heatmap",
"interval": "",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Latency",
"type": "heatmap"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"log": 10,
"type": "log"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 9,
"x": 15,
"y": 10
},
"id": 10,
"options": {
"legend": {
"calcs": [
"mean",
"lastNotNull"
],
"displayMode": "table",
"placement": "right",
"showLegend": true,
"sortBy": "Name",
"sortDesc": false
},
"tooltip": {
"maxHeight": 600,
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"exemplar": true,
"expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{container=\"jellyfin\"}[$__rate_interval])) without(container,endpoint, instance, pod, code, exported_endpoint, method,action))",
"interval": "",
"legendFormat": "{{controller}}.",
"range": true,
"refId": "A"
}
],
"title": "Latency",
"type": "timeseries"
}
],
"refresh": "30s",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "Prometheus",
"value": "prometheus"
},
"hide": 0,
"includeAll": false,
"label": "datasource",
"multi": false,
"name": "DS_PROMETHEUS",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timeRangeUpdatedDuringEditOrView": false,
"timepicker": {},
"timezone": "",
"title": "Jellyfin",
"uid": "zkWB8mtnk",
"version": 1,
"weekStart": ""
}

View file

@ -0,0 +1,11 @@
{{- if .Values.config.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "jellyfin.fullname" . }}-config
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
data:
patch.sh: |-
{{ tpl (.Files.Get "files/config-patch.sh.gotmpl") . | nindent 4 }}
{{- end }}

View file

@ -0,0 +1,14 @@
{{- if .Values.grafana.dashboards.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "jellyfin.fullname" $ }}-grafana-dashboards
labels:
{{- include "jellyfin.labels" $ | nindent 4 }}
{{- toYaml $.Values.grafana.dashboards.labels | nindent 4 }}
annotations:
{{- toYaml $.Values.grafana.dashboards.annotations | nindent 4 }}
data:
{{- (.Files.Glob "grafana_dashboards/*.json" ).AsConfig | nindent 2 }}
{{- end }}

View file

@ -32,11 +32,29 @@ spec:
serviceAccountName: {{ include "jellyfin.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.config.enabled }}
initContainers:
- name: patch-config
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.config.image }}
image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}:{{ .tag }}"
imagePullPolicy: {{ coalesce $.Values.global.image.pullPolicy .pullPolicy }}
{{- end }}
command:
- "/bin/sh"
- "/scripts/init.sh"
volumeMounts:
- mountPath: /config
name: config
- mountPath: /scripts
name: configmap
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.image}}
{{- with .Values.image }}
image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}:{{ .tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ coalesce $.Values.global.image.pullPolicy .pullPolicy }}
{{- end }}
@ -92,6 +110,15 @@ spec:
{{- end }}
- name: cache
emptyDir: {}
{{- if .Values.config.enabled }}
- name: configmap
configMap:
name: {{ include "jellyfin.fullname" . }}-config
defaultMode: 0755
items:
- key: "patch.sh"
path: "init.sh"
{{- end }}
- name: media
{{- with .Values.persistence.media }}
{{- if .nfs.server }}

View file

@ -0,0 +1,19 @@
{{- if and .Values.config.metrics .Values.prometheus.servicemonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "jellyfin.fullname" . }}
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
{{- with .Values.prometheus.servicemonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "jellyfin.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
path: "/metrics"
{{- end }}

View file

@ -18,6 +18,16 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
config:
enabled: false
# -- image to patch config
image:
registry: ghcr.io
repository: tomwright/dasel
pullPolicy: IfNotPresent
tag: "2.8.0"
metrics: false
persistence:
config:
nfs:
@ -62,6 +72,18 @@ service:
type: ClusterIP
port: 8096
prometheus:
servicemonitor:
enabled: false
labels: {}
grafana:
dashboards:
enabled: false
labels:
grafana_dashboard: "1"
annotations: {}
ingress:
enabled: false
className: ""