@@ -26,6 +26,7 @@ import (
2626
2727type getCountFunc func () (int , error )
2828
29+ // waitForCount waits until the provided function returns greater than zero.
2930func waitForCount (ctx context.Context , log logging.Logger , name string , getCount getCountFunc ) error {
3031 if err := pollUntilContextCancel (ctx , func (_ context.Context ) (bool , error ) {
3132 count , err := getCount ()
@@ -54,11 +55,14 @@ func CheckLogsExist(ctx context.Context, log logging.Logger, networkUUID string)
5455 if err != nil {
5556 return fmt .Errorf ("failed to get collector credentials: %w" , err )
5657 }
57- query , err := getCheckLogsQuery (networkUUID )
58+
59+ url := getLokiURL ()
60+
61+ selectors , err := getSelectors (networkUUID )
5862 if err != nil {
5963 return err
6064 }
61- url := getLokiURL ( )
65+ query := fmt . Sprintf ( "sum(count_over_time({%s}[1h]))" , selectors )
6266
6367 log .Info ("checking if logs exist" ,
6468 zap .String ("url" , url ),
@@ -70,15 +74,6 @@ func CheckLogsExist(ctx context.Context, log logging.Logger, networkUUID string)
7074 })
7175}
7276
73- // getCheckLogsQuery returns the query to check if logs exist.
74- func getCheckLogsQuery (networkUUID string ) (string , error ) {
75- selectors , err := getSelectors (networkUUID )
76- if err != nil {
77- return "" , err
78- }
79- return fmt .Sprintf ("sum(count_over_time({%s}[1h]))" , selectors ), nil
80- }
81-
8277func queryLoki (
8378 ctx context.Context ,
8479 lokiURL string ,
@@ -159,11 +154,14 @@ func CheckMetricsExist(ctx context.Context, log logging.Logger, networkUUID stri
159154 if err != nil {
160155 return fmt .Errorf ("failed to get collector credentials: %w" , err )
161156 }
162- query , err := getCheckMetricsQuery (networkUUID )
157+
158+ url := getPrometheusURL ()
159+
160+ selectors , err := getSelectors (networkUUID )
163161 if err != nil {
164162 return err
165163 }
166- url := getPrometheusURL ( )
164+ query := fmt . Sprintf ( "count({%s})" , selectors )
167165
168166 log .Info ("checking if metrics exist" ,
169167 zap .String ("url" , url ),
@@ -175,15 +173,6 @@ func CheckMetricsExist(ctx context.Context, log logging.Logger, networkUUID stri
175173 })
176174}
177175
178- // getCheckMetricsQuery returns the query to check if metrics exist.
179- func getCheckMetricsQuery (networkUUID string ) (string , error ) {
180- selectors , err := getSelectors (networkUUID )
181- if err != nil {
182- return "" , err
183- }
184- return fmt .Sprintf ("count({%s})" , selectors ), nil
185- }
186-
187176func queryPrometheus (
188177 ctx context.Context ,
189178 log logging.Logger ,
0 commit comments