♻️ home-automation

This commit is contained in:
auricom
2022-09-14 14:55:02 +02:00
parent ad4642f598
commit a5b53b32d6
26 changed files with 447 additions and 240 deletions

View File

@@ -0,0 +1,57 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: &app zigbee2mqtt-exporter
namespace: default
spec:
interval: 15m
chart:
spec:
chart: app-template
version: 0.1.1
sourceRef:
kind: HelmRepository
name: bjw-s-charts
namespace: flux-system
install:
createNamespace: true
remediation:
retries: 5
upgrade:
remediation:
retries: 5
dependsOn:
- name: emqx
namespace: default
- name: zigbee2mqtt
namespace: default
values:
image:
repository: docker.io/kpetrem/mqtt-exporter
tag: latest@sha256:c70814150116a96e09292d08571a9e04f7df0048f152f7af2f167c09ad4ac95f
env:
LOG_LEVEL: DEBUG
LOG_MQTT_MESSAGE: "True"
MQTT_ADDRESS: emqx.default.svc.cluster.local
MQTT_TOPIC: "zigbee2mqtt/#"
MQTT_V5_PROTOCOL: "True"
MQTT_USERNAME: ${SECRET_MQTT_USER}
MQTT_PASSWORD: ${SECRET_MQTT_PASSWORD}
PROMETHEUS_PORT: &port 80
PROMETHEUS_PREFIX: zigbee2mqtt_
ZIGBEE2MQTT_AVAILABILITY: "True"
service:
main:
ports:
http:
port: *port
podSecurityContext:
runAsUser: 1000
runAsGroup: 1000
resources:
requests:
cpu: 10m
memory: 50Mi
limits:
memory: 200Mi

View File

@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helm-release.yaml
- prometheus.yaml

View File

@@ -0,0 +1,52 @@
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: &app zigbee2mqtt-exporter
namespace: default
labels: &labels
app.kubernetes.io/instance: *app
app.kubernetes.io/name: *app
spec:
selector:
matchLabels:
<<: *labels
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: zigbee2mqtt-exporter
namespace: default
spec:
groups:
- name: zigbee2mqtt-exporter.rules
rules:
- alert: Zigbee2MqttExporterAbsent
annotations:
summary: Zigbee2Mqtt Exporter has disappeared from Prometheus target discovery.
expr: absent(up{job=~".*mqtt-exporter.*"} == 1)
for: 15m
labels:
severity: critical
- alert: Zigbee2MqttUnavailable
annotations:
summary: The zigbee device connection is lost,
connection on topic {{$labels.topic}} is down.
expr: zigbee2mqtt_zigbee_availability == 0
for: 60m
labels:
severity: critical
- alert: Zigbee2MqttBatteryLow
annotations:
summary: The zigbee device battery level is low,
battery level on topic {{$labels.topic}} is at {{$value}}%.
expr: zigbee2mqtt_battery < 10
for: 60m
labels:
severity: warning