diff --git a/.github/workflows/merge-master.yaml b/.github/workflows/merge-master.yaml index ce95a6a..bd1c91f 100644 --- a/.github/workflows/merge-master.yaml +++ b/.github/workflows/merge-master.yaml @@ -21,7 +21,7 @@ jobs: release_notes: ${{ steps.semantic.outputs.new_release_notes }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: token: ${{ secrets.ACCESS_TOKEN }} @@ -51,15 +51,15 @@ jobs: needs: prepare steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: '1.17' - name: Cache Go modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 2da3b2d..9d70542 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -15,15 +15,15 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: '1.17' - name: Cache Go modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} diff --git a/pkg/common/clients/prometheus_client.go b/pkg/common/clients/prometheus_client.go index 1f874ab..40d2e40 100644 --- a/pkg/common/clients/prometheus_client.go +++ b/pkg/common/clients/prometheus_client.go @@ -60,3 +60,19 @@ func (c PrometheusClient) QueryRange(ctx context.Context, query string, startAt, } return result, nil } + +// Query returns an instant vector, given the following parameters: +// - query: Prometheus query +// - moment: moment in time +// It returns the result vector and the execution error encountered. +func (c PrometheusClient) Query(ctx context.Context, query string, moment time.Time) (model.Value, error) { + result, warnings, err := c.api.Query(ctx, query, moment) + if err != nil { + c.logger.Errorf("Error querying Prometheus: %v", err) + return nil, err + } + if len(warnings) > 0 { + c.logger.Warnf("Prometheus query warnings result: %v", warnings) + } + return result, nil +}