Eerste versie

This commit is contained in:
2022-10-28 08:30:22 +02:00
parent de75a01de7
commit 4d8224d1cc
31 changed files with 1638 additions and 2 deletions

26
exampleconf/conf.yaml Normal file
View File

@@ -0,0 +1,26 @@
# Config file for MQTT prometheus exporter
# Logging
#logging:
# logfile: '' # Optional default '' (stdout)
# level: 'info' # Optional default 'info'
# MQTT All values default to paho.mqtt.client defaults
#mqtt:
# host: 'mqtt.example.com' # Optional default 'localhost'
# port: 1883 # Optional default '1883'
# keepalive: 60 # Optional
# auth: # Optional If included, username_pw_set() is called with user/password
# username: 'user' # Required (when auth is present)
# password: 'pass' # Optional
# tls: # Optional If included, tls_set() is called with the following:
# ca_certs: # Optional
# certfile: # Optional
# keyfile: # Optional
# cert_reqs: # Optional
# tls_version: # Optional
# ciphers: # Optional
# Prometheus
#prometheus:
# exporter_port: # Optional default 9344

View File

@@ -0,0 +1,23 @@
# histogram metric. with Buckets <= 0.5, 5, 10, +inf
- name: 'network_ping_ms'
help: 'ping response in ms'
type: 'histogram'
topic: 'network/+/+/ping'
parameters:
buckets:
- 0.5
- 5
- 10
label_configs:
- source_labels: ['__msg_topic__']
target_label: '__topic__'
- source_labels: ["__msg_topic__"]
regex: "network/([^/]+).*"
target_label: "network"
replacement: '\1'
action: "replace"
- source_labels: ["__msg_topic__"]
regex: "network/[^/]+/([^/]+).*"
target_label: "server"
replacement: '\1'
action: "replace"

View File

@@ -0,0 +1,27 @@
# Example metric definition
metrics:
- name: 'mqtt_example' # Required(unique, if multiple, only last entry is kept)
help: 'MQTT example gauge' # Required
type: 'gauge' # Required ('gauge', 'counter', 'summary' or 'histogram')
#parameters: # Optional parameters for certain metrics
# buckets: # Optional (Passed as 'buckets' argument to Histogram)
# - .1
# - 1.0
# - 10.0
# states: # Optional (Passes as 'states' arguments to Enum)
# - on
# - off
topic: 'example/topic/+' # Required
# Inspired by 'https://prometheus.io/docs/operating/configuration/#<relabel_config>'
# "__msg_topic__" and "__value__" are populated with msg topic and value. And "__topic__" is 'topic' from config.
# Supported actions are: 'replace', 'keep' and 'drop'
# All labels starting with "__" will be removed, and "__topic__" and "__value__" is copied into "topic" anv "value"
# after all label configs have been applied.
label_configs: # Optional
- source_labels: ['__msg_topic__'] # Required (when label_configs is present)
separator: '/' # Optional default ';'
regex: '(.*)' # Optional default '(.*)'
target_label: '__topic__' # Required (when label_configs is present and 'action' = 'replace')
replacement: '\1' # Optional default '\1'
action: 'replace' # Optional default 'replace'

View File

@@ -0,0 +1,61 @@
# Config file for Mosquitto broker system metrics
# Metric definitions
metrics:
- name: 'mqtt_broker'
help: 'System events from broker'
type: 'gauge'
topic: '$SYS/broker/#'
label_configs:
- source_labels: ['__msg_topic__']
target_label: '__topic__'
- source_labels: ['__value__']
regex: '^(\d+([,.]\d*)?)$|^([,.]\d+)$'
action: 'keep'
- name: 'mqtt_broker_version'
help: 'Mosquitto version (static)'
type: 'gauge'
topic: '$SYS/broker/version'
label_configs:
- source_labels: ['__msg_topic__']
target_label: '__topic__'
- source_labels: ['__value__']
regex: '^\D+((?:\d+[\.]?)+)$'
target_label: 'version'
replacement: '\1'
action: 'replace'
- source_labels: ['__value__']
replacement: '1'
target_label: '__value__'
action: 'replace'
- name: 'mqtt_broker_changeset'
help: 'Mosquitto build changeset (static)'
type: 'gauge'
topic: '$SYS/broker/changeset'
label_configs:
- source_labels: ['__msg_topic__']
target_label: '__topic__'
- source_labels: ['__value__']
target_label: 'changeset'
action: 'replace'
- source_labels: ['__value__']
replacement: '1'
target_label: '__value__'
action: 'replace'
- name: 'mqtt_broker_timestamp'
help: 'Mosquitto build timestamp (static)'
type: 'gauge'
topic: '$SYS/broker/timestamp'
label_configs:
- source_labels: ['__msg_topic__']
target_label: '__topic__'
- source_labels: ['__value__']
target_label: 'timestamp'
action: 'replace'
- source_labels: ['__value__']
replacement: '1'
target_label: '__value__'
action: 'replace'

View File

@@ -0,0 +1,23 @@
# metric for a switch with the state on and off.
# states are case sensitive and must match exactly
# use label_config to rewrite other values, see below.
metrics:
- name: "fhem_light_state"
help: "Light state on/off"
type: "enum"
topic: "fhem/+/+/light"
parameters:
states:
- 'on'
- 'off'
label_configs:
- source_labels: ['__value__'] # replace uppercase ON and 0 with on
regex: "(ON|0)"
target_label: '__value__'
replacement: 'on'
action: "replace"
- source_labels: ['__value__'] # replace uppercase OFF und 1 with off
regex: "(OFF|1)"
target_label: '__value__'
replacement: 'off'
action: "replace"