[lidarr] metrics refactor (#1184)

* [lidarr] metrics refactor

* port protocol

* revert scraping intevals after testing

* update docs
This commit is contained in:
j_r0dd 2021-09-12 17:33:13 -04:00 committed by GitHub
parent 379e69a974
commit 04e9beed84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 141 additions and 65 deletions

View File

@ -2,7 +2,7 @@ apiVersion: v2
appVersion: v1.0.0.2255 appVersion: v1.0.0.2255
description: Looks and smells like Sonarr but made for music description: Looks and smells like Sonarr but made for music
name: lidarr name: lidarr
version: 12.0.1 version: 13.0.0
kubeVersion: ">=1.16.0-0" kubeVersion: ">=1.16.0-0"
keywords: keywords:
- lidarr - lidarr

View File

@ -1,6 +1,6 @@
# lidarr # lidarr
![Version: 12.0.1](https://img.shields.io/badge/Version-12.0.1-informational?style=flat-square) ![AppVersion: v1.0.0.2255](https://img.shields.io/badge/AppVersion-v1.0.0.2255-informational?style=flat-square) ![Version: 13.0.0](https://img.shields.io/badge/Version-13.0.0-informational?style=flat-square) ![AppVersion: v1.0.0.2255](https://img.shields.io/badge/AppVersion-v1.0.0.2255-informational?style=flat-square)
Looks and smells like Sonarr but made for music Looks and smells like Sonarr but made for music
@ -78,20 +78,22 @@ N/A
|-----|------|---------|-------------| |-----|------|---------|-------------|
| env | object | See below | environment variables. | | env | object | See below | environment variables. |
| env.TZ | string | `"UTC"` | Set the container timezone | | env.TZ | string | `"UTC"` | Set the container timezone |
| exporter.enabled | bool | See values.yaml | Enable and configure Exportarr sidecar and Prometheus podMonitor. |
| exporter.env.additionalMetrics | bool | `false` | Set to true to enable gathering of additional metrics (slow) |
| exporter.env.port | int | `32123` | metrics port |
| exporter.env.unknownQueueItems | bool | `false` | Set to true to enable gathering unknown queue items |
| exporter.image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
| exporter.image.repository | string | `"ghcr.io/onedr0p/exportarr"` | image repository |
| exporter.image.tag | string | `"v0.6.1"` | image tag |
| exporter.podMonitor.interval | string | `"3m"` | |
| exporter.podMonitor.labels | object | `{}` | |
| exporter.podMonitor.scrapeTimeout | string | `"1m"` | |
| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | | image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
| image.repository | string | `"ghcr.io/k8s-at-home/lidarr"` | image repository | | image.repository | string | `"ghcr.io/k8s-at-home/lidarr"` | image repository |
| image.tag | string | `"v1.0.0.2255"` | image tag | | image.tag | string | `"v1.0.0.2255"` | image tag |
| ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | | ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. |
| metrics.enabled | bool | See values.yaml | Enable and configure Exportarr sidecar and Prometheus podMonitor. |
| metrics.exporter.env.additionalMetrics | bool | `false` | Set to true to enable gathering of additional metrics (slow) |
| metrics.exporter.env.port | int | `9792` | metrics port |
| metrics.exporter.env.unknownQueueItems | bool | `false` | Set to true to enable gathering unknown queue items |
| metrics.exporter.image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
| metrics.exporter.image.repository | string | `"ghcr.io/onedr0p/exportarr"` | image repository |
| metrics.exporter.image.tag | string | `"v0.6.1"` | image tag |
| metrics.prometheusRule | object | See values.yaml | Enable and configure Prometheus Rules for the chart under this key. |
| metrics.prometheusRule.rules | list | See prometheusrules.yaml | Configure additionial rules for the chart under this key. |
| metrics.serviceMonitor.interval | string | `"30s"` | |
| metrics.serviceMonitor.labels | object | `{}` | |
| metrics.serviceMonitor.scrapeTimeout | string | `"10s"` | |
| persistence | object | See values.yaml | Configure persistence settings for the chart under this key. | | persistence | object | See values.yaml | Configure persistence settings for the chart under this key. |
| probes | object | See values.yaml | Configures the probes for the main Pod. | | probes | object | See values.yaml | Configures the probes for the main Pod. |
| service | object | See values.yaml | Configures service settings for the chart. | | service | object | See values.yaml | Configures service settings for the chart. |
@ -102,6 +104,12 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [13.0.0]
#### Changed
- **BREAKING**: Refactored Prometheus metrics section to add rules. Enabling metrics automatically enables the serviceMonitor.
### [12.0.0] ### [12.0.0]
#### Changed #### Changed
@ -134,6 +142,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Initial version - Initial version
[13.0.0]: #1300
[12.0.0]: #1200 [12.0.0]: #1200
[11.0.0]: #1100 [11.0.0]: #1100
[10.0.0]: #1000 [10.0.0]: #1000

View File

@ -9,6 +9,12 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [13.0.0]
#### Changed
- **BREAKING**: Refactored Prometheus metrics section to add rules. Enabling metrics automatically enables the serviceMonitor and exporter sidecar.
### [12.0.0] ### [12.0.0]
#### Changed #### Changed
@ -41,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Initial version - Initial version
[13.0.0]: #1300
[12.0.0]: #1200 [12.0.0]: #1200
[11.0.0]: #1100 [11.0.0]: #1100
[10.0.0]: #1000 [10.0.0]: #1000

View File

@ -3,12 +3,12 @@
{{/* Append the hardcoded settings */}} {{/* Append the hardcoded settings */}}
{{- define "lidarr.harcodedValues" -}} {{- define "lidarr.harcodedValues" -}}
{{ if .Values.exporter.enabled }} {{ if .Values.metrics.enabled }}
additionalContainers: additionalContainers:
exporter: exporter:
name: exporter name: exporter
image: "{{ .Values.exporter.image.repository }}:{{ .Values.exporter.image.tag }}" image: "{{ .Values.metrics.exporter.image.repository }}:{{ .Values.metrics.exporter.image.tag }}"
imagePullPolicy: {{ .Values.exporter.image.pullPolicy }} imagePullPolicy: {{ .Values.metrics.exporter.image.pullPolicy }}
args: ["exportarr", "lidarr"] args: ["exportarr", "lidarr"]
env: env:
- name: URL - name: URL
@ -16,20 +16,29 @@ additionalContainers:
- name: CONFIG - name: CONFIG
value: "/config/config.xml" value: "/config/config.xml"
- name: PORT - name: PORT
value: "{{ .Values.exporter.env.port }}" value: "{{ .Values.metrics.exporter.env.port }}"
- name: ENABLE_ADDITIONAL_METRICS - name: ENABLE_ADDITIONAL_METRICS
value: "{{ .Values.exporter.env.additionalMetrics }}" value: "{{ .Values.metrics.exporter.env.additionalMetrics }}"
- name: ENABLE_UNKNOWN_QUEUE_ITEMS - name: ENABLE_UNKNOWN_QUEUE_ITEMS
value: "{{ .Values.exporter.env.unknownQueueItems }}" value: "{{ .Values.metrics.exporter.env.unknownQueueItems }}"
ports: ports:
- name: metrics - name: metrics
containerPort: {{ .Values.exporter.env.port }} containerPort: {{ .Values.metrics.exporter.env.port }}
volumeMounts: volumeMounts:
{{ if .Values.persistence.config.enabled }} {{ if .Values.persistence.config.enabled }}
- name: config - name: config
mountPath: /config mountPath: /config
readOnly: true readOnly: true
{{ end }} {{ end }}
service:
metrics:
enabled: true
ports:
metrics:
enabled: true
protocol: TCP
port: {{ .Values.metrics.exporter.env.port }}
{{ end }} {{ end }}
{{- end -}} {{- end -}}
{{- $_ := mergeOverwrite .Values (include "lidarr.harcodedValues" . | fromYaml) -}} {{- $_ := mergeOverwrite .Values (include "lidarr.harcodedValues" . | fromYaml) -}}

View File

@ -1,29 +0,0 @@
{{- if .Values.exporter.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ template "common.names.fullname" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.exporter.podMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "common.labels.selectorLabels" . | nindent 6 }}
podMetricsEndpoints:
- port: metrics
{{- with .Values.exporter.podMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.exporter.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
path: /metrics
relabelings:
- sourceLabels: ['namespace', 'job']
regex: ".+/(.*)"
targetLabel: "job"
replacement: "$1"
{{- end }}

View File

@ -0,0 +1,37 @@
{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.metrics.prometheusRule.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
groups:
- name: lidarr
rules:
- alert: ExportarrAbsent
annotations:
description: Lidarr Exportarr has disappeared from Prometheus
service discovery.
summary: Exportarr is down.
expr: |
absent(up{job=~".*lidarr.*"} == 1)
for: 5m
labels:
severity: critical
- alert: LidarrDown
annotations:
description: Lidarr service is down.
summary: Lidarr is down.
expr: |
lidarr_system_status == 0
for: 5m
labels:
severity: critical
{{- with .Values.metrics.prometheusRule.rules }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,24 @@
{{- if .Values.metrics.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.metrics.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "common.labels.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
{{- with .Values.metrics.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
path: /metrics
{{- end }}

View File

@ -57,6 +57,7 @@ probes:
timeoutSeconds: 10 timeoutSeconds: 10
# -- Configure persistence settings for the chart under this key. # -- Configure persistence settings for the chart under this key.
## Config persistence is required for the Prometheus exporter sidecar.
# @default -- See values.yaml # @default -- See values.yaml
persistence: persistence:
config: config:
@ -66,25 +67,43 @@ persistence:
enabled: false enabled: false
mountPath: /media mountPath: /media
exporter: metrics:
# -- Enable and configure Exportarr sidecar and Prometheus podMonitor. # -- Enable and configure Exportarr sidecar and Prometheus serviceMonitor.
# @default -- See values.yaml # @default -- See values.yaml
enabled: false enabled: false
podMonitor: serviceMonitor:
interval: 3m interval: 3m
scrapeTimeout: 1m scrapeTimeout: 1m
labels: {} labels: {}
image: # -- Enable and configure Prometheus Rules for the chart under this key.
# -- image repository # @default -- See values.yaml
repository: ghcr.io/onedr0p/exportarr prometheusRule:
# -- image tag enabled: false
tag: v0.6.1 labels: {}
# -- image pull policy # -- Configure additionial rules for the chart under this key.
pullPolicy: IfNotPresent # @default -- See prometheusrules.yaml
env: rules: []
# -- metrics port # - alert: LidarrDown
port: 32123 # annotations:
# -- Set to true to enable gathering of additional metrics (slow) # description: Lidarr service is down.
additionalMetrics: false # summary: Lidarr is down.
# -- Set to true to enable gathering unknown queue items # expr: |
unknownQueueItems: false # lidarr_system_status == 0
# for: 5m
# labels:
# severity: critical
exporter:
image:
# -- image repository
repository: ghcr.io/onedr0p/exportarr
# -- image tag
tag: v0.6.1
# -- image pull policy
pullPolicy: IfNotPresent
env:
# -- metrics port
port: 9792
# -- Set to true to enable gathering of additional metrics (slow)
additionalMetrics: false
# -- Set to true to enable gathering unknown queue items
unknownQueueItems: false