diff --git a/elk.yaml.template b/elk.yaml.template index c1dd4cfaa10ad4db7273ebe8586e1d4de41ada9b..aaa0623127aabec026a3a45a46270466f352e466 100644 --- a/elk.yaml.template +++ b/elk.yaml.template @@ -1,23 +1,45 @@ +#------------------------------- topo server ------------------------------- elk: +# https_enabled: false - public_certificate: "" - private_key: "" - addr: "localhost:9993" + cert_file: "" + key_file: "" +# +# 插件服务端服务器监听地址 + server_listen_addr: "0.0.0.0:9993" +# +# 远程客户端与插件服务端建立连接时插件的地址 + server_target_addr: "192.168.75.133:9993" +# +#------------------------------- log ------------------------------- log: +# level: debug - driver: file # 可选stdout和file。stdout:输出到终端控制台;file:输出到path下的指定文件。 +# +# 可选stdout和file。stdout:输出到终端控制台;file:输出到path下的指定文件。 + driver: file +# path: /opt/PilotGo/plugin/elk/log/elk.log max_file: 1 max_size: 10485760 +# +#------------------------------- elasticsearch ------------------------------- elasticsearch: +# https_enabled: false addr: "localhost:9200" username: "" password: "" -logstash: - http_addr: "localhost:9600" +# +#------------------------------- kibana ------------------------------- kibana: +# https_enabled: false addr: "localhost:5601" username: "" password: "" +# +#------------------------------- logstash(暂不使用) ------------------------------- +logstash: +# + http_addr: "localhost:9600" \ No newline at end of file diff --git a/server/conf/meta.go b/server/conf/meta.go index 33b8ae94f4bcf90f4d114706d04933bdf24805d5..7a0ee64083b965df3ab280d80cf43cd747da5f5c 100644 --- a/server/conf/meta.go +++ b/server/conf/meta.go @@ -2,9 +2,10 @@ package conf type ElkConf struct { Https_enabled bool `yaml:"https_enabled"` - Public_certificate string `yaml:"public_certificate"` - Private_key string `yaml:"private_key"` - Addr string `yaml:"addr"` + Public_certificate string `yaml:"cert_file"` + Private_key string `yaml:"key_file"` + Addr string `yaml:"server_listen_addr"` + Addr_target string `yaml:"server_target_addr"` } type ElasticConf struct { diff --git a/server/pluginclient/meta.go b/server/pluginclient/meta.go index a0ed165793d2091f3d18c117993b0d7be99dda7a..43e9c3717a9c60cb6a0be8f917f2cbf67b198e43 100644 --- a/server/pluginclient/meta.go +++ b/server/pluginclient/meta.go @@ -10,6 +10,6 @@ var PluginInfo = &client.PluginInfo{ Description: "connect PilotGo and elk", Author: "wangjunqi", Email: "wangjunqi@kylinos.cn", - Url: "http://localhost:9993", + Url: "", // 客户端访问插件服务端的地址 PluginType: "micro-app", } diff --git a/server/pluginclient/pluginClient.go b/server/pluginclient/pluginClient.go index aa731e8392fa23e763a47ec04f46541721fe8936..8bc5836c70d4ffb966509eeaf0a603115e948aca 100644 --- a/server/pluginclient/pluginClient.go +++ b/server/pluginclient/pluginClient.go @@ -2,8 +2,12 @@ package pluginclient import ( "context" + "errors" + "fmt" + "gitee.com/openeuler/PilotGo-plugin-elk/server/conf" "gitee.com/openeuler/PilotGo/sdk/common" + "gitee.com/openeuler/PilotGo/sdk/logger" "gitee.com/openeuler/PilotGo/sdk/plugin/client" ) @@ -12,9 +16,24 @@ var Global_Client *client.Client var Global_Context context.Context func InitPluginClient() { + if conf.Global_Config != nil && conf.Global_Config.Elk.Https_enabled { + PluginInfo.Url = fmt.Sprintf("https://%s", conf.Global_Config.Elk.Addr_target) + } else if conf.Global_Config != nil && !conf.Global_Config.Elk.Https_enabled { + PluginInfo.Url = fmt.Sprintf("http://%s", conf.Global_Config.Elk.Addr_target) + } else { + err := errors.New("Global_Config is nil") + logger.Fatal("%+v", err) + } + Global_Client = client.DefaultClient(PluginInfo) - // 注册插件扩展点 + getExtentions() + + Global_Context = context.Background() +} + +// 注册插件扩展点 +func getExtentions() { var ex []common.Extention pe1 := &common.PageExtention{ Type: common.ExtentionPage, @@ -36,6 +55,4 @@ func InitPluginClient() { } ex = append(ex, pe1, pe2, pe3) Global_Client.RegisterExtention(ex) - - Global_Context = context.Background() } diff --git a/server/service/template/meta.go b/server/service/template/meta.go index 2df03fe3b89aec8fed81924a1ca771107579d433..2f86795725d51a508bf7ca86e00458f73b3f94de 100755 --- a/server/service/template/meta.go +++ b/server/service/template/meta.go @@ -132,7 +132,7 @@ const ( "must": [ { "match": { - "data_stream.dataset": "{{queryfield_data_stream_dataset}}" + "data_stream.dataset": "{{queryfield_datastream_dataset}}" } }, { @@ -159,7 +159,7 @@ const ( } }, "params": { - "queryfield_data_stream_dataset": "system.syslog", + "queryfield_datastream_dataset": "system.syslog", "queryfield_range_gte": "2024-06-24T10:55:36.185Z", "queryfield_range_lte": "2024-06-24T11:00:36.185Z", "aggsfield": "process.name",