@@ -84,7 +84,7 @@ func (r *KeptnElasticProvider) FetchAnalysisValue(ctx context.Context, query str
8484 ctx , cancel := context .WithTimeout (ctx , 20 * time .Second )
8585 defer cancel ()
8686
87- result , err := r .runElasticQuery (ctx , query )
87+ result , err := r .runElasticQuery (ctx , * provider , query )
8888 if err != nil {
8989 return "" , err
9090 }
@@ -98,7 +98,7 @@ func (r *KeptnElasticProvider) EvaluateQuery(ctx context.Context, metric metrics
9898 ctx , cancel := context .WithTimeout (ctx , 20 * time .Second )
9999 defer cancel ()
100100
101- result , err := r .runElasticQuery (ctx , metric .Spec .Query )
101+ result , err := r .runElasticQuery (ctx , provider , metric .Spec .Query )
102102 if err != nil {
103103 return "" , nil , err
104104 }
@@ -117,7 +117,13 @@ func (r *KeptnElasticProvider) EvaluateQueryForStep(ctx context.Context, metric
117117}
118118
119119// runElasticQuery runs query on elastic search to get output from elasticsearch
120- func (r * KeptnElasticProvider ) runElasticQuery (ctx context.Context , query string ) (map [string ]interface {}, error ) {
120+ func (r * KeptnElasticProvider ) runElasticQuery (ctx context.Context , provider metricsapi.KeptnMetricsProvider , query string ) (map [string ]interface {}, error ) {
121+ var err error
122+ r .Log .Info ("Running Elasticsearch query" , "query" , query )
123+ r .Elastic , err = GetElasticClient (provider )
124+ if err != nil {
125+ return nil , err
126+ }
121127
122128 res , err := r .Elastic .Search (
123129 r .Elastic .Search .WithContext (ctx ),
0 commit comments