# Inputs.http.xml config help?

**URL:** <https://community.influxdata.com/t/inputs-http-xml-config-help/25643>\
**Category:** Telegraf\
**Tags:** xml\
**Created:** [July 4, 2022, 10:39am UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643 "2022-07-04T10:39:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nigel\_Hewett](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/nigel_hewett/32/10323_2.png) [@Nigel\_Hewett](https://community.influxdata.com/u/Nigel_Hewett)\
**Post date:** [July 4, 2022, 10:39am UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/1 "2022-07-04T10:39:23Z")

</div>

i have the following xml 🙂

```auto
<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

```auto
  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

---

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://community.influxdata.com/u/phill)\
**Post date:** [July 4, 2022, 1:38pm UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/2 "2022-07-04T13:38:56Z")

</div>

Hi @Nigel_Hewett,  
The [input data formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) for Telegraf shows xml parsing is handled by the [XPATH parser plug-in](https://github.com/influxdata/telegraf/tree/master/plugins/parsers/xpath). The syntax would be `[[inputs.http.xpath]]`.

---

<div class="post-metadata">

**Author:** ![Nigel\_Hewett](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/nigel_hewett/32/10323_2.png) [@Nigel\_Hewett](https://community.influxdata.com/u/Nigel_Hewett)\
**Post date:** [July 5, 2022, 7:17am UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/3 "2022-07-05T07:17:20Z")

</div>

updated with xpath as follows still no data:

```auto
  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 ?

```

---

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://community.influxdata.com/u/phill)\
**Post date:** [July 5, 2022, 10:25am UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/4 "2022-07-05T10:25:54Z")

</div>

The [Xpath parser plug-in documentation](https://github.com/influxdata/telegraf/tree/master/plugins/parsers/xpath) 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.

```auto
 ## 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'"

```

---

<div class="post-metadata">

**Author:** ![Nigel\_Hewett](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/nigel_hewett/32/10323_2.png) [@Nigel\_Hewett](https://community.influxdata.com/u/Nigel_Hewett)\
**Post date:** [July 5, 2022, 12:27pm UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/5 "2022-07-05T12:27:14Z")

</div>

hi, if i use this config:

```auto
  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:

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

```

☹

---

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://community.influxdata.com/u/phill)\
**Post date:** [July 5, 2022, 4:08pm UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/6 "2022-07-05T16:08:25Z")

</div>

```auto
[[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.

---

<div class="post-metadata">

**Author:** ![Nigel\_Hewett](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/nigel_hewett/32/10323_2.png) [@Nigel\_Hewett](https://community.influxdata.com/u/Nigel_Hewett)\
**Post date:** [July 6, 2022, 7:54am UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/7 "2022-07-06T07:54:55Z")

</div>

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

if i wanted to include description from the

```auto
<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

```auto
/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

---

<div class="post-metadata">

**Author:** ![Nigel\_Hewett](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/nigel_hewett/32/10323_2.png) [@Nigel\_Hewett](https://community.influxdata.com/u/Nigel_Hewett)\
**Post date:** [July 6, 2022, 10:04am UTC](https://community.influxdata.com/t/inputs-http-xml-config-help/25643/8 "2022-07-06T10:04:37Z")

</div>

Thanks guys sorted it (I think)

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

awesome tool
