I am just starting out with the TIG stack on a pi3B. I am trying to read temperature values from an xml file and keep getting error messages and telegraf failing to start. I have read through the “parsing XML” guides and suspect I have still made an error with the inputs section of the conf file. I used the “journalctl -fu telegraf” command which stated -
“key `data_format’ is in conflict with line b21d”
I do not understand where b21d is - perhaps in the telegraf executable?
[[inputs.http.xml]]
## Optional: XPath-query to select a subset of nodes from the XML document.
metric_selection = “//SenSet”
## Optional: XPath-query to set the metric (measurement) name.
metric_name = "string('Creysse')"
## Optional: Query to extract metric timestamp.
## If not specified the time of execution is used.
#timestamp = "/Gateway/Timestamp"
## Optional: Format of the timestamp determined by the query above.
## This can be any of "unix", "unix_ms", "unix_us", "unix_ns" or a valid Golang
## time format. If not specified, a "unix" timestamp (in seconds) is expected.
#timestamp_format = "2006-01-02T15:04:05Z"
## Tag definitions using the given XPath queries.
[inputs.http.xml.tags]
name = "string(Entry/Name)"
## Integer field definitions using XPath queries.
[inputs.http.xml.fields_int]
## 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.http.xml.fields]
temperature = "number(Entry/Value)"
I would be grateful for any assistance in identifying my mistakes here.
The example data does not look like a valid XML file.
Your post is a bit messed up. Please embed all code snippets in markdown format, so that it will be rendered correctly here in the forum and thus be displayed legibly, see example below.
```xml
put your xml file snippet here
```
```toml
put you Telegraf config code snippet here
```
I think the problem is in the inputs section of my telegraf.conf file -
[[inputs.http]]
urls = ["http://peyr.dyndns.org:2905/values.xml"]
data_format = "xml"
## Drop url and hostname from list of tags
tagexclude = ["url", "host"]
## 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 = "xml"
## Multiple parsing sections are allowed
[[inputs.http.xml]]
## Optional: XPath-query to select a subset of nodes from the XML document.
metric_selection = "//SenSet"
## Optional: XPath-query to set the metric (measurement) name.
metric_name = "string('Creysse')"
## Optional: Query to extract metric timestamp.
## If not specified the time of execution is used.
#timestamp = "/Gateway/Timestamp"
## Optional: Format of the timestamp determined by the query above.
## This can be any of "unix", "unix_ms", "unix_us", "unix_ns" or a valid Golang
## time format. If not specified, a "unix" timestamp (in seconds) is expected.
#timestamp_format = "2006-01-02T15:04:05Z"
## Tag definitions using the given XPath queries.
[inputs.http.xml.tags]
name = "string(Entry/Name)"
## Integer field definitions using XPath queries.
[inputs.http.xml.fields_int]
## 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.http.xml.fields]
temperature = "number(Entry/Value)"
I would be grateful for any assistance in identifying my mistakes here.
Thanks for formatting your config file. Can you provide the full output from telegraf as well? You mentioned part of it, but it would be good to see the full thing?
Do you mean the full telegraf.conf file ?
There is not much “output” as telegraf fails to start properly – or do you mean the response to the status command in the terminal?
here is the output from the status command after I start telegraf
Will look into pastebin
D
sudo systemctl status telegraf
telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
Loaded: loaded (/lib/systemd/system/telegraf.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2021-11-04 15:23:36 GMT; 4min 56s ago
Docs: GitHub - influxdata/telegraf: The plugin-driven server agent for collecting & reporting metrics.
Process: 5020 ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS (code=exited, status=1/FAILURE)
Main PID: 5020 (code=exited, status=1/FAILURE)
Nov 04 15:23:36 KODI systemd[1]: telegraf.service: Service RestartSec=100ms expired, scheduling restart.
Nov 04 15:23:36 KODI systemd[1]: telegraf.service: Scheduled restart job, restart counter is at 5.
Nov 04 15:23:36 KODI systemd[1]: Stopped The plugin-driven server agent for reporting metrics into InfluxDB.
Nov 04 15:23:36 KODI systemd[1]: telegraf.service: Start request repeated too quickly.
Nov 04 15:23:36 KODI systemd[1]: telegraf.service: Failed with result ‘exit-code’.
Nov 04 15:23:36 KODI systemd[1]: Failed to start The plugin-driven server agent for reporting metrics into InfluxDB.
We only remove one layer of complexity and try to simplify the debugging
Therefore, just run telegraf on the console (without systemd) and watch the output.
Thanks - you’re correct - telegraf runs with the additional line removed. I can see data in influxdb now.
An annoying simple mistake - as often the case!
It has raised another question for me which is how to make telegraf read all three temperature outputs rather than just the first set. Do I have to specify each element exactly in separate lines of the config?
Many thanks for your time and effort in finding my mistake.
One more question if I may.
If I want read in another xml file from a different temp monitor device - with different tags etc - but to the same influx database do I add another section of [[inputs.http]] to the existing telegraf.conf file - or should I create another conf file ? - or (seems unlikely) do i try and put it all in the same [[inputs.http]] section as I have started already ??