Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prometheus): instant vector query support #69

Merged
merged 4 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}