MQTT message parsing

Hi folks.

Iam reading mqtt data:

ess/home/statistics/pcs_pv_total_power 0
ess/home/statistics/batconv_power 190
ess/home/statistics/bat_use 1
ess/home/statistics/bat_status 2
ess/home/statistics/bat_user_soc 81.25
ess/home/statistics/load_power 191
ess/home/statistics/load_today 0.0
ess/home/statistics/grid_power 1
ess/home/statistics/current_day_self_consumption 0.0
ess/home/statistics/current_pv_generation_sum 0
ess/home/statistics/current_grid_feed_in_energy 0

I would like to have the measument named “ess” and then in _field eveything after statistics/. But i dont get it.

Here my actual telegraf config:

 ## Topics that will be subscribed to.
  topics = ["ess/home/statistics/#"]

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "value"
  data_type = "float"

  # Enable extracting tag values from MQTT topics
  # _ denotes an ignored entry in the topic path
  [[inputs.mqtt_consumer.topic_parsing]]
    topic = "ess/+/+/+"
    measurement = "ess/_/_/_"
    fields = "_/_/_/_"
    #tags = "_/home/statistics/_"

Please help me. Many thanks in advance.

Has no one an idea?
Do you need more information?

Hello @Stefan_F,
I’m so sorry for not responding sooner. Sometimes messages get lost in here. In the future please @ me.

I haven’t tested it but I think you can do:

[[inputs.mqtt_consumer]]
  servers = ["tcp://localhost:1883"]
  topics = ["ess/home/statistics/#"]
  data_format = "value"

[[inputs.mqtt_consumer.topic_parsing]]
  topic = "ess/home/statistics/(.*)/(.*)/(.*)"
  measurement = "ess"
  fields = ["$1", "$2", "$3"]

To give you

ess,field1=statistics,field2=pcs_pv_total_power value=0
ess,field1=statistics,field2=batconv_power value=190
ess,field1=statistics,field2=bat_use value=1
ess,field1=statistics,field2=bat_status value=2
ess,field1=statistics,field2=bat_user_soc value=81.25
ess,field1=statistics,field2=load_power value=191
ess,field1=statistics,field2=load_today value=0.0
ess,field1=statistics,field2=grid_power value=1
ess,field1=statistics,field2=current_day_self_consumption value=0.0
ess,field1=statistics,field2=current_pv_generation_sum value=0
ess,field1=statistics,field2=current_grid_feed_in_energy value=0

Just checking do you know about the --debug --test and --once flags for telegraf as well?
They can be really useful.