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

Add support for numeric time zone offsets in timestamp processor #13902

Merged
merged 2 commits into from
Oct 4, 2019

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Oct 3, 2019

The ingest node date processor supports numeric time zone offsets,
and the add_locale Beat processor adds the numeric timezone in numeric
formats. Add support for these formats to the timestamp processor for
consistency with the other processors.

This is needed in #13893, where a javascript pipeline needs the timezone
set by the add_locale processor to generate the timestamp using the
timestamp processor.

The ingest node `date` processor support numeric time zone offsets,
and the `add_locale` Beat processor adds the numeric timezone in numeric
formats. Add support for these formats to the timestamp processor for
consistency with the other processors.
@@ -84,6 +84,20 @@ func newFromConfig(c config) (*processor, error) {
return p, nil
}

func loadLocation(timezone string) (*time.Location, error) {
timezoneFormats := []string{"-07", "-0700", "-07:00"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should timezoneFormats here be a global variable? (No need to change it if you prefer this.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we support Z0700 Z07:00 as well? I was reading https://yourbasic.org/golang/format-parse-string-time-date-example/ to see what are the offset/timezone format there are.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this format in the Go documentation, I think this is only useful in complete timestamps to format times with numeric zero timezones (UTC) as Z, or to parse Z as zero timestamps.

In our case here we are not parsing complete timestamps, but only timezones, that come from configuration. We could use these formats to support Z as a valid value for the timezone setting (as timezone: 'Z'), but I am not sure if we want to do that, specially when there are more usual alternatives that will work, as timezone: 'Etc/UTC', or timezone: '+0000'.

@jsoriano
Copy link
Member Author

jsoriano commented Oct 3, 2019

@kaiyan-sheng timezoneFormats is now a global variable and I have added some error cases to the test.

Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me.

@jsoriano
Copy link
Member Author

jsoriano commented Oct 4, 2019

jenkins, test this again please

@jsoriano jsoriano merged commit babb862 into elastic:master Oct 4, 2019
@jsoriano jsoriano deleted the timestamp-processor-timezone branch October 4, 2019 16:41
@urso urso added the v7.5.0 label Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants