From 090b612d7e2736e0b35624e65408bfcea6fc415b Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Tue, 25 Jun 2024 17:17:21 +0800 Subject: [PATCH] server/conf: check https config of elasticsearch and kibana --- elk.yaml.template | 6 ++++-- server/conf/meta.go | 14 ++++++++------ server/elasticClient/client.go | 2 +- server/kibanaClient/7_17_16/client.go | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/elk.yaml.template b/elk.yaml.template index ce3917c..6da35e4 100644 --- a/elk.yaml.template +++ b/elk.yaml.template @@ -12,12 +12,14 @@ log: max_file: 1 max_size: 10485760 elasticsearch: - http_addr: "localhost:9200" + https_enabled: false + addr: "localhost:9200" username: "" password: "" logstash: http_addr: "localhost:9600" kibana: - http_addr: "localhost:5601" + https_enabled: false + addr: "localhost:5601" username: "" password: "" diff --git a/server/conf/meta.go b/server/conf/meta.go index 5c7d338..c4c114c 100644 --- a/server/conf/meta.go +++ b/server/conf/meta.go @@ -12,9 +12,10 @@ type PilotGoConf struct { } type ElasticConf struct { - Addr string `yaml:"http_addr"` - Username string `yaml:"username"` - Password string `yaml:"password"` + Https_enabled bool `yaml:"https_enabled"` + Addr string `yaml:"addr"` + Username string `yaml:"username"` + Password string `yaml:"password"` } type LogstashConf struct { @@ -22,7 +23,8 @@ type LogstashConf struct { } type KibanaConf struct { - Addr string `yaml:"http_addr"` - Username string `yaml:"username"` - Password string `yaml:"password"` + Https_enabled bool `yaml:"https_enabled"` + Addr string `yaml:"addr"` + Username string `yaml:"username"` + Password string `yaml:"password"` } diff --git a/server/elasticClient/client.go b/server/elasticClient/client.go index 871fcaa..282c439 100644 --- a/server/elasticClient/client.go +++ b/server/elasticClient/client.go @@ -31,7 +31,7 @@ type ElasticClient_v7 struct { func InitElasticClient() { addresses := []string{} - if conf.Global_Config.Elk.Https_enabled { + if conf.Global_Config.Elasticsearch.Https_enabled { addresses = append(addresses, fmt.Sprintf("https://%s", conf.Global_Config.Elasticsearch.Addr)) } else { addresses = append(addresses, fmt.Sprintf("http://%s", conf.Global_Config.Elasticsearch.Addr)) diff --git a/server/kibanaClient/7_17_16/client.go b/server/kibanaClient/7_17_16/client.go index edc9618..c22f24a 100644 --- a/server/kibanaClient/7_17_16/client.go +++ b/server/kibanaClient/7_17_16/client.go @@ -26,7 +26,7 @@ type KibanaClient_v7 struct { func InitKibanaClient() { protocol := "" - if conf.Global_Config.Elk.Https_enabled { + if conf.Global_Config.Kibana.Https_enabled { protocol = "https" } else { protocol = "http" -- Gitee