Skip to content

Add basic metrics

embr requested to merge feature/let-them-eat-metrics into develop

Issue Fix

Part of #56 (closed)

Description

Adds some basic metrics for ratmand's internals. They're currently exposed as Prometheus metrics, an API endpoint will be added in a follow-up MR that exposes the same data as JSON for the dashboard.

Alternative(s) considered

We don't strictly need to export Prometheus metrics, but it's pretty much the defacto standard for metrics these days, and a Prometheus client library needs much of the same infrastructure as a home-rolled API for tracking this stuff would.

The Rust ecosystem is currently torn between two different implementations of this idea - one is Prometheus' official prometheus-client crate, the other is the more generic metrics crate. The two have more similarities than differences, and if we wanted to move between them in the future, that's not a very difficult task. Which one we actually use should be treated as an implementation detail; the public API (the Prometheus endpoint and future API endpoint) is the same regardless.

Type

Choose one: Feature

Screenshots (if applicable)

$ http localhost:8090/_/metrics
HTTP/1.1 200 OK
content-length: 2166
content-type: application/openmetrics-text;charset=utf-8;version=1.0.0
date: Mon, 11 Jul 2022 13:21:59 GMT

# HELP ratman_routes_current Number of routes currently in the table.
# TYPE ratman_routes_current gauge
ratman_routes_current{kind="local"} 3
ratman_routes_current{kind="remote"} 1
# HELP ratman_dispatch_messages Total number of messages dispatched.
# TYPE ratman_dispatch_messages counter
ratman_dispatch_messages_total{recp_type="standard",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 3408
# HELP ratman_dispatch_frames Total number of frames dispatched.
# TYPE ratman_dispatch_frames counter
ratman_dispatch_frames_total{recp_type="flood",recp_id="43CC-8612-0100-E6CD-F06A-1049-948E-3DA3-94B8-3E7B-C131-BA1D-2570-2D1B-4C2D-A2CA"} 68
ratman_dispatch_frames_total{recp_type="standard",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 71895
ratman_dispatch_frames_total{recp_type="flood",recp_id="2AE3-D6CB-3FA4-CD8D-22F4-5E12-74CD-516E-1FB7-A1C0-8436-2837-7E09-D467-ED30-99C3"} 68
ratman_dispatch_frames_total{recp_type="flood",recp_id="7D47-AE70-ECFF-D921-8EDA-1B1F-1D9F-4017-1A9F-6F41-71A3-E411-F3C0-FA54-315D-E95E"} 68
# HELP ratman_dispatch_bytes_bytes Total size of dispatched frames.
# TYPE ratman_dispatch_bytes_bytes counter
# UNIT ratman_dispatch_bytes_bytes bytes
ratman_dispatch_bytes_bytes_total{recp_type="flood",recp_id="7D47-AE70-ECFF-D921-8EDA-1B1F-1D9F-4017-1A9F-6F41-71A3-E411-F3C0-FA54-315D-E95E"} 3060
ratman_dispatch_bytes_bytes_total{recp_type="flood",recp_id="43CC-8612-0100-E6CD-F06A-1049-948E-3DA3-94B8-3E7B-C131-BA1D-2570-2D1B-4C2D-A2CA"} 3060
ratman_dispatch_bytes_bytes_total{recp_type="flood",recp_id="2AE3-D6CB-3FA4-CD8D-22F4-5E12-74CD-516E-1FB7-A1C0-8436-2837-7E09-D467-ED30-99C3"} 3060
ratman_dispatch_bytes_bytes_total{recp_type="standard",recp_id="405E-DA6E-1B45-F0FA-7AFB-3459-393A-F352-183C-24C8-80DD-341B-C803-2353-B4E6-4CEE"} 92067523
# HELP ratman_proto_announcements Total number of announcements sent.
# TYPE ratman_proto_announcements counter
ratman_proto_announcements_total 102
# HELP http_requests Total number of HTTP requests.
# TYPE http_requests counter
http_requests_total{method="GET",path="/_/metrics",status="200"} 2
# EOF
Edited by embr

Merge request reports