Skip to content

Commit

Permalink
Add special fields in the index pattern (#3282)
Browse files Browse the repository at this point in the history
monicasarbu authored and ruflin committed Jan 4, 2017
1 parent 5b973a0 commit c8b76ca
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
@@ -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]
13 changes: 13 additions & 0 deletions libbeat/scripts/generate_index_pattern.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@

unique_fields = []


def fields_to_json(section, path, output):

for field in section["fields"]:
@@ -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

0 comments on commit c8b76ca

Please sign in to comment.