The result of modifying the key name of the json format data will be doubled

Latezly
Tue, 25 Jun 2024 19:28:11 +0000
Telegraf

JSON data

{
    "Time": "2024-06-25T06:20:03",
    "ENERGY": {
        "TotalStartTime": "2024-05-15T17:10:58",
        "Total": [
            206.965,
            291.411,
            473.815
        ],
        "Yesterday": [
            6.641,
            12.554,
            16.117
        ],
        "Today": [
            0.698,
            4.113,
            4.264
        ],
        "Period": [
            0,
            0,
            2
        ],
        "Power": [
            30,
            242,
            661
        ],
        "ApparentPower": [
            57,
            328,
            680
        ],
        "ReactivePower": [
            49,
            221,
            162
        ],
        "Factor": [
            0.52,
            0.74,
            0.97
        ],
        "Frequency": [
            50,
            50,
            50
        ],
        "Voltage": [
            225,
            225,
            225
        ],
        "Current": [
            0.255,
            1.453,
            3.021
        ]
    }
}

Telegraf Config

[[outputs.file]]
  files = ["stdout", "/root/out.txt"]
  data_format = "influx"

[[inputs.mqtt_consumer]]
  servers = ["tcp://172.30.1.135:1883"]
  topics = [
    "tele/pezm_584143/SENSOR"
  ]
  qos = 0
  username = ""
  password = ""
  name_override = "pezm_three_phase_sensor"
  data_format = "json_v2"

  [[inputs.mqtt_consumer.json_v2]]
    [[inputs.mqtt_consumer.json_v2.object]]
      path = "ENERGY"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Total.0"
        rename = "Total_0"
        type = "float"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Total.1"
        rename = "Total_1"
        type = "float"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Total.2"
        rename = "Total_2"
        type = "float"
      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Yesterday.0"
        rename = "Yesterday_0"
        type = "float"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Yesterday.1"
        rename = "Yesterday_1"
        type = "float"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Yesterday.2"
        rename = "Yesterday_2"
        type = "float"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Today.0"
        rename = "Today_0"
        type = "float"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Today.1"
        rename = "Today_1"
        type = "float"

      [[inputs.mqtt_consumer.json_v2.object.field]]
        path = "Today.2"
        rename = "Today_2"
        type = "float"

Expected results

pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Today_1=2.351,Today_2=0.905,Yesterday_0=5.522,Yesterday_1=3.875,Yesterday_2=2.783,Total_0=212.957,Total_1=293.524 Total_2=473.239 1719340878361661835

Actual results

pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_0=5.522,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_0=5.522,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_0=5.522,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_1=3.875,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_1=3.875,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_1=3.875,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_2=2.783,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_2=2.783,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_0=1.169,Yesterday_2=2.783,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_0=5.522,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_0=5.522,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_0=5.522,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_1=3.875,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_1=3.875,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_1=3.875,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_2=2.783,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_2=2.783,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_1=2.351,Yesterday_2=2.783,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_0=5.522,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_0=5.522,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_0=5.522,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_1=3.875,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_1=3.875,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_1=3.875,Total_2=473.239 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_2=2.783,Total_0=212.957 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_2=2.783,Total_1=293.524 1719340878361661835
pezm_three_phase_sensor,host=CN-D12-Telegraf,topic=tele/pezm_584143/SENSOR Today_2=0.905,Yesterday_2=2.783,Total_2=473.239 1719340878361661835

2 posts - 2 participants