-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add JSON as a format to the HTTP handler #120
Comments
Hmm, this sounds like a case for a custom bridge. That is to say something that takes samples from the Registry and outputs them in the format of another monitoring system, in this case on a separate endpoint. |
@ghodss Prometheus initially only had JSON and protobuf exposition formats. JSON was a crappy compromise in many ways, so we ended up only supporting the new text-based format and the protobuf one (as opposites of each other in terms of ease of construction and robustness + efficiency). I do agree that having the option to export Prometheus metrics as JSON directly from the process that generates them would be convenient for users though. @beorn7, what was the status of making this kind of thing possible via custom output bridges again? |
I don't know about the status of bridges. |
Allowing to get the values out of a metric (cf. #58) would at least allow building the json manually, right? |
@matthiasr That's the plan. After the clean-up, the registry will be independent from exposition. It will simply spit out the canonical representation of Prometheus metrics (which is a slice of MetricFamily protobufs). The http exposition as we have it now will be separate then, encoding the collection of protobufs either into delimited protobufs or into text format, depending on HTTP content type. But the registry interface will be public, so anybody can write their own code, taking the protobuf, doing whatever they desire, e.g. generating JSON from it, and then serve it in any way they see fit. So yeah, I guess we are already on the right way. Even if we will never support JSON inside |
So just for my understanding, if I use the io_prometheus_client.MetricFamily struct (and all its descendants) to convert the values to another format, similar to prom2json, that interface should be stable, right? Or will it be changing in the aforementioned cleanup? |
That should be stable. The cleanup would just be a code refactoring that
|
The protobuf format as defined in https://github.com/prometheus/client_model/blob/master/metrics.proto is supposed to be the central, canonical data exchange format as used internally by the server and the Go client library. We don't intend to change that fact, and we will change the proto only if needed (and that will mostly be to add new metric types, so it should be backwards compatible as per the protobuf design). |
Closing as there is nothing concretely to be done about this. (A general clean-up of |
The prometheus golang client is very useful as a generic library to measure and expose metrics, even when the consumer is not prometheus. (It's being used in this way in the Kubernetes project.) In this case, or in any case where prometheus is not the sole consumer of an application's metrics, being able to consume the metrics from the HTTP endpoint as JSON dramatically helps the ability for tooling to consume and parse the metrics outputted by the golang client.
prom2json provides this functionality as a Go command-line tool, which only makes the functionality accessible to tools in other languages if you package and install the tool and call it in between HTTP calls to the client library. Integration directly into the client's metrics server would make things much easier.
The text was updated successfully, but these errors were encountered: