Skip to content

Commit

Permalink
fix(prometheus): instant vector query support (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoaguimaraes authored Jul 7, 2022
1 parent 393e45f commit fe5d9fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/merge-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -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') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
16 changes: 16 additions & 0 deletions pkg/common/clients/prometheus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit fe5d9fa

Please sign in to comment.