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

Use local timezone for TZ conversion in the FB system module #5647

Merged
merged 6 commits into from
Nov 21, 2017

Conversation

tsg
Copy link
Contributor

@tsg tsg commented Nov 20, 2017

This adds a convert_timezone fileset parameter that, when enabled,
does two things:

  • Uses the add_locale processor in the FB proespector config
  • Uses {{ beat.timezone }} as the timezone parameter for the
    date processor in the Ingest Node pipeline. This parameter accepts
    templates starting with ES 6.1.

For the moment the convert_timezone flag is off by default, to keep
backwards compatibility.

If ES is < 6.1, the flag is automatically considered off when creating the pipeline
(but the add_locale processor is still used).

Closes #3898.

For now this is only applied to the system module, but likely more
modules would benefit from this feature.

Todos:

  • Automatically disable the flag in case of ES < 6.1
  • Add the flag to the auth fileset as well
  • Tests
  • Document the new flag + Changelog

This adds a `convert_timezone` fileset parameter that, when enabled,
does two things:

* Uses the `add_locale` processor in the FB proespector config
* Uses `{{ beat.timezone }}` as the `timezone` parameter for the
  date processor in the Ingest Node pipeline. This parameter accepts
  templates starting with ES 6.1.

For the moment the `convert_timezone` flag is off by default, to keep
backwards compatibility and because it results in an error when used
with ES < 6.1.

Closes elastic#3898.

For now this is only applied to the system module, but likely more
modules would benefit from this feature.
@tsg tsg added Filebeat Filebeat in progress Pull request is currently in progress. review labels Nov 20, 2017
if err != nil {
return "", fmt.Errorf("Error expanding vars on the ingest pipeline path: %v", err)
}

return formatPipelineID(fs.mcfg.Module, fs.name, path, beatVersion), nil
}

func (fs *Fileset) GetPipeline() (pipelineID string, content map[string]interface{}, err error) {
path, err := applyTemplate(fs.vars, fs.manifest.IngestPipeline)
func (fs *Fileset) GetPipeline(esVersion string) (pipelineID string, content map[string]interface{}, err error) {

Choose a reason for hiding this comment

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

exported method Fileset.GetPipeline should have comment or be unexported

@tsg tsg removed the in progress Pull request is currently in progress. label Nov 20, 2017
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM. Left a few minor comments about log messages. Consider testing out my nonewlines tool on the package 😄 .

var exists bool
name, exists := vals["name"].(string)
if !exists {
return nil, fmt.Errorf("Variable doesn't have a string 'name' key")
Copy link
Member

@andrewkroh andrewkroh Nov 21, 2017

Choose a reason for hiding this comment

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

Not sure it matters, but !exists in this case is telling you that either "name" does not exist or name is not a string. And so maybe calling the variable ok would be better since it allows more ambiguity.

Same comment for the other locations where the type assertion and map lookup signals are coalesced.

return vars, fmt.Errorf("Error parsing version %s: %v", minESVersion["version"].(string), err)
}

logp.Debug("fileset", "Comparing ES version %s with %s", haveVersion, minVersion)
Copy link
Member

Choose a reason for hiding this comment

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

I suggest "Comparing ES version %s with requirement of %s" to make the meaning of the two versions more clear.

@@ -155,18 +161,58 @@ func (fs *Fileset) evaluateVars() (map[string]interface{}, error) {
return vars, nil
}

// turnOffElasticsearchVars re-evaluates the variables that have `min_elasticsearch_version`
// set.
func (fs *Fileset) turnOffElasticsearchVars(vars map[string]interface{}, esVersion string) (map[string]interface{}, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice feature.

@tsg tsg added the v6.1.0 label Nov 21, 2017
@monicasarbu monicasarbu merged commit e125cf1 into elastic:master Nov 21, 2017
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.

4 participants