-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
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.
filebeat/fileset/fileset.go
Outdated
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this 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 😄 .
filebeat/fileset/fileset.go
Outdated
var exists bool | ||
name, exists := vals["name"].(string) | ||
if !exists { | ||
return nil, fmt.Errorf("Variable doesn't have a string 'name' key") |
There was a problem hiding this comment.
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.
filebeat/fileset/fileset.go
Outdated
return vars, fmt.Errorf("Error parsing version %s: %v", minESVersion["version"].(string), err) | ||
} | ||
|
||
logp.Debug("fileset", "Comparing ES version %s with %s", haveVersion, minVersion) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature.
This adds a
convert_timezone
fileset parameter that, when enabled,does two things:
add_locale
processor in the FB proespector config{{ beat.timezone }}
as thetimezone
parameter for thedate 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 keepbackwards 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: