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 special fields in the index pattern #3282

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]

*Affecting all Beats*

- Add `_id`, `_type`, `_index` and `_score` fields in the generated index pattern. {pull}3282}[3282]

*Metricbeat*

- Fix service times-out at startup. {pull}3056[3056]
Expand Down
13 changes: 13 additions & 0 deletions libbeat/scripts/generate_index_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

unique_fields = []


def fields_to_json(section, path, output):

for field in section["fields"]:
Expand Down Expand Up @@ -92,6 +93,18 @@ def fields_to_index_pattern(args, input):
for k, section in enumerate(docs["fields"]):
fields_to_json(section, "", output)

# add special fields
special_fields = {
"fields": [
{"name": "_index", "type": "text"},
{"name": "_id", "type": "text"},
{"name": "_type", "type": "text"},
{"name": "_score", "type": "integer"}
],
}

fields_to_json(special_fields, "", output)

output["fields"] = json.dumps(output["fields"])
output["fieldFormatMap"] = json.dumps(output["fieldFormatMap"])
return output
Expand Down