Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegraf/golang does not parse timezone correctly from timestamp #12960

Closed
Hipska opened this issue Mar 27, 2023 · 1 comment · Fixed by #13363
Closed

Telegraf/golang does not parse timezone correctly from timestamp #12960

Hipska opened this issue Mar 27, 2023 · 1 comment · Fixed by #13363
Assignees
Labels
bug unexpected problem or unintended behavior plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins pm/core capability Feature requests that impact and improve core Telegraf

Comments

@Hipska
Copy link
Contributor

Hipska commented Mar 27, 2023

Relevant telegraf.conf

## The column to extract time information for the metric
  ## `csv_timestamp_format` must be specified if this is used.
  ## Will not be included as field in metric.
  csv_timestamp_column = "Timestamp"

  ## The format of time data extracted from `csv_timestamp_column`
  ## this must be specified if `csv_timestamp_column` is specified
  csv_timestamp_format = "2006-01-02 15:04:05 MST"

  ## The timezone of time data extracted from `csv_timestamp_column`
  ## in case of there is no timezone information.
  ## It follows the  IANA Time Zone database.
  csv_timezone = "Local"

Logs from Telegraf

N/A

System info

Telegraf 1.26

Docker

No response

Steps to reproduce

TBD

Expected behavior

Telegraf to parse the timestamp in the correct timezone.

Actual behavior

Metric timestamp has incorrect offset.

Additional info

Golang-nuts conversation: Parsing time with timezones seem to fail

Workaround seems to be like this:

stamp, _ := time.Parse(layout, v)
loc, _ := time.LoadLocation(stamp.Location().String())
stamp, _ = time.ParseInLocation(layout, v, loc)
@Hipska Hipska added bug unexpected problem or unintended behavior pm/core capability Feature requests that impact and improve core Telegraf plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins labels Mar 27, 2023
@powersj
Copy link
Contributor

powersj commented Mar 28, 2023

Is the next step to update calls of time.Parse to check if stamp.Location() is not empty and in turn call ParseInLocation()? Is this needed for all plugins inputs and parsers a like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins pm/core capability Feature requests that impact and improve core Telegraf
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants