From 858c910a7735d26c5c1fb19b86509173ebe7d2b7 Mon Sep 17 00:00:00 2001 From: Renato Guimaraes Date: Wed, 6 Jul 2022 21:35:13 -0300 Subject: [PATCH 1/4] fix(prometheus): instant vector query support [PLT-535] --- pkg/common/clients/prometheus_client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/common/clients/prometheus_client.go b/pkg/common/clients/prometheus_client.go index 1f874ab..2432331 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 matrix 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 +} From d26a53a88a1cc0ad1f0b6b4f1ecfa2c8a7fbeb45 Mon Sep 17 00:00:00 2001 From: Renato Guimaraes Date: Wed, 6 Jul 2022 21:49:49 -0300 Subject: [PATCH 2/4] bump gh actions --- .github/workflows/merge-master.yaml | 8 ++++---- .github/workflows/pull-request.yaml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/merge-master.yaml b/.github/workflows/merge-master.yaml index ce95a6a..fa75239 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.0.1 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..19797e7 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.0.1 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} From fa0052f31a4c974079ee0efee41f651c92396a78 Mon Sep 17 00:00:00 2001 From: Renato Guimaraes Date: Thu, 7 Jul 2022 11:19:25 -0300 Subject: [PATCH 3/4] bump gh actions --- .github/workflows/merge-master.yaml | 2 +- .github/workflows/pull-request.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/merge-master.yaml b/.github/workflows/merge-master.yaml index fa75239..bd1c91f 100644 --- a/.github/workflows/merge-master.yaml +++ b/.github/workflows/merge-master.yaml @@ -59,7 +59,7 @@ jobs: go-version: '1.17' - name: Cache Go modules - uses: actions/cache@v3.0.1 + 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 19797e7..9d70542 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -23,7 +23,7 @@ jobs: go-version: '1.17' - name: Cache Go modules - uses: actions/cache@v3.0.1 + uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} From 65d641884496c31f325618636b074f3cb5706a0f Mon Sep 17 00:00:00 2001 From: Renato Guimaraes Date: Thu, 7 Jul 2022 11:21:16 -0300 Subject: [PATCH 4/4] doc --- pkg/common/clients/prometheus_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/clients/prometheus_client.go b/pkg/common/clients/prometheus_client.go index 2432331..40d2e40 100644 --- a/pkg/common/clients/prometheus_client.go +++ b/pkg/common/clients/prometheus_client.go @@ -64,7 +64,7 @@ func (c PrometheusClient) QueryRange(ctx context.Context, query string, startAt, // Query returns an instant vector, given the following parameters: // - query: Prometheus query // - moment: moment in time -// It returns the result matrix and the execution error encountered. +// 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 {