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

Update verify connection API call #42

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
7 changes: 2 additions & 5 deletions prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ func (p *Prometheus) QueryRange(query string, start, end time.Time, step time.Du

// Verifies prometheus connection
func (p *Prometheus) verifyConnection() error {
_, err := p.api.Runtimeinfo(context.TODO())
if err != nil {
return err
}
return nil
_, err := p.Query("up{}", time.Now().UTC().UTC())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this works, but on a large scale cluster it returns a bulk of data as it checks all target endpoints, hope that is fine.

return err
}
2 changes: 1 addition & 1 deletion prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var _ = Describe("Tests for Prometheus", func() {
_, err := NewClient(url, token, username, password, tlsSkipVerify)
//Asserting no of times mocks are called
Expect(count).To(BeEquivalentTo(0))
Expect(err.Error()).To(ContainSubstring("Get \"/api/v1/status/runtimeinfo\": unsupported protocol scheme \"\""))
Expect(err.Error()).To(ContainSubstring("Post \"/api/v1/query\": unsupported protocol scheme \"\""))
})

It("Test2 passing not valid url", func() {
Expand Down
Loading