POC: New API endpoint with extendable metrics#1426
Closed
josecelano wants to merge 1 commit into
Closed
Conversation
This is only a Prood of Concept. It adds a new REST API endpoint with a new format for metrics: URL: http://0.0.0.0:1212/api/v1/metrics?token=MyAccessToken Sample response: ```json { "labeled_metrics": [ { "metric": { "name": "announce_requests_received_total", "kind": "counter", "value": 1 }, "labels": { "ip_version": "ipv4", "protocol": "http", "url": "http://0.0.0.0:7070" } }, { "metric": { "name": "scrape_requests_received_total", "kind": "counter", "value": 1 }, "labels": { "ip_version": "ipv4", "protocol": "http", "url": "http://0.0.0.0:7070" } } ] } ``` It only supports JSON format for now. It doesn't support prometheus format like the current stats endpoint: URL: http://0.0.0.0:1212/api/v1/stats?token=MyAccessToken&format=prometheus TODO: - Replace primitive types in the new labeled metrics with new tpyes to enforce constraints. For example, metrics names, labels, metric types, etc. - Inject the rigth URL scheme. It's hardcoded now. - Implement for UDP metrics. It's only implemented for HTTP tracker metrics. This would require mergin labeled metrics. - Use a f64 for metric values instead of u64. - The metric name and label set pair must be unique in the array of labeled metrics. Enforce constraint. - Implement versioning. A given API version must contain a set of labeled metrics. Clients expects some labeled metrics to be included in a API version. We need to initialize the array of metrics with all the expected labeled metrics with the initial value.
Member
Author
|
I have continued with the implementation of the POC here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to:
This is only a Proof of Concept.
It adds a new REST API endpoint with a new extendable format for metrics:
URL: http://0.0.0.0:1212/api/v1/metrics?token=MyAccessToken
Sample response:
{ "labeled_metrics": [ { "metric": { "name": "announce_requests_received_total", "kind": "counter", "value": 1 }, "labels": { "ip_version": "ipv4", "protocol": "http", "url": "http://0.0.0.0:7070" } }, { "metric": { "name": "scrape_requests_received_total", "kind": "counter", "value": 1 }, "labels": { "ip_version": "ipv4", "protocol": "http", "url": "http://0.0.0.0:7070" } } ] }It only supports JSON format for now. It doesn't support Prometheus format like the current stats endpoint:
URL: http://0.0.0.0:1212/api/v1/stats?token=MyAccessToken&format=prometheus
The Prometheus format response should be like the following:
TODO
urltoserver_url, ...IMPORTANT
@da2ce7 it would be nice to have feedback before continuing working on this approach.