1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
kibana_index_pattern.go 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"flag"
"fmt"
"os"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/kibana"
"github.com/elastic/beats/libbeat/version"
)
func main() {
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)")
beatVersion := flag.String("version", version.GetDefaultVersion(), "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)
}
version5, _ := common.NewVersion("5.0.0")
version6, _ := common.NewVersion("6.0.0")
versions := []*common.Version{version5, version6}
for _, version := range versions {
indexPatternGenerator, err := kibana.NewGenerator(*index, *beatName, *beatDir, *beatVersion, *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)
}
fmt.Fprintf(os.Stdout, "-- The index pattern was created under %v\n", pattern)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v6.2.3

搜索帮助

0d507c66 1850385 C8b1a773 1850385