Last active
October 31, 2024 08:49
-
-
Save kleini/11a4ffe94b6d7fadad987fb172cbaeb4 to your computer and use it in GitHub Desktop.
Pump MQTT data from a Victron Energy Cerbo GX with Telegraf into InfluxDB v2
This file contains hidden or 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
| [[inputs.mqtt_consumer]] | |
| servers = ["ssl://192.168.0.102:8883"] | |
| ## Topics that will be subscribed to. | |
| topics = [ | |
| "venus/N/+/#", | |
| ] | |
| username = "telegraf" | |
| password = "superSecret" | |
| insecure_skip_verify = true | |
| data_format = "json" | |
| ## Enable extracting tag values from MQTT topics | |
| ## _ denotes an ignored entry in the topic path | |
| # TODO migrate to regex processor | |
| [[inputs.mqtt_consumer.topic_parsing]] | |
| # venus/N/instanceID/pvinverter/20/Ac/Power | |
| topic = "venus/N/+/#" | |
| tags = "_/_/name/" | |
| [[processors.regex]] | |
| namepass = ["mqtt_consumer"] | |
| # extract new measurement | |
| [[processors.regex.tags]] | |
| key = "topic" | |
| pattern = "^venus/N/[a-z0-9]+/(?P<device>[a-z]+)/(?P<instanceNumber>\\d+)/(.*)$" | |
| replacement = "${device}/${3}" | |
| result_key = "measurement" | |
| # additional tag with VRM instance number | |
| [[processors.regex.tags]] | |
| key = "topic" | |
| pattern = "^venus/N/[a-z0-9]+/(?P<device>[a-z]+)/(?P<instanceNumber>\\d+)/(.*)$" | |
| replacement = "${instanceNumber}" | |
| result_key = "instanceNumber" | |
| # replace measurement | |
| [[processors.converter]] | |
| namepass = ["mqtt_consumer"] | |
| [processors.converter.tags] | |
| measurement = ["measurement"] | |
| # for easier debugging | |
| #[[outputs.file]] | |
| # files = ["stdout"] | |
| # data_format = "influx" | |
| # influx_max_line_bytes = 0 | |
| # pump data to InfluxDB v2 | |
| [[outputs.influxdb_v2]] | |
| urls = ["http://192.168.0.104:8086"] | |
| token = "secretToken" | |
| organization = "myorg" | |
| bucket = "venusOS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment