Inputs.http xml.xpath not working in metric_name

Hi, I am trying to change metric_name
( telegraf/plugins/parsers/xpath at master · influxdata/telegraf · GitHub )

This is somehow not working :frowning: … I would like to change metric_name (to be dropped later) in case, there is some attribute status=false instead of attribute status=true at root element…

[[inputs.http.xpath]]
metric_name = “concat( substring( ‘validname’, 1, number(wario/@status = ‘true’) * 9), substring( ‘validname_error’, 1, ( 1 - number(wario/@status = ‘true’)) * 15))”

What is wrong with this query? My metric name ends like “validnamevalidname_error” :-/

Hello @JanPono,
Welcome!
Can you please share the errors you’re getting? Also set debug=true in the agent portion of your config.
Finally what are you getting as your line protocol output?
you can use the --test flag to see if looks right and can you please share it here?

Finally, this blog might be useful:

can you provide sample data?
I’m not sure that’s the best way to build an if statement, there are other ways to alter the data inside telegraf but it all depends on the data you have

1 Like