-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align kibana index generation to beats standard. (#5290)
* Move generator script to dev-tools. * Add NewGenerator method which returns struct instead of init method.
- Loading branch information
Showing
8 changed files
with
184 additions
and
328 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
dev-tools/cmd/kibana_index_pattern/kibana_index_pattern.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.