Skip to content

Commit f66e31f

Browse files
committed
Documentation update and fix some typo
1 parent 24f5bc4 commit f66e31f

File tree

5 files changed

+25
-50
lines changed

5 files changed

+25
-50
lines changed

docs/runbook/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ This page gathers the available guides to operate a Mithril network.
2323
| **Publish packages to npm manually** | [manual-publish-npm](./manual-publish-npm/README.md) | Manually publish packages to npm registry. |
2424
| **Client multi-platform test** | [test-client-multiplatform](./test-client-multiplatform/README.md) | Run multi-platform client CLI binaries, docker and WASM package tests. |
2525
| **Maintain the networks configuration file** | [maintain-networks-configuration-file](./maintain-networks-configuration-file/README.md) | Maintain the `networks.json` file |
26-
| **Aggregator metrics** | [aggregator-metrics](./aggregator-metrics/README.md) | Display aggregator metrics . |
26+
| **Aggregator metrics** | [aggregator-metrics](./aggregator-metrics/README.md) | Display aggregator daily metrics. |
Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,24 @@
11
# Aggregator metrics
22

3-
Aggregator metrics are stored in `monitoring.sqlite3` database as an event.
4-
5-
They are stored in database with `Metrics` as `source` and the name of the metric as `action`.
6-
7-
| event_id | created_at | source | action | content |
8-
| -------- | ----------------------------------- | ------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
9-
| 104 | 2024-10-29T10:27:49.843362986+00:00 | Metrics | mithril_aggregator_signer_registration_total_received_since_startup | `{"content":{"counter":2,"date":"2024-10-29T10:27:49.842316726Z","duration":{"nanos":0,"secs":3}},"headers":{}} ` |
10-
| |
11-
12-
The content of the metric is a json that contains the counter value, the date the value was measured and the duration that corresponds to the measurement.
13-
14-
Json sample:
15-
16-
```json
17-
{
18-
"content": {
19-
"counter": 6,
20-
"date": "2024-10-28T16:43:18.858027008Z",
21-
"duration": {
22-
"nanos": 0,
23-
"secs": 10
24-
}
25-
},
26-
"headers": {}
27-
}
28-
```
29-
30-
Each event represents the number of hits on the counter since the last period of timed.
31-
323
A view `metrics_per_day` is available to calculate the value of a metric over a day.
334

345
The following request displays the sum of counter for each metric on the specify day.
35-
`select date, counter_name, value from metrics_per_day where date='2024-10-29';`
6+
Format of `DAY` variable should be `YYYY-MM-DD` (ie: `2024-10-28`).
7+
8+
```sh
9+
$> sqlite3 -table -batch \
10+
$DATA_STORES_DIRECTORY/monitoring.sqlite3 \
11+
`select date, counter_name, value from metrics_per_day where date='$DAY';`
12+
```
3613

3714
The result looks like:
3815

3916
```
40-
2024-10-29|mithril_aggregator_certificate_total_produced_since_startup|32
41-
2024-10-29|mithril_aggregator_runtime_cycle_success_since_startup|131
42-
2024-10-29|mithril_aggregator_runtime_cycle_total_since_startup|239
17+
+------------+-------------------------------------------------------------+--------+
18+
| date | counter_name | value |
19+
+------------+-------------------------------------------------------------+--------+
20+
| 2024-10-29 | mithril_aggregator_certificate_total_produced_since_startup | 135532 |
21+
| 2024-10-29 | mithril_aggregator_runtime_cycle_success_since_startup | 563246 |
22+
| 2024-10-29 | mithril_aggregator_runtime_cycle_total_since_startup | 237513 |
23+
+------------+-------------------------------------------------------------+--------+
4324
```
44-
45-
NOTE: These metrics should not be used to have an exact count. There may be slight discrepancies with reality.
46-
When stopping the aggregator, last measure may not be counted.
47-
48-
The measurement extends over a period of time which may have started the previous day.
49-
In this case, the value is counted for the day the measurement was taken.
50-
51-
The measurement frequency is relatively short and can be configured by setting the environment variable `PERSIST_USAGE_REPORT_INTERVAL_IN_SECONDS`.

docs/website/root/manual/developer-docs/nodes/mithril-aggregator.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ Here is a list of the available parameters:
456456
| `enable_metrics_server` | `--enable-metrics-server` | - | `ENABLE_METRICS_SERVER` | Enable metrics HTTP server (Prometheus endpoint on /metrics) | `false` | - | - |
457457
| `metrics_server_ip` | `--metrics-server-ip` | - | `METRICS_SERVER_IP` | Metrics HTTP server IP | `0.0.0.0` | - | - |
458458
| `metrics_server_port` | `--metrics-server-port` | - | `METRICS_SERVER_PORT` | Metrics HTTP server listening port | `9090` | - | - |
459+
| `persist_usage_report_interval_in_seconds` | | - | `PERSIST_USAGE_REPORT_INTERVAL_IN_SECONDS` | Duration in seconds between two recording of usage metrics | `10` | `5` | - |
459460

460461
`genesis bootstrap` command:
461462

mithril-aggregator/src/event_store/database/repository.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mod tests {
8181
fn get_all_metrics(
8282
connection: Arc<ConnectionThreadSafe>,
8383
) -> StdResult<Vec<(String, String, i64)>> {
84-
let query = "SELECT date, counter_name, value FROM metrics_per_day";
84+
let query = "select date, counter_name, value from metrics_per_day";
8585
let mut statement = connection.prepare(query)?;
8686
let mut result = Vec::new();
8787
while let Ok(sqlite::State::Row) = statement.next() {
@@ -95,7 +95,7 @@ mod tests {
9595
Ok(result)
9696
}
9797

98-
/// Insert a metric evnet in the database.
98+
/// Insert a metric event in the database.
9999
/// date format is "%Y-%m-%d %H:%M:%S %z", example: "2015-09-05 23:56:04 +0000"
100100
fn insert_metric_event(
101101
persister: &EventPersister,

mithril-aggregator/src/services/usage_reporter.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use slog::{info, Logger};
1111

1212
/// Message sent to the event store to report a metric value.
1313
#[derive(Serialize, Deserialize)]
14-
struct MetricMessage {
14+
struct MetricEventMessage {
1515
counter: i64,
1616
duration: Duration,
1717
date: DateTime<Utc>,
@@ -56,18 +56,18 @@ impl UsageReporter {
5656

5757
fn send_metrics(&mut self, duration: &Duration) {
5858
let metrics = self.metric_service.export_metrics_map();
59-
let delta = UsageReporter::metrics_delta(&self.last_metrics, &metrics);
59+
let delta = Self::metrics_delta(&self.last_metrics, &metrics);
6060
let date = Utc::now();
6161

6262
self.last_metrics = metrics;
6363

6464
for (name, value) in delta {
6565
let _result = self
6666
.transmitter_service
67-
.send_event_message::<MetricMessage>(
67+
.send_event_message::<MetricEventMessage>(
6868
"Metrics",
6969
&name,
70-
&MetricMessage {
70+
&MetricEventMessage {
7171
counter: value,
7272
duration: *duration,
7373
date,
@@ -130,7 +130,8 @@ mod tests {
130130
}
131131

132132
fn extract_metric_value(message: &EventMessage) -> (String, i64) {
133-
let metric_delta: MetricMessage = serde_json::from_value(message.content.clone()).unwrap();
133+
let metric_delta: MetricEventMessage =
134+
serde_json::from_value(message.content.clone()).unwrap();
134135
(message.action.clone(), metric_delta.counter)
135136
}
136137

@@ -156,7 +157,7 @@ mod tests {
156157
let message = &received_messages[0];
157158
assert_eq!(message.source, "Metrics");
158159
assert_eq!(message.action, metric.name());
159-
let message_content: MetricMessage =
160+
let message_content: MetricEventMessage =
160161
serde_json::from_value(message.content.clone()).unwrap();
161162
assert_eq!(3, message_content.counter);
162163
assert_eq!(Duration::from_secs(10), message_content.duration);

0 commit comments

Comments
 (0)