forked from bendikwa/mqtt_exporter
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENUM to support e.g. Light Switches (#27)
ENUM is a not so common metric, that is made to suport boolen states. Typical use case are predefined states like on/off or low/medium/high in string form. Regarding ENUM see https://github.com/prometheus/client_python/blob/9a24236695c9ad47f9dc537a922a6d1333d8d093/prometheus_client/metrics.py#L640-L698 and https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#stateset Co-authored-by: poggenpower <[email protected]>
- Loading branch information
1 parent
86d79ec
commit 1afdb5a
Showing
8 changed files
with
213 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
# Logging | ||
logging: | ||
# logfile: 'conf/mqttexperter.log' # Optional default '' (stdout) | ||
level: 'debug' # Optional default 'info' | ||
|
||
timescale: 0 | ||
|
||
# Metric definitions | ||
metrics: | ||
- name: "fhem_light_state" | ||
help: "Light state on/off" | ||
type: "enum" | ||
topic: "fhem/+/+/light" | ||
parameters: | ||
states: | ||
- 'on' | ||
- 'off' | ||
label_configs: | ||
- source_labels: ['__value__'] | ||
regex: "(ON|0)" | ||
target_label: '__value__' | ||
replacement: 'on' | ||
action: "replace" | ||
- source_labels: ['__value__'] | ||
regex: "(OFF|1)" | ||
target_label: '__value__' | ||
replacement: 'off' | ||
action: "replace" | ||
- source_labels: ['__msg_topic__'] | ||
target_label: '__topic__' | ||
- source_labels: ["__msg_topic__"] | ||
regex: "fhem/([^/]+).*" | ||
target_label: "location" | ||
replacement: '\1' | ||
action: "replace" | ||
- 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
in_topic;in_payload;out_name;out_labels;out_value;delay;assert | ||
fhem/room01/desk/light01;on;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};0;4;True | ||
fhem/room01/desk/light01;on;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};0;3;True | ||
fhem/room01/desk/light01;off;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};1;5;True | ||
fhem/room01/desk/light01;on;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};0;4;True | ||
fhem/room01/desk/light01;off;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};1;3;True | ||
fhem/room01/desk/light01;ON;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};0;5;True | ||
fhem/room01/desk/light01;OFF;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};1;4;True | ||
fhem/room01/desk/light01;off;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};1;3;True | ||
fhem/room01/desk/light01;1;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};1;5;True | ||
fhem/room01/desk/light01;0;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};0;4;True | ||
fhem/room01/desk/light01;on;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};0;3;True | ||
fhem/room01/desk/light01;off;fhem_light_state;{"location":"Garten","topic": "fhem/room01/desk/light01"};1;5;True | ||
network/vlan11/srv01.local/ping;2;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "5.0"};{"_count": 1, "_sum": 2, "_bucket": 1};2;True | ||
network/vlan11/srv01.local/ping;4;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "5.0"};{"_count": 2, "_sum": 6, "_bucket": 2};6;True | ||
network/vlan11/srv01.local/ping;7;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "10.0"};{"_count": 3, "_sum": 13, "_bucket": 3};1;True | ||
network/vlan11/srv01.local/ping;0.4;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "0.5"};{"_count": 4, "_sum": 13.4, "_bucket": 1};4;True | ||
network/vlan11/srv01.local/ping;20;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "+Inf"};{"_count": 5, "_sum": 33.4, "_bucket": 5};5;True | ||
network/vlan11/srv01.local/ping;11.1;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "+Inf"};{"_count": 6, "_sum": 44.5, "_bucket": 6};2;True | ||
network/vlan11/srv01.local/ping;5;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "5.0"};{"_count": 7, "_sum": 49.5, "_bucket": 4};4;True | ||
network/vlan11/srv01.local/ping;6;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "10.0"};{"_count": 8, "_sum": 55.5, "_bucket": 6};1;True | ||
network/vlan11/srv01.local/ping;0.05;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "0.5"};{"_count": 9, "_sum": 55.55, "_bucket": 2};4;True | ||
network/vlan11/srv01.local/ping;30;network_ping_ms;{"network": "vlan11","topic": "network/vlan11/srv01.local/ping", "server": "srv01.local", "le": "+Inf"};{"_count": 10, "_sum": 85.55, "_bucket": 10};5;True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters