diff --git a/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go b/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go new file mode 100644 index 000000000000..f90b93faf43b --- /dev/null +++ b/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go @@ -0,0 +1,49 @@ +package main + +import ( + "flag" + "fmt" + "os" + + "github.com/elastic/beats/libbeat/kibana" + "github.com/elastic/beats/libbeat/version" +) + +func main() { + beatVersion := version.GetDefaultVersion() + index := flag.String("index", "", "The name of the index pattern. (required)") + beatName := flag.String("beat-name", "", "The name of the beat. (required)") + beatDir := flag.String("beat-dir", "", "The local beat directory. (required)") + version := flag.String("version", beatVersion, "The beat version.") + flag.Parse() + + if *index == "" { + fmt.Fprint(os.Stderr, "The name of the index pattern msut be set.") + os.Exit(1) + } + + if *beatName == "" { + fmt.Fprint(os.Stderr, "The name of the beat must be set.") + os.Exit(1) + } + + if *beatDir == "" { + fmt.Fprint(os.Stderr, "The beat directory must be set.") + os.Exit(1) + } + + indexPatternGenerator, err := kibana.NewGenerator(*index, *beatName, *beatDir, *version) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + + pattern, err := indexPatternGenerator.Generate() + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + for _, p := range pattern { + fmt.Fprintf(os.Stdout, "-- The index pattern was created under %v\n", p) + } +} diff --git a/libbeat/kibana/index.go b/libbeat/kibana/index_pattern_generator.go similarity index 58% rename from libbeat/kibana/index.go rename to libbeat/kibana/index_pattern_generator.go index 68d033e2ef56..7f756709b2ab 100644 --- a/libbeat/kibana/index.go +++ b/libbeat/kibana/index_pattern_generator.go @@ -2,7 +2,6 @@ package kibana import ( "encoding/json" - "errors" "io/ioutil" "os" "path/filepath" @@ -11,43 +10,56 @@ import ( "github.com/elastic/beats/libbeat/common" ) -type Index struct { - Version string - IndexName string - BeatDir string - BeatName string - +type IndexPatternGenerator struct { + indexName string + version string fieldsYaml string targetDirDefault string targetDir5x string targetFilename string } -// Create the Index-Pattern for Kibana for 5.x and default. -func (i *Index) Create() ([]string, error) { - indices := []string{} +// Create an instance of the Kibana Index Pattern Generator +func NewGenerator(indexName, beatName, beatDir, version string) (*IndexPatternGenerator, error) { + beatName = clean(beatName) - err := i.init() - if err != nil { + fieldsYaml := filepath.Join(beatDir, "fields.yml") + if _, err := os.Stat(fieldsYaml); err != nil { return nil, err } + return &IndexPatternGenerator{ + indexName: indexName, + version: version, + fieldsYaml: fieldsYaml, + targetDirDefault: createTargetDir(beatDir, "default"), + targetDir5x: createTargetDir(beatDir, "5.x"), + targetFilename: beatName + ".json", + }, nil +} + +// Create the Index-Pattern for Kibana for 5.x and default. +func (i *IndexPatternGenerator) Generate() ([]string, error) { + var indices []string + commonFields, err := common.LoadFieldsYaml(i.fieldsYaml) if err != nil { return nil, err } - transformed := TransformFields("@timestamp", i.IndexName, commonFields) + transformer := NewTransformer("@timestamp", i.indexName, commonFields) + transformed := transformer.TransformFields() - if fieldsBytes, err := json.Marshal(transformed["fields"]); err != nil { + fieldsBytes, err := json.Marshal(transformed["fields"]) + if err != nil { return nil, err - } else { - transformed["fields"] = string(fieldsBytes) } - if fieldFormatBytes, err := json.Marshal(transformed["fieldFormatMap"]); err != nil { + transformed["fields"] = string(fieldsBytes) + + fieldFormatBytes, err := json.Marshal(transformed["fieldFormatMap"]) + if err != nil { return nil, err - } else { - transformed["fieldFormatMap"] = string(fieldFormatBytes) } + transformed["fieldFormatMap"] = string(fieldFormatBytes) file5x := filepath.Join(i.targetDir5x, i.targetFilename) err = dumpToFile(file5x, transformed) @@ -57,11 +69,11 @@ func (i *Index) Create() ([]string, error) { indices = append(indices, file5x) out := common.MapStr{ - "version": i.Version, + "version": i.version, "objects": []common.MapStr{ common.MapStr{ "type": "index-pattern", - "id": i.IndexName, + "id": i.indexName, "version": 1, "attributes": transformed, }, @@ -77,24 +89,6 @@ func (i *Index) Create() ([]string, error) { return indices, nil } -func (i *Index) init() error { - if i.Version == "" || i.IndexName == "" || i.BeatDir == "" || i.BeatName == "" { - return errors.New("RequiredParams: Version, IndexName, BeatDir and BeatName") - } - i.BeatName = clean(i.BeatName) - - i.fieldsYaml = filepath.Join(i.BeatDir, "fields.yml") - if _, err := os.Stat(i.fieldsYaml); err != nil { - return err - } - - i.targetDirDefault = createTargetDir(i.BeatDir, "default") - i.targetDir5x = createTargetDir(i.BeatDir, "5.x") - i.targetFilename = i.BeatName + ".json" - - return nil -} - func clean(name string) string { reg := regexp.MustCompile("[^a-zA-Z0-9_]+") return reg.ReplaceAllString(name, "") diff --git a/libbeat/kibana/index_test.go b/libbeat/kibana/index_pattern_generator_test.go similarity index 67% rename from libbeat/kibana/index_test.go rename to libbeat/kibana/index_pattern_generator_test.go index faa5b94ba6db..54d26938c528 100644 --- a/libbeat/kibana/index_test.go +++ b/libbeat/kibana/index_pattern_generator_test.go @@ -14,49 +14,32 @@ import ( "github.com/elastic/beats/libbeat/common" ) -func TestAllArgsSet(t *testing.T) { +func TestNewGenerator(t *testing.T) { beatDir := tmpPath() defer teardown(beatDir) - tests := []struct { - Index Index - }{ - {Index: Index{IndexName: "beat-index", BeatDir: beatDir, BeatName: "mybeat."}}, - {Index: Index{Version: "6.0", BeatDir: beatDir, BeatName: "mybeat."}}, - {Index: Index{Version: "6.0", IndexName: "beat-index", BeatName: "mybeat."}}, - {Index: Index{Version: "6.0", IndexName: "beat-index", BeatDir: beatDir}}, - } - for idx, test := range tests { - err := test.Index.init() - msg := fmt.Sprintf("(%v): Should have raised error", idx) - assert.Error(t, err, msg) - } -} - -func TestInit(t *testing.T) { - beatDir := tmpPath() - defer teardown(beatDir) // checks for fields.yml - idx := Index{Version: "7.0", IndexName: "beat-index", BeatDir: filepath.Join(beatDir, "notexistent"), BeatName: "mybeat."} - err := idx.init() + generator, err := NewGenerator("beat-index", "mybeat.", filepath.Join(beatDir, "notexistent"), "7.0") assert.Error(t, err) - idx = Index{Version: "7.0", IndexName: "beat-index", BeatDir: beatDir, BeatName: "mybeat."} - err = idx.init() + generator, err = NewGenerator("beat-index", "mybeat.", beatDir, "7.0") assert.NoError(t, err) + assert.Equal(t, "7.0", generator.version) + assert.Equal(t, "beat-index", generator.indexName) + assert.Equal(t, filepath.Join(beatDir, "fields.yml"), generator.fieldsYaml) // creates file dir and sets name expectedDir := filepath.Join(beatDir, "_meta/kibana/default/index-pattern") - assert.Equal(t, expectedDir, idx.targetDirDefault) - _, err = os.Stat(idx.targetDirDefault) + assert.Equal(t, expectedDir, generator.targetDirDefault) + _, err = os.Stat(generator.targetDirDefault) assert.NoError(t, err) expectedDir = filepath.Join(beatDir, "_meta/kibana/5.x/index-pattern") - assert.Equal(t, expectedDir, idx.targetDir5x) - _, err = os.Stat(idx.targetDir5x) + assert.Equal(t, expectedDir, generator.targetDir5x) + _, err = os.Stat(generator.targetDir5x) assert.NoError(t, err) - assert.Equal(t, "mybeat.json", idx.targetFilename) + assert.Equal(t, "mybeat.json", generator.targetFilename) } func TestCleanName(t *testing.T) { @@ -75,12 +58,49 @@ func TestCleanName(t *testing.T) { } } -func TestDefault(t *testing.T) { +func TestGenerateFieldsYaml(t *testing.T) { + beatDir := tmpPath() + defer teardown(beatDir) + generator, err := NewGenerator("metricbeat-*", "metric beat ?!", beatDir, "7.0.0-alpha1") + _, err = generator.Generate() + assert.NoError(t, err) + + generator.fieldsYaml = "" + _, err = generator.Generate() + assert.Error(t, err) +} + +func TestDumpToFile5x(t *testing.T) { beatDir := tmpPath() defer teardown(beatDir) + generator, err := NewGenerator("metricbeat-*", "metric beat ?!", beatDir, "7.0.0-alpha1") + _, err = generator.Generate() + assert.NoError(t, err) + + generator.targetDir5x = "./non-existing/something" + _, err = generator.Generate() + assert.Error(t, err) +} - index := Index{Version: "7.0.0-alpha1", IndexName: "metricbeat-*", BeatDir: beatDir, BeatName: "metric beat !"} - index.Create() +func TestDumpToFileDefault(t *testing.T) { + beatDir := tmpPath() + defer teardown(beatDir) + generator, err := NewGenerator("metricbeat-*", "metric beat ?!", beatDir, "7.0.0-alpha1") + _, err = generator.Generate() + assert.NoError(t, err) + + generator.targetDirDefault = "./non-existing/something" + _, err = generator.Generate() + assert.Error(t, err) +} + +func TestGenerate(t *testing.T) { + beatDir := tmpPath() + defer teardown(beatDir) + generator, err := NewGenerator("metricbeat-*", "metric beat ?!", beatDir, "7.0.0-alpha1") + pattern, err := generator.Generate() + assert.NoError(t, err) + assert.Equal(t, 2, len(pattern)) tests := []map[string]string{ {"existing": "metricbeat-5x-old.json", "created": "_meta/kibana/5.x/index-pattern/metricbeat.json"}, diff --git a/libbeat/kibana/transform.go b/libbeat/kibana/transform.go index 46938294cd10..68adb50af58f 100644 --- a/libbeat/kibana/transform.go +++ b/libbeat/kibana/transform.go @@ -7,46 +7,62 @@ import ( "github.com/elastic/beats/libbeat/common" ) -func TransformFields(timeFieldName string, title string, commonFields common.Fields) common.MapStr { - fields := []common.MapStr{} - fieldFormatMap := common.MapStr{} - keys := common.MapStr{} +type Transformer struct { + fields common.Fields + transformedFields []common.MapStr + transformedFieldFormatMap common.MapStr + timeFieldName string + title string + keys common.MapStr +} + +func NewTransformer(timeFieldName, title string, fields common.Fields) *Transformer { + return &Transformer{ + fields: fields, + timeFieldName: timeFieldName, + title: title, + transformedFields: []common.MapStr{}, + transformedFieldFormatMap: common.MapStr{}, + keys: common.MapStr{}, + } +} - transformFields(keys, commonFields, &fields, fieldFormatMap, "") +func (t *Transformer) TransformFields() common.MapStr { + t.transformFields(t.fields, "") // add some meta fields truthy := true falsy := false - add(common.Field{Path: "_id", Type: "keyword", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &falsy, Aggregatable: &falsy}, &fields, fieldFormatMap) - add(common.Field{Path: "_type", Type: "keyword", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &truthy, Aggregatable: &truthy}, &fields, fieldFormatMap) - add(common.Field{Path: "_index", Type: "keyword", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &falsy, Aggregatable: &falsy}, &fields, fieldFormatMap) - add(common.Field{Path: "_score", Type: "integer", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &falsy, Aggregatable: &falsy}, &fields, fieldFormatMap) + t.add(common.Field{Path: "_id", Type: "keyword", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &falsy, Aggregatable: &falsy}) + t.add(common.Field{Path: "_type", Type: "keyword", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &truthy, Aggregatable: &truthy}) + t.add(common.Field{Path: "_index", Type: "keyword", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &falsy, Aggregatable: &falsy}) + t.add(common.Field{Path: "_score", Type: "integer", Index: &falsy, Analyzed: &falsy, DocValues: &falsy, Searchable: &falsy, Aggregatable: &falsy}) return common.MapStr{ - "timeFieldName": timeFieldName, - "title": title, - "fields": fields, - "fieldFormatMap": fieldFormatMap, + "timeFieldName": t.timeFieldName, + "title": t.title, + "fields": t.transformedFields, + "fieldFormatMap": t.transformedFieldFormatMap, } } -func transformFields(keys common.MapStr, commonFields common.Fields, fields *[]common.MapStr, fieldFormatMap common.MapStr, path string) { +func (t *Transformer) transformFields(commonFields common.Fields, path string) { for _, f := range commonFields { f.Path = f.Name if path != "" { f.Path = path + "." + f.Name } - if keys[f.Path] != nil { + if t.keys[f.Path] != nil { msg := fmt.Sprintf("ERROR: Field <%s> is duplicated. Please update and try again.", f.Path) panic(errors.New(msg)) } if f.Type == "group" { - transformFields(keys, f.Fields, fields, fieldFormatMap, f.Path) + t.transformFields(f.Fields, f.Path) } else { // set default values (as done in python script) - keys[f.Path] = true + t.keys[f.Path] = true truthy := true falsy := false @@ -55,16 +71,16 @@ func transformFields(keys common.MapStr, commonFields common.Fields, fields *[]c f.DocValues = &truthy f.Searchable = &truthy f.Aggregatable = &truthy - add(f, fields, fieldFormatMap) + t.add(f) } } } -func add(f common.Field, fields *[]common.MapStr, fieldFormatMap common.MapStr) { +func (t *Transformer) add(f common.Field) { field, fieldFormat := transformField(f) - *fields = append(*fields, field) + t.transformedFields = append(t.transformedFields, field) if fieldFormat != nil { - fieldFormatMap[field["name"].(string)] = fieldFormat + t.transformedFieldFormatMap[field["name"].(string)] = fieldFormat } } diff --git a/libbeat/kibana/transform_test.go b/libbeat/kibana/transform_test.go index 0f5f58b0ec64..7718a0aaa784 100644 --- a/libbeat/kibana/transform_test.go +++ b/libbeat/kibana/transform_test.go @@ -16,7 +16,8 @@ var ( ) func TestEmpty(t *testing.T) { - out := TransformFields("name", "title", common.Fields{}) + trans := NewTransformer("name", "title", common.Fields{}) + out := trans.TransformFields() expected := common.MapStr{ "timeFieldName": "name", "title": "title", @@ -76,7 +77,8 @@ func TestErrors(t *testing.T) { common.Field{Name: "context", Path: "something"}, common.Field{Name: "context", Path: "something", Type: "keyword"}, } - assert.Panics(t, func() { TransformFields("", "", commonFields) }) + trans := NewTransformer("name", "title", commonFields) + assert.Panics(t, func() { trans.TransformFields() }) } func TestTransformTypes(t *testing.T) { @@ -100,7 +102,8 @@ func TestTransformTypes(t *testing.T) { {commonField: common.Field{Type: "invalid"}, expected: nil}, } for idx, test := range tests { - out := TransformFields("", "", common.Fields{test.commonField})["fields"].([]common.MapStr)[0] + trans := NewTransformer("name", "title", common.Fields{test.commonField}) + out := trans.TransformFields()["fields"].([]common.MapStr)[0] assert.Equal(t, test.expected, out["type"], fmt.Sprintf("Failed for idx %v", idx)) } } @@ -142,7 +145,8 @@ func TestTransformGroup(t *testing.T) { }, } for idx, test := range tests { - out := TransformFields("", "", test.commonFields)["fields"].([]common.MapStr) + trans := NewTransformer("name", "title", test.commonFields) + out := trans.TransformFields()["fields"].([]common.MapStr) assert.Equal(t, len(test.expected)+ctMetaData, len(out)) for i, e := range test.expected { assert.Equal(t, e, out[i]["name"], fmt.Sprintf("Failed for idx %v", idx)) @@ -190,13 +194,14 @@ func TestTransformMisc(t *testing.T) { {commonField: common.Field{}, expected: false, attr: "scripted"}, } for idx, test := range tests { - out := TransformFields("", "", common.Fields{test.commonField})["fields"].([]common.MapStr)[0] + trans := NewTransformer("", "", common.Fields{test.commonField}) + out := trans.TransformFields()["fields"].([]common.MapStr)[0] msg := fmt.Sprintf("(%v): expected '%s' to be <%v> but was <%v>", idx, test.attr, test.expected, out[test.attr]) assert.Equal(t, test.expected, out[test.attr], msg) } } -func TestTransformFielFormatMap(t *testing.T) { +func TestTransformFieldFormatMap(t *testing.T) { tests := []struct { commonField common.Field expected common.MapStr @@ -273,7 +278,8 @@ func TestTransformFielFormatMap(t *testing.T) { }, } for idx, test := range tests { - out := TransformFields("", "", common.Fields{test.commonField})["fieldFormatMap"] + trans := NewTransformer("", "", common.Fields{test.commonField}) + out := trans.TransformFields()["fieldFormatMap"] assert.Equal(t, test.expected, out, fmt.Sprintf("Failed for idx %v", idx)) } } diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index f550b23863c7..0677719b5b35 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -293,7 +293,7 @@ endif @# Generate Kibana index pattern @mkdir -p $(PWD)/_meta/kibana/5.x/index-pattern @mkdir -p $(PWD)/_meta/kibana/default/index-pattern - go run -v ${ES_BEATS}/libbeat/scripts/generate_index_pattern.go '${BEAT_INDEX_PREFIX}-*' ${BEAT_NAME} $(PWD) ${BEAT_VERSION} + @go run ${ES_BEATS}/dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go -index '${BEAT_INDEX_PREFIX}-*' -beat-name ${BEAT_NAME} -beat-dir $(PWD) -version ${BEAT_VERSION} # Runs the post-update target if it exists. Will not return errors @-$(MAKE) post-update diff --git a/libbeat/scripts/generate_index_pattern.go b/libbeat/scripts/generate_index_pattern.go deleted file mode 100644 index 66ae0cc05333..000000000000 --- a/libbeat/scripts/generate_index_pattern.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/elastic/beats/libbeat/kibana" -) - -func main() { - index := kibana.Index{ - IndexName: os.Args[1], - BeatDir: os.Args[3], - BeatName: os.Args[2], - Version: os.Args[4], - } - indices, err := index.Create() - if err != nil { - panic(err) - } - for _, i := range indices { - fmt.Println("-- The index pattern was created under ", i) - } -} diff --git a/libbeat/scripts/generate_index_pattern.py b/libbeat/scripts/generate_index_pattern.py deleted file mode 100644 index 890ba07af175..000000000000 --- a/libbeat/scripts/generate_index_pattern.py +++ /dev/null @@ -1,205 +0,0 @@ -#!/usr/bin/env python - -""" -This script generates the index-pattern for Kibana from -the fields.yml file. -""" - -import yaml -import argparse -import string -import re -import json -import os -import errno -import sys - -unique_fields = [] - - -def fields_to_json(fields, section, path, output): - - # Need in case there are no fields - if section["fields"] is None: - section["fields"] = {} - - for field in section["fields"]: - if path == "": - newpath = field["name"] - else: - newpath = path + "." + field["name"] - - if "type" in field and field["type"] == "group": - fields_to_json(fields, field, newpath, output) - else: - field_to_json(fields, field, newpath, output) - - -def field_to_json(fields, desc, path, output, - indexed=True, analyzed=False, doc_values=True, - searchable=True, aggregatable=True): - - if path in unique_fields: - print("ERROR: Field {} is duplicated. Please delete it and try again. Fields already are {}".format( - path, ", ".join(fields))) - sys.exit(1) - else: - fields.append(path) - - field = { - "name": path, - "count": 0, - "scripted": False, - "indexed": indexed, - "analyzed": analyzed, - "doc_values": doc_values, - "searchable": searchable, - "aggregatable": aggregatable, - } - # find the kibana types based on the field type - if "type" in desc: - if desc["type"] in ["half_float", "scaled_float", "float", "integer", "long", "short", "byte"]: - field["type"] = "number" - elif desc["type"] in ["text", "keyword"]: - field["type"] = "string" - if desc["type"] == "text": - field["aggregatable"] = False - elif desc["type"] == "date": - field["type"] = "date" - elif desc["type"] == "geo_point": - field["type"] = "geo_point" - else: - field["type"] = "string" - - output["fields"].append(field) - - if "format" in desc or "pattern" in desc: - fieldFormat = {} - - if "format" in desc: - fieldFormat["id"] = desc["format"] - - if "input_format" in desc: - fieldFormat["params"] = { - "inputFormat": desc["input_format"] - } - - if "pattern" in desc: - fieldFormat["params"] = { - "pattern": desc["pattern"] - } - - output["fieldFormatMap"][path] = fieldFormat - - -def fields_to_index_pattern(version, args, input): - - docs = yaml.load(input) - fields = [] - - if docs is None: - print("fields.yml is empty. Cannot generate index-pattern") - return - - attributes = { - "fields": [], - "fieldFormatMap": {}, - "timeFieldName": "@timestamp", - "title": args.index, - - } - - for k, section in enumerate(docs): - fields_to_json(fields, section, "", attributes) - - # add meta fields - - field_to_json(fields, {"name": "_id", "type": "keyword"}, "_id", - attributes, - indexed=False, analyzed=False, doc_values=False, - searchable=False, aggregatable=False) - - field_to_json(fields, {"name": "_type", "type": "keyword"}, "_type", - attributes, - indexed=False, analyzed=False, doc_values=False, - searchable=True, aggregatable=True) - - field_to_json(fields, {"name": "_index", "type": "keyword"}, "_index", - attributes, - indexed=False, analyzed=False, doc_values=False, - searchable=False, aggregatable=False) - - field_to_json(fields, {"name": "_score", "type": "integer"}, "_score", - attributes, - indexed=False, analyzed=False, doc_values=False, - searchable=False, aggregatable=False) - - attributes["fields"] = json.dumps(attributes["fields"]) - attributes["fieldFormatMap"] = json.dumps(attributes["fieldFormatMap"]) - - if version == "5.x": - return attributes - - return { - "version": args.version, - "objects": [{ - "type": "index-pattern", - "id": args.index, - "version": 1, - "attributes": attributes, - }] - - - } - - -def get_index_pattern_name(index): - - allow = string.ascii_letters + string.digits + "_" - return re.sub('[^%s]' % allow, '', index) - - -def dump_index_pattern(args, version, output): - - fileName = get_index_pattern_name(args.beat_name) - target_dir = os.path.join(args.beat, "_meta", "kibana", version, "index-pattern") - target_file = os.path.join(target_dir, fileName + ".json") - - try: - os.makedirs(target_dir) - except OSError as exception: - if exception.errno != errno.EEXIST: - raise - - output = json.dumps(output, indent=2) - - with open(target_file, 'w') as f: - f.write(output) - - print("The index pattern was created under {}".format(target_file)) - return target_file - - -if __name__ == "__main__": - - parser = argparse.ArgumentParser( - description="Generates the index-pattern for a Beat.") - parser.add_argument("--version", help="Beat version") - parser.add_argument("--index", help="The name of the index-pattern") - parser.add_argument("--beat", help="Local Beat directory") - parser.add_argument("--beat-name", help="Name of the beat") - - args = parser.parse_args() - - fields_yml = args.beat + "/fields.yml" - - # generate the index-pattern content - with open(fields_yml, 'r') as f: - fields = f.read() - - # with open(target, 'w') as output: - output = fields_to_index_pattern("default", args, fields) - dump_index_pattern(args, "default", output) - - output5x = fields_to_index_pattern("5.x", args, fields) - dump_index_pattern(args, "5.x", output5x)