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

api/v1: added /status/runtimeinfo #5165

Closed
wants to merge 1 commit into from
Closed

Conversation

vn-ki
Copy link
Contributor

@vn-ki vn-ki commented Jan 31, 2019

This does not yet build. I want some pointers before I can go ahead.

Right now, because I have the types in web.go, I am running into a cyclic import.

Is there a file where I can place RuntimeInfo struct and PrometheusVersion struct?

If not, how do I tackle this problem? Is my approach fundamentally wrong?

Ping: @brancz @mxinden

Closes #2467

Signed-off-by: Vishnunarayan K I appukuttancr@gmail.com

@mxinden
Copy link
Member

mxinden commented Feb 1, 2019

Is there a file where I can place RuntimeInfo struct and PrometheusVersion struct?

As these are specific to an API interface and should not break once a different API (web.go) interface changes, I would vote for duplicating the structs in api/v1/api.go, given that they are also quite simple.

I am not a maintainer of Prometheus. What do others think?

@brian-brazil
Copy link
Contributor

Hmm, how about factoring that out and providing a warning that the contents of the map may change over time?

@vn-ki
Copy link
Contributor Author

vn-ki commented Feb 1, 2019

@brian-brazil By factoring out do you mean to place the structs in a different file which both api.go and web.go can import?

@brian-brazil
Copy link
Contributor

brian-brazil commented Feb 2, 2019 via email

@vn-ki vn-ki force-pushed the api-ui-data branch 3 times, most recently from 1326c57 to 3f93820 Compare February 2, 2019 10:39
@vn-ki
Copy link
Contributor Author

vn-ki commented Feb 2, 2019

@brian-brazil I factored it out. Can you check the implementation? I'll add the warning and necessary docs after that.

@vn-ki
Copy link
Contributor Author

vn-ki commented Feb 3, 2019

I have added the documentation of the api (with a warning it might change) and the required tests.

@vn-ki vn-ki changed the title [WIP] api/v1: added /status/runtimeinfo api/v1: added /status/runtimeinfo Feb 3, 2019
docs/querying/api.md Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/web.go Outdated Show resolved Hide resolved
docs/querying/api.md Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
web/types/types.go Outdated Show resolved Hide resolved
@vn-ki vn-ki force-pushed the api-ui-data branch 4 times, most recently from 289c745 to 3d504e6 Compare February 5, 2019 20:13
@vn-ki
Copy link
Contributor Author

vn-ki commented Feb 5, 2019

Resolved all issues

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

I think a consistent API is important. I am sorry for the nit picking.

web/web_types/types.go Outdated Show resolved Hide resolved
web/web_types/types.go Outdated Show resolved Hide resolved
web/web_types/types.go Outdated Show resolved Hide resolved
@vn-ki
Copy link
Contributor Author

vn-ki commented Feb 7, 2019

@mxinden All fixed

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Small nit. Other than that this looks good to me. Are there any thoughts by others left?

web/web_types/types.go Outdated Show resolved Hide resolved
web/web_types/types.go Show resolved Hide resolved
@vn-ki
Copy link
Contributor Author

vn-ki commented Feb 17, 2019

@mxinden Done

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for bearing with us @vn-ki!

Giving @brian-brazil the last vote as a Prometheus maintainer.

CWD string `json:"cwd"`
Version *PrometheusVersion `json:"version"`
Alertmanagers []*url.URL `json:"alertmanagers"`
GoroutineCount int `json:"goroutineCNT"`
Copy link
Member

Choose a reason for hiding this comment

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

Is there a particular reason why you specifically abbreviate Count -> CNT here? Seems inconsistent with the other fields, especially the other ...Count fields.

Otherwise this PR looks 👍

GOGC string `json:"goGC"`
CorruptionCount int64 `json:"corruptionCount"`
ChunkCount int64 `json:"chunkCount"`
TimeSeriesCount int64 `json:"timeSeriesCount"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Count here still implies a counter, which this isn't. And chunks, goroutines.

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't have made that association because it's not a metric name, but don't care either way.

On the other hand you might ask if we really need to offer data over this API that we already have on /metrics as well (goroutines, number of time series, etc.).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the other hand you might ask if we really need to offer data over this API that we already have on /metrics as well (goroutines, number of time series, etc.).

I feel like providing an API makes those a bit more accessible.

Should I remove it?

"time"
)

// RunRuntimeInfo contains runtime info about Prometheus.
Copy link
Member

Choose a reason for hiding this comment

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

RunRuntimeInfo -> RuntimeInfo

"corruptionCount": 0,
"goGC": "",
"goMaxProcs": 4,
"goroutineCNT": 29,
Copy link
Member

Choose a reason for hiding this comment

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

Would need to be updated to align with Julius' comment

Birth time.Time `json:"startTime"`
CWD string `json:"cwd"`
Version *PrometheusVersion `json:"version"`
Alertmanagers []*url.URL `json:"alertmanagers"`
Copy link
Member

Choose a reason for hiding this comment

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

I think it should be a slice of strings instead of url.URL. This is the current API output with 1 configured AlertManager:

{
  "status": "success",
  "data": {
...
    "alertmanagers": [
      {
        "Scheme": "http",
        "Opaque": "",
        "User": null,
        "Host": "localhost:9093",
        "Path": "/api/v1/alerts",
        "RawPath": "",
        "ForceQuery": false,
        "RawQuery": "",
        "Fragment": ""
      }
    ],
...
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@simonpasquier The status.html template uses the Host, Path and Scheme.

https://github.com/prometheus/prometheus/blob/4a0b6aa612daf141b86c49e9207542eea1018ebd/web/ui/templates/status.html#L90

I'm not sure what to do. Any help will be appreciated.

Copy link
Member

Choose a reason for hiding this comment

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

Right, I would be inclined to declare an intermediary Alertmanager struct that would only expose the required fields.

type AlertManager struct {
    Scheme string `json:"scheme"`
    Host string `json:"host"`
    Path string `json:"path"`
}

type RuntimeInfo struct {
...
    Alertmanagers []Alertmanager `json:"alertmanagers"`
...
}

@vn-ki vn-ki force-pushed the api-ui-data branch 2 times, most recently from 302f32d to 19eaa6d Compare March 25, 2019 13:34
@vn-ki
Copy link
Contributor Author

vn-ki commented Mar 25, 2019

@simonpasquier Done and rebased

Copy link
Member

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

The code looks good to me. A few nits on the documentation.

@@ -683,6 +683,46 @@ $ curl http://localhost:9090/api/v1/status/flags

*New in v2.2*

### Runtime Info
Copy link
Member

Choose a reason for hiding this comment

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

Information

@@ -683,6 +683,46 @@ $ curl http://localhost:9090/api/v1/status/flags

*New in v2.2*

### Runtime Info

The following endpoint returns runtime info of the Prometheus server.
Copy link
Member

Choose a reason for hiding this comment

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

s/info/information/ too

{
"status": "success",
"data": {
"alertmanagers": null,
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to add a non-null value.

...
    "alertmanagers": [
      {
        "scheme": "http",
        "host": "localhost:9093",
        "path": "/api/v1/alerts"
      }
    ],
...

Signed-off-by: Vishnunarayan K I <appukuttancr@gmail.com>
@vn-ki
Copy link
Contributor Author

vn-ki commented Mar 25, 2019

@simonpasquier Done

@simonpasquier
Copy link
Member

@vn-ki you have conflicts to resolve.

@stale stale bot added the stale label Feb 19, 2020
@codesome
Copy link
Member

We have this upstream already in the React UI (https://prometheus.demo.do.prometheus.io/api/v1/status/runtimeinfo). Thanks for working on this btw!

@codesome codesome closed this Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data accessible via API
7 participants