diff --git a/src/handlers/delete_client.rs b/src/handlers/delete_client.rs index dbbe4094..8cf8e9d2 100644 --- a/src/handlers/delete_client.rs +++ b/src/handlers/delete_client.rs @@ -1,6 +1,5 @@ use { crate::{ - decrement_counter, error::{Error::InvalidAuthentication, Result}, handlers::{authenticate_client, Response, DECENTRALIZED_IDENTIFIER_PREFIX}, log::prelude::*, @@ -63,7 +62,5 @@ pub async fn handler( "deleted client" ); - decrement_counter!(state.metrics, registered_clients); - Ok(Response::default()) } diff --git a/src/handlers/delete_tenant.rs b/src/handlers/delete_tenant.rs index fcb96ab7..0905c4ee 100644 --- a/src/handlers/delete_tenant.rs +++ b/src/handlers/delete_tenant.rs @@ -1,8 +1,5 @@ use { - crate::{ - decrement_counter, error::Error, handlers::validate_tenant_request, log::prelude::*, - state::AppState, - }, + crate::{error::Error, handlers::validate_tenant_request, log::prelude::*, state::AppState}, axum::{ extract::{Path, State}, http::HeaderMap, @@ -42,8 +39,6 @@ pub async fn handler( state.tenant_store.delete_tenant(&id).await?; - decrement_counter!(state.metrics, registered_tenants); - debug!( tenant_id = %id, "deleted tenant" diff --git a/src/metrics/mod.rs b/src/metrics/mod.rs index 1deda837..85bbe7c7 100644 --- a/src/metrics/mod.rs +++ b/src/metrics/mod.rs @@ -1,7 +1,7 @@ use { crate::error::{Error, Result}, opentelemetry::{ - metrics::{Counter, UpDownCounter}, + metrics::Counter, sdk::{ self, export::metrics::aggregation, @@ -22,8 +22,8 @@ pub struct Metrics { pub sent_fcm_v1_notifications: Counter, pub sent_apns_notifications: Counter, - pub registered_clients: UpDownCounter, - pub registered_tenants: UpDownCounter, + pub registered_clients: Counter, + pub registered_tenants: Counter, pub tenant_apns_updates: Counter, pub tenant_fcm_updates: Counter, @@ -54,12 +54,12 @@ impl Metrics { let meter = opentelemetry::global::meter("echo-server"); let clients_counter = meter - .i64_up_down_counter("registered_clients") + .u64_counter("registered_clients") .with_description("The number of currently registered clients") .init(); let tenants_counter = meter - .i64_up_down_counter("registered_tenants") + .u64_counter("registered_tenants") .with_description("The number of currently registered tenants") .init(); diff --git a/terraform/monitoring/main.tf b/terraform/monitoring/main.tf index c34ed7c3..a7f640b9 100644 --- a/terraform/monitoring/main.tf +++ b/terraform/monitoring/main.tf @@ -149,71 +149,6 @@ resource "grafana_dashboard" "at_a_glance" { "title" : "Notifications per Hour", "type" : "stat" }, - { - "datasource" : { - "type" : "prometheus", - "uid" : grafana_data_source.prometheus.uid - }, - "fieldConfig" : { - "defaults" : { - "color" : { - "mode" : "thresholds" - }, - "mappings" : [], - "thresholds" : { - "mode" : "absolute", - "steps" : [ - { - "color" : "green", - "value" : null - }, - { - "color" : "red", - "value" : 80 - } - ] - } - }, - "overrides" : [] - }, - "gridPos" : { - "h" : 8, - "w" : 10, - "x" : 11, - "y" : 0 - }, - "id" : 16, - "options" : { - "colorMode" : "value", - "graphMode" : "area", - "justifyMode" : "auto", - "orientation" : "auto", - "reduceOptions" : { - "calcs" : [ - "lastNotNull" - ], - "fields" : "", - "values" : false - }, - "textMode" : "auto" - }, - "pluginVersion" : "8.4.7", - "targets" : [ - { - "datasource" : { - "type" : "prometheus", - "uid" : grafana_data_source.prometheus.uid - }, - "exemplar" : true, - "expr" : "sum(rate(registered_clients{}[1h]))", - "interval" : "", - "legendFormat" : "", - "refId" : "A" - } - ], - "title" : "Client Registrations per Hour", - "type" : "stat" - }, { "gridPos" : { "h" : 1, @@ -417,13 +352,13 @@ resource "grafana_dashboard" "at_a_glance" { "uid" : grafana_data_source.prometheus.uid }, "exemplar" : true, - "expr" : "sum(increase(registered_clients{}[1h]))", + "expr" : "sum(rate(registered_clients{}[$__rate_interval]))", "interval" : "", "legendFormat" : "", "refId" : "Clients" } ], - "title" : "Registered Clients past 1h", + "title" : "Client registration rate", "type" : "timeseries" }, {