1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
transformer.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
package kibana
import (
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/go-ucfg/yaml"
)
type transformer struct {
entries []kibanaEntry
}
type kibanaEntry struct {
Kibana struct {
SourceFilters []string `config:"source_filters"`
} `config:"kibana"`
}
func newTransformer(entries []kibanaEntry) *transformer {
return &transformer{entries: entries}
}
func (t *transformer) transform() common.MapStr {
transformed := common.MapStr{}
var srcFilters []common.MapStr
for _, entry := range t.entries {
for _, sourceFilter := range entry.Kibana.SourceFilters {
srcFilters = append(srcFilters, common.MapStr{"value": sourceFilter})
}
}
if len(srcFilters) > 0 {
transformed["sourceFilters"] = srcFilters
}
return transformed
}
func loadKibanaEntriesFromYaml(yamlFile string) ([]kibanaEntry, error) {
entries := []kibanaEntry{}
cfg, err := yaml.NewConfigWithFile(yamlFile)
if err != nil {
return nil, err
}
err = cfg.Unpack(&entries)
if err != nil {
return nil, err
}
return entries, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.2.3

搜索帮助