[unifi-poller] metrics refactor (#1182)

Co-authored-by: ᗪєνιη ᗷυнʟ <onedr0p@users.noreply.github.com>
This commit is contained in:
j_r0dd 2021-09-13 09:39:53 -04:00 committed by GitHub
parent c3017ec800
commit faec4db9ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 94 additions and 29 deletions

View File

@ -2,7 +2,7 @@ apiVersion: v2
appVersion: 2.1.3
description: Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus
name: unifi-poller
version: 9.0.0
version: 10.0.0
kubeVersion: ">=1.16.0-0"
keywords:
- unifi

View File

@ -1,6 +1,6 @@
# unifi-poller
![Version: 9.0.0](https://img.shields.io/badge/Version-9.0.0-informational?style=flat-square) ![AppVersion: 2.1.3](https://img.shields.io/badge/AppVersion-2.1.3-informational?style=flat-square)
![Version: 10.0.0](https://img.shields.io/badge/Version-10.0.0-informational?style=flat-square) ![AppVersion: 2.1.3](https://img.shields.io/badge/AppVersion-2.1.3-informational?style=flat-square)
Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus
@ -87,10 +87,16 @@ N/A
| influxdb.enabled | bool | `false` | Create an InfluxDB instance as a [unifi-poller storage backend](https://unifipoller.com/docs/dependencies/influxdb). See [bitnami/influxdb](https://github.com/bitnami/charts/tree/master/bitnami/influxdb) for more options. |
| influxdb.persistence.enabled | bool | `false` | Enable persistence to store in a PV so data survives pod restarts. |
| ingress.main.enabled | bool | `false` | Expose [unifi-poller's web interface](https://unifipoller.com/docs/advanced/webserver) (if enabled in the configuration) via the k8s ingress by setting this true. |
| prometheus.serviceMonitor.additionalLabels | object | `{}` | More labels to add to the ServiceMonitor resource. |
| prometheus.serviceMonitor.enabled | bool | `false` | Create a [ServiceMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/design.md#servicemonitor) for the [unifi-poller prometheus exporter](https://unifipoller.com/docs/dependencies/prometheus) that is recognized by [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator). This gets created in this chart's namespace. Note: this only creates a ServiceMonitor, not a prometheus instance. |
| prometheus.serviceMonitor.interval | string | `"1m"` | Prometheus [endpoint polling interval](https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint) for this ServiceMonitor (how often unifi-poller will be queried). |
| service.main.ports.http.port | int | `9130` | The port this prometheus exporter will listen on ([registered as 9130](https://github.com/prometheus/prometheus/wiki/Default-port-allocations)). This should match unifi-poller's [configured listen port](https://unifipoller.com/docs/install/configuration#prometheus). |
| metrics.enabled | bool | See values.yaml | Enable and configure a Prometheus serviceMonitor for the chart under this key. |
| 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"` | |
| service.main.ports.http.enabled | bool | `false` | |
| service.main.ports.metrics.enabled | bool | `true` | |
| service.main.ports.metrics.port | int | `9130` | |
| service.main.ports.metrics.protocol | string | `"TCP"` | |
## Changelog
@ -98,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).
### [10.0.0]
#### Changed
- **BREAKING**: Refactored Prometheus metrics section to add rules. Enabling metrics automatically enables the serviceMonitor.
### [9.0.0]
#### Changed
@ -113,6 +125,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- **BREAKING**: Change the default influxdb database name to match unifi-poller's default
- Updates default unifi-poller version from 2.0.1 to 2.1.3
[10.0.0]: #1000
[9.0.0]: #900
[8.0.0]: #800

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).
### [10.0.0]
#### Changed
- **BREAKING**: Refactored Prometheus metrics section to add rules. Enabling metrics automatically enables the serviceMonitor.
### [9.0.0]
#### Changed
@ -24,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- **BREAKING**: Change the default influxdb database name to match unifi-poller's default
- Updates default unifi-poller version from 2.0.1 to 2.1.3
[10.0.0]: #1000
[9.0.0]: #900
[8.0.0]: #800
{{- end -}}

View File

@ -0,0 +1,27 @@
{{- 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: {{ include "common.names.fullname" . }}
rules:
- alert: UnifiPollerAbsent
annotations:
description: Unifi Poller has disappeared from Prometheus service discovery.
summary: Unifi Poller is down.
expr: |
absent(up{job=~".*{{ include "common.names.fullname" . }}.*"} == 1)
for: 5m
labels:
severity: critical
{{- with .Values.metrics.prometheusRule.rules }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

View File

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

View File

@ -28,8 +28,10 @@ service:
main:
ports:
http:
# -- The port this prometheus exporter will listen on ([registered as 9130](https://github.com/prometheus/prometheus/wiki/Default-port-allocations)).
# This should match unifi-poller's [configured listen port](https://unifipoller.com/docs/install/configuration#prometheus).
enabled: false
metrics:
enabled: true
protocol: TCP
port: 9130
ingress:
@ -38,19 +40,6 @@ ingress:
# (if enabled in the configuration) via the k8s ingress by setting this true.
enabled: false
prometheus:
serviceMonitor:
# -- Create a [ServiceMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/design.md#servicemonitor)
# for the [unifi-poller prometheus exporter](https://unifipoller.com/docs/dependencies/prometheus)
# that is recognized by [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator).
# This gets created in this chart's namespace. Note: this only creates a ServiceMonitor, not a prometheus instance.
enabled: false
# -- Prometheus [endpoint polling interval](https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint)
# for this ServiceMonitor (how often unifi-poller will be queried).
interval: 1m
# -- More labels to add to the ServiceMonitor resource.
additionalLabels: {}
influxdb:
# -- Create an InfluxDB instance as a [unifi-poller storage backend](https://unifipoller.com/docs/dependencies/influxdb).
# See [bitnami/influxdb](https://github.com/bitnami/charts/tree/master/bitnami/influxdb) for more options.
@ -68,3 +57,29 @@ influxdb:
enabled: false
# storageClass: ""
# size: 8Gi
metrics:
# -- Enable and configure a Prometheus serviceMonitor for the chart under this key.
# @default -- See values.yaml
enabled: false
serviceMonitor:
interval: 1m
scrapeTimeout: 30s
labels: {}
# -- Enable and configure Prometheus Rules for the chart under this key.
# @default -- See values.yaml
prometheusRule:
enabled: false
labels: {}
# -- Configure additionial rules for the chart under this key.
# @default -- See prometheusrules.yaml
rules: []
# - alert: UnifiPollerAbsent
# annotations:
# description: Unifi Poller has disappeared from Prometheus service discovery.
# summary: Unifi Poller is down.
# expr: |
# absent(up{job=~".*unifi-poller.*"} == 1)
# for: 5m
# labels:
# severity: critical