Http/xml parser config not found

Hello,

since several days, my previous working http/xml parsing configuration doesnt work anymore. telegraf --debug --test gives me:

[parsers.xml::http] Number of configs: 0

Here is my config:

[[inputs.http]]
  urls = [ "http://openhab.beach.lan/addons/xmlapi/state.cgi?device_id=1555" ]

  data_format = "xml"
  tagexclude = ["url", "host"]

  [[inputs.http.xml]]

  metric_name = "'hygrometer'"
  metric_selection = "/state/device[@name='Hygrometer_LR']/channel[@ise_id='1576']"
  timestamp = "datapoint[type='TEMPERATURE']/@timestamp"
  timestamp_format = "unix"

  [inputs.http.xml.fields]
    humidity = "number(datapoint[@type='HUMIDITY']/@value)"
    temperature = "number(datapoint[@type='TEMPERATURE']/@value)"

and the response of “url”.

<state>
  <device name="Hygrometer_LR" ise_id="1555" unreach="false" sticky_unreach="false" config_pending="false">
    <channel name="Hygrometer_LR:0" ise_id="1556">
      <datapoint name="BidCos-RF.OEQ0161025:0.UNREACH" type="UNREACH" ise_id="1572"       value="false" valuetype="2" valueunit="" timestamp="1655382240"/>
      <datapoint name="BidCos-RF.OEQ0161025:0.STICKY_UNREACH" type="STICKY_UNREACH"       ise_id="1568" value="false" valuetype="2" valueunit="" timestamp="1655382240"/>
      <datapoint name="BidCos-RF.OEQ0161025:0.CONFIG_PENDING" type="CONFIG_PENDING" ise_id="1558" value="false" valuetype="2" valueunit="" timestamp="1655382240"/>
      <datapoint name="BidCos-RF.OEQ0161025:0.LOWBAT" type="LOWBAT" ise_id="1562" alue="false" valuetype="2" valueunit="" timestamp="1655382240"/>
      <datapoint name="BidCos-RF.OEQ0161025:0.RSSI_DEVICE" type="RSSI_DEVICE" se_id="1566" value="1" valuetype="8" valueunit="" timestamp="1655382240"/>
      <datapoint name="BidCos-RF.OEQ0161025:0.RSSI_PEER" type="RSSI_PEER" ise_id="1567" alue="1" valuetype="8" valueunit="" timestamp="1655382240"/>
    </channel>
    <channel name="HM-WDS40-TH-I-2 OEQ0161025:1" ise_id="1576">
      <datapoint name="BidCos-RF.OEQ0161025:1.TEMPERATURE" type="TEMPERATURE" se_id="1578" value="23.500000" valuetype="4" valueunit="°C" timestamp="1655383038"/>
      <datapoint name="BidCos-RF.OEQ0161025:1.HUMIDITY" type="HUMIDITY" ise_id="1577" alue="48" valuetype="16" valueunit="%" timestamp="1655383038"/>
    </channel>
  </device>
</state>

Any help is appreciated.

Hello @beacher_pille88,
Can you please set debug=true and share all of the logs?
Thank you.

No problem, there you go:

In my real config, there are several more plugins, but I shortened it to the failing one and just ping statistics.

telegraf_my.conf

[global_tags]

[agent]
  interval = "240s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "60s"
  flush_jitter = "0s"
  precision = ""
  debug = true
  quiet = false
  omit_hostname = true

[[outputs.influxdb_v2]]
  urls = ["http://sun.beach.lan:8086"]
  token = "Y6Z3Dwh6EGtWqaD5SJw1L8FImS0cZCbL2ZurDDBaM3P_n7gsIkXQut4LGuKOrvX_reI6UE87gQHKMOu9RkJNXQ=="
  organization = "Home"
  bucket = "SmartHome"

[[inputs.http]]
  urls = [ "http://openhab.beach.lan/addons/xmlapi/state.cgi?device_id=1555" ]

  data_format = "xml"
  tagexclude = ["url", "host"]

  [[inputs.http.xml]]
  
  metric_name = "'hygrometer'"
  metric_selection = "/state/device[@name='Hygrometer_LR']/channel[@ise_id='1576']"
  timestamp = "datapoint[type='TEMPERATURE']/@timestamp"
  timestamp_format = "unix"

  [inputs.http.xml.fields]
    humidity = "number(datapoint[@type='HUMIDITY']/@value)"
    temperature = "number(datapoint[@type='TEMPERATURE']/@value)"

[[inputs.ping]]
  urls = ["8.8.8.8"]

  method = "native"
  count = 10
  ping_interval = 1.0
  ipv6 = false
  interval = "60s"

And here you can see the output:

$ sudo telegraf --config telegraf_my.conf --debug --test

2022-06-17T23:06:58Z I! Starting Telegraf 1.23.0
2022-06-17T23:06:58Z I! Loaded inputs: http ping
2022-06-17T23:06:58Z I! Loaded aggregators: 
2022-06-17T23:06:58Z I! Loaded processors: 
2022-06-17T23:06:58Z W! Outputs are not used in testing mode!
2022-06-17T23:06:58Z I! Tags enabled: 
2022-06-17T23:06:58Z D! [agent] Initializing plugins
2022-06-17T23:06:58Z D! [agent] Starting service inputs
2022-06-17T23:06:58Z D! [parsers.xml::http] Number of configs: 0
> ping,url=8.8.8.8 average_response_ms=12.888363,maximum_response_ms=14.071322,minimum_response_ms=10.900155,packets_received=10i,packets_transmitted=10i,percent_packet_loss=0,result_code=0i,standard_deviation_ms=0.868977,ttl=116i 1655507228000000000
2022-06-17T23:07:07Z D! [agent] Stopping service inputs
2022-06-17T23:07:07Z D! [agent] Input channel closed
2022-06-17T23:07:07Z D! [agent] Stopped Successfully

This worked until 16.06.2022 01:48:00 +02:00

I already tried it with tails als input and the response of “url” but without success.

My € 0.10: Are you missing an @ in type=‘TEMPERATURE’ ?

Just tried it out - same result.

I solved it myself.

The following is not valid (anymore):

[[inputs.http]]
  ...
  [[inputs.http.xml]]
  ...
  [inputs.http.xml.fields]

It has to be:

[[inputs.http]]
  ...
  [[inputs.http.xpath]]
  ...
  [inputs.http.xpath.fields]

xml → xpath

Hi,

Thanks for noticing this! This is definitely a regression. We have put up a PR here with a fix.

In ~20mins or so, that PR should have artifacts that you can download and try. If you can, could you try one of those artifacts out and let us know if it allows you to use your previous config?

Thanks!

No problem, I’m always happy to contribute anything to this project.

I’m not DevOps enough to try this out and possibly fuck up my “clean” installation. Sorry!