Powershell directly in Telegraf.conf, tag problem[solved]

Windows running Telegraf, report to Influxdb

I have with success been able to run a powershell command directly in telegraf.conf.

My problem is that I have not found a way to add a tag in my command.

My command looks like this
"powershell.exe -NoProfile -Command \"$ChromeCount=(get-process -Name Chrome).Count\";\"write-host \"win_chrome sessions=$ChromeCount\"\""

What I want to do is to use this command
"powershell.exe -NoProfile -Command \"$ChromeCount=(get-process -Name Chrome).Count\";\"write-host \"win_chrome,host=REP01 sessions=$ChromeCount\"\""

When I use the last command I get an error from Telegraf that looks like this
missing timestamp “win_chrome host=REP01 sessions=15”

I understand that timestamp must be the last information if you want to add it otherwise Influxdb will add it.

Why is telegraf removing my comma(,)?
I have tried escape character, u002C but it doesn’t help.

I don’t have powershell to test with but maybe this helps?

1 Like

[quote=“flopp, post:1, topic:6902”]
Thank you. I can confirm that the link was the solution.
I just added a ` and it started to work.

"powershell.exe -NoProfile -Command \"$ChromeCount=(get-process -Name Chrome).Count\";\"write-host \"win_chrome,host=REP01 sessions=$ChromeCount"""`

1 Like