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
api/prometheus/v1/api.go: Add support for status/runtimeinfo endpoint #755
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -137,6 +137,7 @@ const ( | |||||||||
epCleanTombstones = apiPrefix + "/admin/tsdb/clean_tombstones" | ||||||||||
epConfig = apiPrefix + "/status/config" | ||||||||||
epFlags = apiPrefix + "/status/flags" | ||||||||||
epRuntimeinfo = apiPrefix + "/status/runtimeinfo" | ||||||||||
) | ||||||||||
|
||||||||||
// AlertState models the state of an alert. | ||||||||||
|
@@ -238,6 +239,8 @@ type API interface { | |||||||||
Query(ctx context.Context, query string, ts time.Time) (model.Value, Warnings, error) | ||||||||||
// QueryRange performs a query for the given range. | ||||||||||
QueryRange(ctx context.Context, query string, r Range) (model.Value, Warnings, error) | ||||||||||
// Runtimeinfo returns the various runtime information properties about the Prometheus server. | ||||||||||
Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
|
||||||||||
// Series finds series by label matchers. | ||||||||||
Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, Warnings, error) | ||||||||||
// Snapshot creates a snapshot of all current data into snapshots/<datetime>-<rand> | ||||||||||
|
@@ -277,6 +280,22 @@ type ConfigResult struct { | |||||||||
// FlagsResult contains the result from querying the flag endpoint. | ||||||||||
type FlagsResult map[string]string | ||||||||||
|
||||||||||
// RuntimeinfoResult contains the result from querying the runtimeinfo endpoint. | ||||||||||
type RuntimeinfoResult struct { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||||||||||
StartTime string `json:"startTime"` | ||||||||||
CWD string `json:"CWD"` | ||||||||||
ReloadConfigSuccess bool `json:"reloadConfigSuccess"` | ||||||||||
LastConfigTime string `json:"lastConfigTime"` | ||||||||||
ChunkCount int `json:"chunkCount"` | ||||||||||
TimeSeriesCount int `json:"timeSeriesCount"` | ||||||||||
CorruptionCount int `json:"corruptionCount"` | ||||||||||
GoroutineCount int `json:"goroutineCount"` | ||||||||||
GOMAXPROCS int `json:"GOMAXPROCS"` | ||||||||||
GOGC string `json:"GOGC"` | ||||||||||
GODEBUG string `json:"GODEBUG"` | ||||||||||
StorageRetention string `json:"storageRetention"` | ||||||||||
} | ||||||||||
|
||||||||||
// SnapshotResult contains the result from querying the snapshot endpoint. | ||||||||||
type SnapshotResult struct { | ||||||||||
Name string `json:"name"` | ||||||||||
|
@@ -640,6 +659,23 @@ func (h *httpAPI) Flags(ctx context.Context) (FlagsResult, error) { | |||||||||
return res, json.Unmarshal(body, &res) | ||||||||||
} | ||||||||||
|
||||||||||
func (h *httpAPI) Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) { | ||||||||||
u := h.client.URL(epRuntimeinfo, nil) | ||||||||||
|
||||||||||
req, err := http.NewRequest(http.MethodGet, u.String(), nil) | ||||||||||
if err != nil { | ||||||||||
return RuntimeinfoResult{}, err | ||||||||||
} | ||||||||||
|
||||||||||
_, body, _, err := h.client.Do(ctx, req) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like matches the other methods, but why we discard the status code completely? No point in marshaling if we don't check 2** status. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like you mentioned this just uses what the other functions use, but the custom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is something to fix in follow up PRs if any, just it feels wrong, will add issue to follow up (: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, we should fix it for all the functions! If you open issue can you ping me on it, thanks! |
||||||||||
if err != nil { | ||||||||||
return RuntimeinfoResult{}, err | ||||||||||
} | ||||||||||
|
||||||||||
var res RuntimeinfoResult | ||||||||||
return res, json.Unmarshal(body, &res) | ||||||||||
} | ||||||||||
|
||||||||||
func (h *httpAPI) LabelNames(ctx context.Context) ([]string, Warnings, error) { | ||||||||||
u := h.client.URL(epLabels, nil) | ||||||||||
req, err := http.NewRequest(http.MethodGet, u.String(), nil) | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this, as the endpoint is /runtimeinfo not /runtime_info, at least that was the logic I used here. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, not a blocker, but this looks weird (: