-
Notifications
You must be signed in to change notification settings - Fork 47
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
POC: New API endpoint with extendable metrics #1414
Draft
josecelano
wants to merge
1
commit into
torrust:develop
Choose a base branch
from
josecelano:1403-overhaul-stats-start-collecting-stats-per-server-instance-per-socket
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
POC: New API endpoint with extendable metrics #1414
josecelano
wants to merge
1
commit into
torrust:develop
from
josecelano:1403-overhaul-stats-start-collecting-stats-per-server-instance-per-socket
Conversation
This file contains 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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1414 +/- ##
===========================================
- Coverage 83.17% 83.09% -0.08%
===========================================
Files 233 234 +1
Lines 17086 17242 +156
Branches 17086 17242 +156
===========================================
+ Hits 14211 14328 +117
- Misses 2608 2649 +41
+ Partials 267 265 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
b766cc7
to
c159351
Compare
This was referenced Mar 26, 2025
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:
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
url
toserver_url
, ...IMPORTANT
@da2ce7 it would be nice to have feedback before continuing working on this approach.