-
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
Template setting in the configuration file #4284
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,11 @@ type Template struct { | |
index string | ||
beatVersion Version | ||
esVersion Version | ||
settings common.MapStr | ||
} | ||
|
||
// New creates a new template instance | ||
func New(beatVersion string, esVersion string, index string) (*Template, error) { | ||
func New(beatVersion string, esVersion string, index string, settings common.MapStr) (*Template, error) { | ||
|
||
bV, err := NewVersion(beatVersion) | ||
if err != nil { | ||
|
@@ -44,6 +45,7 @@ func New(beatVersion string, esVersion string, index string) (*Template, error) | |
index: index, | ||
beatVersion: *bV, | ||
esVersion: *esV, | ||
settings: settings, | ||
}, nil | ||
|
||
} | ||
|
@@ -90,6 +92,18 @@ func (t *Template) generate(properties common.MapStr, dynamicTemplates []common. | |
|
||
dynamicTemplates = append(dynamicTemplates, dynamicTemplateBase) | ||
|
||
settings := common.MapStr{ | ||
"index": common.MapStr{ | ||
"refresh_interval": "5s", | ||
"mapping": common.MapStr{ | ||
"total_fields": common.MapStr{ | ||
"limit": defaultTotalFieldsLimit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work on all ES versions down to 2.x? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think ES 2.x will just ignore the setting, but I'm going to test it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just tested, seems to work well. |
||
}, | ||
}, | ||
}, | ||
} | ||
settings.DeepUpdate(t.settings) | ||
|
||
// Load basic structure | ||
basicStructure := common.MapStr{ | ||
"mappings": common.MapStr{ | ||
|
@@ -102,10 +116,8 @@ func (t *Template) generate(properties common.MapStr, dynamicTemplates []common. | |
"properties": properties, | ||
}, | ||
}, | ||
"order": 1, | ||
"settings": common.MapStr{ | ||
"index.refresh_interval": "5s", | ||
}, | ||
"order": 1, | ||
"settings": settings, | ||
} | ||
|
||
// ES 6 moved from template to index_patterns: https://github.com/elastic/elasticsearch/pull/21009 | ||
|
@@ -119,11 +131,6 @@ func (t *Template) generate(properties common.MapStr, dynamicTemplates []common. | |
basicStructure.Put("mappings._default_._all.norms.enabled", false) | ||
} | ||
|
||
if t.esVersion.major >= 5 { | ||
// Metricbeat exceeds the default of 1000 fields | ||
basicStructure.Put("settings.index.mapping.total_fields.limit", defaultTotalFieldsLimit) | ||
} | ||
|
||
return basicStructure | ||
} | ||
|
||
|
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.
+1 on using a "generic" approach