diff --git a/libbeat/_meta/fields.common.yml b/libbeat/_meta/fields.common.yml index bb9c7ac84c5..81a5972d164 100644 --- a/libbeat/_meta/fields.common.yml +++ b/libbeat/_meta/fields.common.yml @@ -1,11 +1,4 @@ -defaults: - type: keyword - required: false - index: true - doc_values: true - ignore_above: 1024 -fields: - key: beat title: Beat description: > diff --git a/libbeat/scripts/generate_fields_docs.py b/libbeat/scripts/generate_fields_docs.py index e3635296a15..bfa11e77bd0 100644 --- a/libbeat/scripts/generate_fields_docs.py +++ b/libbeat/scripts/generate_fields_docs.py @@ -84,7 +84,7 @@ def fields_to_asciidoc(input, output, beat): # Create sections from available fields sections = {} - for v in docs["fields"]: + for v in docs: sections[v["key"]] = v["title"] for key in sorted(sections): @@ -92,7 +92,7 @@ def fields_to_asciidoc(input, output, beat): output.write("\n--\n") # Sort alphabetically by key - for section in sorted(docs["fields"], key=lambda field: field["key"]): + for section in sorted(docs, key=lambda field: field["key"]): section["name"] = section["title"] section["anchor"] = section["key"] document_fields(output, section, sections, "") diff --git a/libbeat/scripts/generate_index_pattern.py b/libbeat/scripts/generate_index_pattern.py index 2e748f35cb1..95408180597 100644 --- a/libbeat/scripts/generate_index_pattern.py +++ b/libbeat/scripts/generate_index_pattern.py @@ -97,7 +97,7 @@ def fields_to_index_pattern(args, input): } - for k, section in enumerate(docs["fields"]): + for k, section in enumerate(docs): fields_to_json(section, "", output) # add meta fields @@ -149,9 +149,10 @@ def get_index_pattern_name(index): with open(fields_yml, 'r') as f: fields = f.read() - # Prepend beat fields from libbeat - with open(args.libbeat + "/_meta/fields.generated.yml") as f: - fields = f.read() + fields + if os.path.basename(args.beat) != "libbeat": + # Prepend beat fields from libbeat + with open(args.libbeat + "/_meta/fields.generated.yml") as f: + fields = f.read() + fields # with open(target, 'w') as output: output = fields_to_index_pattern(args, fields) diff --git a/libbeat/scripts/generate_template.py b/libbeat/scripts/generate_template.py index a27543a327a..be18e51ebca 100644 --- a/libbeat/scripts/generate_template.py +++ b/libbeat/scripts/generate_template.py @@ -30,16 +30,16 @@ def fields_to_es_template(args, input, output, index, version): print("fields.yml is empty. Cannot generate template.") return - # Each template needs defaults - if "defaults" not in docs.keys(): - print("No defaults are defined. Each template needs at" + - " least defaults defined.") - return - - defaults = docs["defaults"] + defaults = { + "type": "keyword", + "required": False, + "index": True, + "doc_values": True, + "ignore_above": 1024, + } - for k, section in enumerate(docs["fields"]): - docs["fields"][k] = dedot(section) + for k, section in enumerate(docs): + docs[k] = dedot(section) # skeleton template = { @@ -105,9 +105,8 @@ def fields_to_es_template(args, input, output, index, version): } }) - for section in docs["fields"]: - prop, dynamic = fill_section_properties(args, section, - defaults, "") + for section in docs: + prop, dynamic = fill_section_properties(args, section, defaults, "") properties.update(prop) dynamic_templates.extend(dynamic) diff --git a/libbeat/tests/system/beat/beat.py b/libbeat/tests/system/beat/beat.py index d3aba834c74..74822f9660c 100644 --- a/libbeat/tests/system/beat/beat.py +++ b/libbeat/tests/system/beat/beat.py @@ -429,7 +429,7 @@ def extract_fields(doc_list, name): fields = [] dictfields = [] - for item in doc["fields"]: + for item in doc: subfields, subdictfields = extract_fields(item["fields"], "") fields.extend(subfields) dictfields.extend(subdictfields)