MCPcopy Create free account
hub / github.com/efficientgo/e2e / InstantQuery

Method InstantQuery

monitoring/monitoring.go:308–325  ·  view source on GitHub ↗

InstantQuery evaluates instant PromQL queries against monitoring service.

(query string)

Source from the content-addressed store, hash-verified

306
307// InstantQuery evaluates instant PromQL queries against monitoring service.
308func (s *Service) InstantQuery(query string) (string, error) {
309 if !s.p.IsRunning() {
310 return "", errors.Newf("%s is not running", s.p.Name())
311 }
312
313 res, err := (&http.Client{}).Get("http://" + s.p.Endpoint("http") + "/api/v1/query?query=" + query)
314 if err != nil {
315 return "", err
316 }
317
318 if res.StatusCode < 200 || res.StatusCode >= 300 {
319 return "", errors.Newf("unexpected status code %d while fetching metrics", res.StatusCode)
320 }
321 defer errcapture.ExhaustClose(&err, res.Body, "metrics response")
322
323 body, err := io.ReadAll(res.Body)
324 return string(body), err
325}
326
327// GetMonitoringRunnable returns a Prometheus monitoring runnable.
328func (s *Service) GetMonitoringRunnable() e2e.Runnable {

Callers

nothing calls this directly

Calls 3

IsRunningMethod · 0.65
NameMethod · 0.65
EndpointMethod · 0.65

Tested by

no test coverage detected