Skip to content

Commit 3c968b8

Browse files
committed
Update metrics
1 parent a5e6786 commit 3c968b8

9 files changed

+267
-142
lines changed

common/src/settings.rs

+19-12
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ pub struct Monitoring {
374374
listen_address: String,
375375
listen_port: u16,
376376
http_request_duration_buckets: Option<Vec<f64>>,
377-
count_received_events_per_machine: Option<bool>,
378-
count_event_size_per_machine: Option<bool>,
377+
count_input_events_per_machine: Option<bool>,
378+
count_input_event_bytes_per_machine: Option<bool>,
379379
count_http_request_body_network_size_per_machine: Option<bool>,
380380
count_http_request_body_real_size_per_machine: Option<bool>,
381381
}
@@ -398,12 +398,12 @@ impl Monitoring {
398398
}
399399
}
400400

401-
pub fn count_received_events_per_machine(&self) -> bool {
402-
self.count_received_events_per_machine.unwrap_or(false)
401+
pub fn count_input_events_per_machine(&self) -> bool {
402+
self.count_input_events_per_machine.unwrap_or(false)
403403
}
404404

405-
pub fn count_event_size_per_machine(&self) -> bool {
406-
self.count_event_size_per_machine.unwrap_or(false)
405+
pub fn count_input_event_bytes_per_machine(&self) -> bool {
406+
self.count_input_event_bytes_per_machine.unwrap_or(false)
407407
}
408408

409409
pub fn count_http_request_body_network_size_per_machine(&self) -> bool {
@@ -632,7 +632,9 @@ mod tests {
632632
assert_eq!(s.monitoring().unwrap().listen_address(), "127.0.0.1");
633633
assert_eq!(s.monitoring().unwrap().listen_port(), 9090);
634634
assert_eq!(
635-
s.monitoring().unwrap().count_event_size_per_machine(),
635+
s.monitoring()
636+
.unwrap()
637+
.count_input_event_bytes_per_machine(),
636638
false
637639
);
638640
assert_eq!(
@@ -648,7 +650,7 @@ mod tests {
648650
false
649651
);
650652
assert_eq!(
651-
s.monitoring().unwrap().count_received_events_per_machine(),
653+
s.monitoring().unwrap().count_input_events_per_machine(),
652654
false
653655
);
654656
assert_eq!(
@@ -688,10 +690,10 @@ mod tests {
688690
listen_address = "127.0.0.1"
689691
listen_port = 9090
690692
http_request_duration_buckets = [0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0]
691-
count_event_size_per_machine = true
693+
count_input_event_bytes_per_machine = true
692694
count_http_request_body_network_size_per_machine = true
693695
count_http_request_body_real_size_per_machine = true
694-
count_received_events_per_machine = true
696+
count_input_events_per_machine = true
695697
"#;
696698

697699
#[test]
@@ -702,7 +704,12 @@ mod tests {
702704
assert!(s.monitoring().is_some());
703705
assert_eq!(s.monitoring().unwrap().listen_address(), "127.0.0.1");
704706
assert_eq!(s.monitoring().unwrap().listen_port(), 9090);
705-
assert_eq!(s.monitoring().unwrap().count_event_size_per_machine(), true);
707+
assert_eq!(
708+
s.monitoring()
709+
.unwrap()
710+
.count_input_event_bytes_per_machine(),
711+
true
712+
);
706713
assert_eq!(
707714
s.monitoring()
708715
.unwrap()
@@ -716,7 +723,7 @@ mod tests {
716723
true
717724
);
718725
assert_eq!(
719-
s.monitoring().unwrap().count_received_events_per_machine(),
726+
s.monitoring().unwrap().count_input_events_per_machine(),
720727
true
721728
);
722729
assert_eq!(

common/src/subscription.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
use anyhow::{anyhow, bail, Result};
99
use log::{info, warn};
1010
use serde::{Deserialize, Serialize};
11-
use strum::{AsRefStr, EnumString, VariantNames};
11+
use strum::{AsRefStr, EnumString, IntoStaticStr, VariantNames};
1212
use uuid::Uuid;
1313

1414
use crate::utils::VersionHasher;
@@ -96,12 +96,8 @@ pub struct FilesConfiguration {
9696
}
9797

9898
impl FilesConfiguration {
99-
pub fn new(
100-
path: String,
101-
) -> Self {
102-
Self {
103-
path
104-
}
99+
pub fn new(path: String) -> Self {
100+
Self { path }
105101
}
106102

107103
pub fn path(&self) -> &str {
@@ -182,7 +178,17 @@ impl Display for SubscriptionOutput {
182178
}
183179
}
184180
#[derive(
185-
Debug, Clone, Eq, PartialEq, Serialize, Deserialize, Hash, VariantNames, AsRefStr, EnumString,
181+
Debug,
182+
Clone,
183+
Eq,
184+
PartialEq,
185+
Serialize,
186+
Deserialize,
187+
Hash,
188+
VariantNames,
189+
AsRefStr,
190+
EnumString,
191+
IntoStaticStr,
186192
)]
187193
#[strum(serialize_all = "snake_case", ascii_case_insensitive)]
188194
pub enum SubscriptionOutputFormat {
@@ -683,8 +689,8 @@ impl SubscriptionData {
683689
self
684690
}
685691

686-
/// Set the subscription's max elements.
687-
pub fn set_max_elements(&mut self, max_elements: Option<u32>) -> &mut Self {
692+
/// Set the subscription's max elements.
693+
pub fn set_max_elements(&mut self, max_elements: Option<u32>) -> &mut Self {
688694
self.parameters.max_elements = max_elements;
689695
self.update_internal_version();
690696
self

doc/monitoring.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ Metrics collection and publication can be enabled in the OpenWEC settings (see `
4343

4444
| **Metric** | **Type** | **Labels** | **Description** |
4545
|---|---|---|---|
46-
| `openwec_received_events_total` | `Counter` | `subscription_uuid`, `subscription_name`, `machine` (optional*) | Number of events received by openwec |
47-
| `openwec_event_size_bytes_total` | `Counter` | `subscription_uuid`, `subscription_name`, `machine` (optional*) | The total size of all events received by openwec |
48-
| `http_request_body_real_size_bytes_total` | `Counter` | `method`, `uri`, `machine` (optional*) | The total size of all http requests body received by openwec after decryption and decompression |
49-
| `http_request_body_network_size_bytes_total` | `Counter` | `method`, `uri`, `machine` (optional*) | The total size of all http requests body received by openwec |
50-
| `openwec_messages_total` | `Counter` | `action` (one of `"enumerate"`, `"heartbeat"`, `"events"`) | Number of messages received by openwec |
51-
| `openwec_event_output_failures_total` | `Counter` | `subscription_uuid`, `subscription_name` | Number of events that could not be written to outputs by openwec |
52-
| `http_request_duration_seconds` | `Histogram` | `method`, `status`, `uri` | HTTP requests duration histogram |
46+
| `openwec_input_events_total` | `Counter` | `subscription_uuid`, `subscription_name`, `machine` (optional*) | The total number of events received by openwec |
47+
| `openwec_input_event_bytes_total` | `Counter` | `subscription_uuid`, `subscription_name`, `machine` (optional*) | The total size of all events received by openwec |
48+
| `openwec_input_messages_total` | `Counter` | `action` (one of `"enumerate"`, `"heartbeat"`, `"events"`) | The total number of messages received by openwec |
49+
| `openwec_input_event_parsing_failures_total` | `Counter` | `subscription_uuid`, `subscription_name`, `type` | The total number of event parsing failures |
50+
| `openwec_http_requests_total` | `Counter` | `uri`, `code` | The total number of HTTP requests handled by openwec |
51+
| `openwec_http_request_duration_seconds` | `Histogram` | `uri` | Histogram of response duration for HTTP requests |
52+
| `openwec_http_request_body_network_size_bytes_total` | `Counter` | `uri`, `machine` (optional*) | The total size of all http requests body received by openwec |
53+
| `openwec_http_request_body_real_size_bytes_total` | `Counter` | `uri`, `machine` (optional*) | The total size of all http requests body received by openwec after decryption and decompression |
54+
| `openwec_output_driver_failures_total` | `Counter` | `subscription_uuid`, `subscription_name`, `driver` | The total number of output driver failures |
55+
| `openwec_output_format_failures_total` | `Counter` | `subscription_uuid`, `subscription_name`, `format` | The total number of output format failures |
5356

5457
> [!WARNING]
5558
> Enabling the `machine` labels may cause a **huge** increase in metric cardinality!

openwec.conf.sample.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -322,25 +322,25 @@
322322
# listen_port =
323323

324324
# [Optional]
325-
# Request duration buckets (in seconds) used by the "http_request_duration_seconds" histogram
325+
# Request duration buckets (in seconds) used by the "openwec_http_request_duration_seconds" histogram
326326
# http_request_duration_buckets = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0]
327327

328328
# [Optional]
329-
# If set, a "machine" label will be added to the "openwec_received_events_total" metric
329+
# If set, a "machine" label will be added to the "openwec_input_events_total" metric
330330
# Warning: this may cause a HUGE increase in metric cardinality
331-
# count_received_events_per_machine = false
331+
# count_input_events_per_machine = false
332332

333333
# [Optional]
334-
# If set, a "machine" label will be added to the "openwec_event_size_bytes_total" metric
334+
# If set, a "machine" label will be added to the "openwec_input_event_bytes_total" metric
335335
# Warning: this may cause a HUGE increase in metric cardinality
336-
# count_event_size_per_machine = false
336+
# count_input_event_bytes_per_machine = false
337337

338338
# [Optional]
339-
# If set, a "machine" label will be added to the "http_request_body_network_size_bytes_total" metric
339+
# If set, a "machine" label will be added to the "openwec_http_request_body_network_size_bytes_total" metric
340340
# Warning: this may cause a HUGE increase in metric cardinality
341341
# count_http_request_body_network_size_per_machine = false
342342

343343
# [Optional]
344-
# If set, a "machine" label will be added to the "http_request_body_real_size_bytes_total" metric
344+
# If set, a "machine" label will be added to the "openwec_http_request_body_real_size_bytes_total" metric
345345
# Warning: this may cause a HUGE increase in metric cardinality
346346
# count_http_request_body_real_size_per_machine = false

0 commit comments

Comments
 (0)