diff --git a/elk/handler/search.go b/elk/handler/search.go index 8c80d80fefece79149efcea763018bec9057dd95..f7e5f1536727ebf87b93387a97430bd489c18f10 100644 --- a/elk/handler/search.go +++ b/elk/handler/search.go @@ -15,6 +15,7 @@ import ( ) func SearchHandle(ctx *gin.Context) { + index := ctx.Query("index") defer ctx.Request.Body.Close() if elasticClient.Global_elastic.Client == nil { err := errors.Errorf("%+v **warn**0", "global_elastic is null") @@ -24,7 +25,7 @@ func SearchHandle(ctx *gin.Context) { } resp, err := elasticClient.Global_elastic.Client.Search( elasticClient.Global_elastic.Client.Search.WithContext(context.Background()), - elasticClient.Global_elastic.Client.Search.WithIndex(".ds-logs-system.syslog-default-2024.06.04-000001"), + elasticClient.Global_elastic.Client.Search.WithIndex(index), elasticClient.Global_elastic.Client.Search.WithBody(ctx.Request.Body), elasticClient.Global_elastic.Client.Search.WithTrackTotalHits(true), elasticClient.Global_elastic.Client.Search.WithPretty(), diff --git a/elk/kibanaClient/7_17_16/client.go b/elk/kibanaClient/7_17_16/client.go index 3e57673fa4854a52cbf39d06c4ee2f3d3197841b..edc961800738e64b0c85579dca1dc37b4ea98445 100644 --- a/elk/kibanaClient/7_17_16/client.go +++ b/elk/kibanaClient/7_17_16/client.go @@ -25,8 +25,14 @@ type KibanaClient_v7 struct { } func InitKibanaClient() { + protocol := "" + if conf.Global_Config.Elk.Https_enabled { + protocol = "https" + } else { + protocol = "http" + } cfg := &kibana.ClientConfig{ - Protocol: "https", + Protocol: protocol, Host: conf.Global_Config.Kibana.Addr, Username: conf.Global_Config.Kibana.Username, Password: conf.Global_Config.Kibana.Password,