Inputs.http.xml config help?

i have the following xml :slight_smile:

<perf-config>
<server name="RMF-DDS-Server" version="ZOSV2R4" functionality="3409"/>
<performance-data>
<buttons>YES</buttons>
<metric id="12345" description="% IIP by job" type="multi" listtype="J" workscope=",,G" filter="ORD=VD;HI=20;" ncols="3" resource="ABC1,*,PROCESSOR" restype="PROCESSOR" reslabelurl="ABC1,*,PROCESSOR">
<timerange localstart="20220701141400" localend="20220701141600" utcstart="20220701131400" utcend="20220701131600"/>
<scroll prev="20220701141300" next="20220701141700"/>
<timestamp localstart="07/01/2022 14:14:00" localtime="07/01/2022 14:16:00" timestring="20220701141600"/>
<gathererinterval seconds="120"/>
<data-range seconds="120"/>
<row label="PROC1" value="12.69" value2="00D0" per="12.69" ex="NONE"/>
<row label="PROC2" value="2.375" value2="00CF" per="2.375" ex="NONE"/>
<row label="PROC3" value="1.443" value2="0139" per="1.443" ex="NONE"/>
</metric>
</performance-data>
</perf-config>

following one of the examples if have the following config

  data_format = "xml"

    [[inputs.http.xml]]
      metric_name = "'RMF'"
      metric_selection = "//perf-config//performance-data//metric//row"
      timestamp = "//perf-config//performance-data//metric//timestamp//@timestring"

    [[inputs.http.xml.tags]]
      description = "label"

    [[inputs.http.xml.fields]]
      value = "value"

debug shows [parsers.xml::http] Number of selected metric nodes: 3 but no data is written to influx?

Thanks

Hi @Nigel_Hewett,
The input data formats for Telegraf shows xml parsing is handled by the XPATH parser plug-in. The syntax would be [[inputs.http.xpath]].

updated with xpath as follows still no data:

  data_format = "xml"

    [[inputs.http.xpath]]
      metric_name = "'RMF'"
      metric_selection = "/perf-config/performance-data/metric/row"
#      timestamp = "//perf-config//performance-data//metric//timestamp//@timestring"

    [[inputs.http.xpath.tags]]
      description = "@label"

    [[inputs.http.xpath.fields]]
      value = "@value"

is it because label and value are in one row ?

The Xpath parser plug-in documentation mentioned above shows single square bracket syntax for specifying tags and fields. See below . . . Note: the example uses file input so the only difference is inputs.http instead of inputs.file and proper indentation.

 ## Tag definitions using the given XPath queries.
    [inputs.file.xpath.tags]
      name   = "substring-after(Sensor/@name, ' ')"
      device = "string('the ultimate sensor')"

    ## Integer field definitions using XPath queries.
    [inputs.file.xpath.fields_int]
      consumers = "Variable/@consumers"

    ## Non-integer field definitions using XPath queries.
    ## The field type is defined using XPath expressions such as number(), boolean() or string(). If no conversion is performed the field will be of type string.
    [inputs.file.xpath.fields]
      temperature = "number(Variable/@temperature)"
      power       = "number(Variable/@power)"
      frequency   = "number(Variable/@frequency)"
      ok          = "Mode != 'ok'"
1 Like

hi, if i use this config:

  data_format = "xml"

  [inputs.http.xpath]
    metric_name = "'RMF'"
#      metric_selection = "/perf-config/performance-data/metric/row"
#      timestamp = "//perf-config//performance-data//metric//timestamp//@timestring"

  [inputs.http.xpath.tags]
    description = "/perf-config/performance-data/metric/row/@label"

  [inputs.http.xpath.fields_int]
    value = "/perf-config/performance-data/metric/row/@value"

it returns:

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

:frowning:

[[inputs.http]]
  data_format = "xml"

  [[inputs.http.xpath]]   # 1 Indent, Double square brackets
    metric_name = "'RMF'"

    [inputs.http.xpath.tags]  # 2 Indents, Single square brackets
      description = "/perf-config/performance-data/metric/row/@label"

    [inputs.http.xpath.fields_int]  # 2 Indents, Single square brackets
      value = "/perf-config/performance-data/metric/row/@value"

Set debug = true in the [agent] section.

2 Likes

thanks phill, too many []'s was the issue, that now is working fine.

if i wanted to include description from the

<metric id="12345" description="% IIP by job" type="multi" listtype="J" workscope=",,G" filter="ORD=VD;HI=20;" ncols="3" resource="ABC1,*,PROCESSOR" restype="PROCESSOR" reslabelurl="ABC1,*,PROCESSOR">

as this it outside of my metric selection i tried moving the metric selection to

/perf-config/performance-data/metric

this then can pick up description but only returns one row of label and values

is this possible either way?

thanks again

Thanks guys sorted it (I think)

leave the metric selection at row and use the full xpath to description for the tag

awesome tool