I am trying to set the timezone for an mqtt source which I am parsing with xpath (see below). However, the time written to the underlying postgressl DB (timescale enabled) is always UTC. I have tried using Localhost as well as specific timezones. Am I doing something wrong?
The timezone config option tells telegraf what timezone the timestamps your data has is in. So you are saying my data is in “America/Chicago” and do not to assume it is UTC.
Timestamps read by telegraf are internally stored as unix timestamps. Unix timestamps do not have timezones. So they are all stored to UTC, relative to the timezone you specified. It is more common to see users want to store their timestamps in UTC, and use whatever reporting mechanism to change the timestamp (e.g. grafana).
That said, the postgres output does has an option to specify a field for the timestamp of your data and an option to specify whether it includes a timestamp or not. If you wish to keep the timezone info with your data, then do not not parse the timestamp, and instead store it as a field and use these other mechanisms.
I’m not sure my understanding above is correct. We added an option to specify if the timezone includes a timezone and that is about it. Consider trying that in the postgresql output first.
Hope that helps.
edit: modified my response about the postgresql output