mirror of
https://git.madhouse-project.org/algernon/iocaine.git
synced 2025-02-24 02:18:47 +01:00
metrics: Provide an iocaine_garbage_served
metric, too
Some checks failed
documentation / documentation (push) Waiting to run
documentation / notification (push) Blocked by required conditions
lint / linting (push) Waiting to run
build / binary (push) Has been cancelled
build / binary-static (x86_64-linux) (push) Has been cancelled
build / container (push) Has been cancelled
build / clippy (push) Has been cancelled
Some checks failed
documentation / documentation (push) Waiting to run
documentation / notification (push) Blocked by required conditions
lint / linting (push) Waiting to run
build / binary (push) Has been cancelled
build / binary-static (x86_64-linux) (push) Has been cancelled
build / container (push) Has been cancelled
build / clippy (push) Has been cancelled
Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
parent
87c1dfa04b
commit
efa3a203ba
2 changed files with 13 additions and 3 deletions
|
@ -3,9 +3,10 @@ title: "Monitoring iocaine"
|
||||||
description: How to monitor iocaine with Prometheus and Grafana?
|
description: How to monitor iocaine with Prometheus and Grafana?
|
||||||
---
|
---
|
||||||
|
|
||||||
`iocaine` can be [configured](@/configuration/index.md#metrics) to expose [Prometheus](https://prometheus.io)-compatible metrics, separately from the garbage generator. When enabled, two metrics are exposed:
|
`iocaine` can be [configured](@/configuration/index.md#metrics) to expose [Prometheus](https://prometheus.io)-compatible metrics, separately from the garbage generator. When enabled, three metrics are exposed:
|
||||||
|
|
||||||
- `iocaine_requests_total`, a counter of how many hits `iocaine` served, optionally with labels attached (see below).
|
- `iocaine_requests_total`, a counter of how many hits `iocaine` served, optionally with labels attached (see below).
|
||||||
|
- `iocaine_garbage_served`, the number of bytes of generated content served (not including headers, and not counting any compression by the reverse proxy).
|
||||||
- `process_start_time_seconds`, a gauge, a timestamp of when `iocaine` started, to allow measuring uptime.
|
- `process_start_time_seconds`, a gauge, a timestamp of when `iocaine` started, to allow measuring uptime.
|
||||||
|
|
||||||
# The simplest configuration
|
# The simplest configuration
|
||||||
|
@ -23,11 +24,14 @@ This will expose the following metrics on `http://127.0.0.1:42042/metrics`:
|
||||||
# TYPE iocaine_requests_total counter
|
# TYPE iocaine_requests_total counter
|
||||||
iocaine_requests_total 1
|
iocaine_requests_total 1
|
||||||
|
|
||||||
|
# TYPE iocaine_garbage_served counter
|
||||||
|
iocaine_garbage_served 2122
|
||||||
|
|
||||||
# TYPE process_start_time_seconds gauge
|
# TYPE process_start_time_seconds gauge
|
||||||
process_start_time_seconds{service="iocaine"} 1738873005.2406795
|
process_start_time_seconds{service="iocaine"} 1738873005.2406795
|
||||||
```
|
```
|
||||||
|
|
||||||
The `process_start_time_seconds` metric is *always* present, and its value only changes when `iocaine` is restarted. For the sake of brevity, it is excluded from all other examples.
|
The `process_start_time_seconds` and `iocaine_garbage_served` metrics are *always* present. For the sake of brevity, they are excluded from all other examples.
|
||||||
|
|
||||||
# Per-host metrics
|
# Per-host metrics
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,13 @@ fn poison(iocaine: &StatefulIocaine, headers: axum::http::HeaderMap, path: &str)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Html(AssembledStatisticalSequences::generate(iocaine, host, path))
|
let garbage = AssembledStatisticalSequences::generate(iocaine, host, path);
|
||||||
|
|
||||||
|
if iocaine.config.metrics.enable {
|
||||||
|
metrics::counter!("iocaine_garbage_served").increment(garbage.len() as u64);
|
||||||
|
}
|
||||||
|
|
||||||
|
Html(garbage)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn poison_root(
|
async fn poison_root(
|
||||||
|
|
Loading…
Reference in a new issue