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

Metrics #3216

Merged
merged 20 commits into from
Jan 16, 2024
Merged

Metrics #3216

Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7cfcb5d
Add Prometheus instrumentation
tillprochaska Oct 16, 2023
35ec9ca
Fix missing bind argument
tillprochaska Sep 21, 2023
58d4ee7
Run Prometheus exporter as a separate service
tillprochaska Oct 16, 2023
21202a8
Expose number of streaming requests and number of streamed entities a…
tillprochaska Oct 16, 2023
74e9eb7
Expose number of auth attempts as Prometheus metrics
tillprochaska Oct 16, 2023
e0769a7
Update Helm chart to expose metrics endpoints, setup ServiceMonitors
tillprochaska Nov 19, 2023
bfd7a60
Handle requests without Authz object gracefully
tillprochaska Nov 8, 2023
7bd852d
Rename Prometheus label to "api_endpoint" to prevent naming clashes
tillprochaska Nov 8, 2023
de5538f
Add xref metrics
tillprochaska Nov 17, 2023
155ec42
Use common prefix for all metric names
tillprochaska Nov 19, 2023
4c238d2
Expose Python platform information as Prometheus metrics
tillprochaska Nov 19, 2023
b27bae4
Remove unused port, network policy from K8s specs
tillprochaska Nov 19, 2023
d512e00
Use keyword args to set Prometheus metric labels
tillprochaska Nov 20, 2023
8137882
Bump servicelayer from 1.22.0 to 1.22.1
tillprochaska Nov 21, 2023
841f4b6
Simplify entity streaming metrics code
tillprochaska Nov 23, 2023
1288d94
Limit maximum size of Prometheus multiprocessing directory
tillprochaska Nov 23, 2023
33d9416
Do not let collector classes inherit from `object`
tillprochaska Nov 23, 2023
63fb216
Add `aleph_` prefix to Prometheus API metrics
tillprochaska Jan 9, 2024
ff937cd
Fix metrics name (singular -> plural)
tillprochaska Jan 9, 2024
6197c30
Add documentation on how to test Prometheus instrumentation in local …
tillprochaska Jan 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename Prometheus label to "api_endpoint" to prevent naming clashes
Prometheus Operator also uses the "endpoint" label and automatically renames "endpoint" labels exposed by the metrics endpoint to "exported_endpoints" which is ugly.
  • Loading branch information
tillprochaska committed Jan 15, 2024
commit 7bd852d8f90fe2711f69dc8604d66b377cfd3a17
14 changes: 7 additions & 7 deletions aleph/metrics/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
REQUEST_DURATION = Histogram(
"http_request_duration_seconds",
"Duration of requests to the Aleph API in seconds",
["method", "status", "endpoint"],
["method", "status", "api_endpoint"],
)

REQUEST = Counter(
"http_request_total",
"Total number of Aleph API requests",
["method", "status", "endpoint", "logged_in"],
["method", "status", "api_endpoint", "logged_in"],
)


Expand All @@ -32,10 +32,10 @@ def before_request():


def after_request(response):
endpoint = request.endpoint
api_endpoint = request.endpoint

# Do not track request duration for the metrics endpoint
if endpoint == METRICS_ENDPOINT_NAME:
# Do not track request duration for the metrics and healthz endpoints
if api_endpoint == METRICS_ENDPOINT_NAME or api_endpoint == "base_api.healthz":
return response

method = request.method
Expand All @@ -50,8 +50,8 @@ def after_request(response):

duration = max(0, default_timer() - request.prometheus_start_time)

REQUEST.labels(method, status, endpoint, logged_in).inc()
REQUEST_DURATION.labels(method, status, endpoint).observe(duration)
REQUEST.labels(method, status, api_endpoint, logged_in).inc()
REQUEST_DURATION.labels(method, status, api_endpoint).observe(duration)

return response

Expand Down