From 38ff5c2ce32e8b04fe6c266553e2db9385cc0d70 Mon Sep 17 00:00:00 2001 From: Gwen Lg Date: Tue, 17 Feb 2026 21:33:43 +0100 Subject: [PATCH] style: use `_count` suffix for metrics instead of `_counter` to follow grafana best practice. update monitoring doc and grafana json --- doc/book/reference-manual/admin-api.md | 16 ++--- doc/book/reference-manual/monitoring.md | 58 +++++++++---------- ...rafana-garage-dashboard-elasticsearch.json | 26 ++++----- .../grafana-garage-dashboard-prometheus.json | 8 +-- src/api/common/generic_server.rs | 4 +- src/block/metrics.rs | 12 ++-- src/rpc/metrics.rs | 8 +-- src/table/metrics.rs | 8 +-- src/web/web_server.rs | 4 +- 9 files changed, 72 insertions(+), 72 deletions(-) diff --git a/doc/book/reference-manual/admin-api.md b/doc/book/reference-manual/admin-api.md index fb860d7e..82347436 100644 --- a/doc/book/reference-manual/admin-api.md +++ b/doc/book/reference-manual/admin-api.md @@ -182,14 +182,14 @@ content-type: text/plain; version=0.0.4 content-length: 12145 date: Tue, 08 Aug 2023 07:25:05 GMT -# HELP garage_api_admin_error_counter Number of API calls to the various Admin API endpoints that resulted in errors -# TYPE garage_api_admin_error_counter counter -garage_api_admin_error_counter{api_endpoint="CheckWebsiteEnabled",status_code="400"} 1 -garage_api_admin_error_counter{api_endpoint="CheckWebsiteEnabled",status_code="404"} 3 -# HELP garage_api_admin_request_counter Number of API calls to the various Admin API endpoints -# TYPE garage_api_admin_request_counter counter -garage_api_admin_request_counter{api_endpoint="CheckWebsiteEnabled"} 7 -garage_api_admin_request_counter{api_endpoint="Health"} 3 +# HELP garage_api_admin_error_count Number of API calls to the various Admin API endpoints that resulted in errors +# TYPE garage_api_admin_error_count counter +garage_api_admin_error_count{api_endpoint="CheckWebsiteEnabled",status_code="400"} 1 +garage_api_admin_error_count{api_endpoint="CheckWebsiteEnabled",status_code="404"} 3 +# HELP garage_api_admin_request_count Number of API calls to the various Admin API endpoints +# TYPE garage_api_admin_request_count counter +garage_api_admin_request_count{api_endpoint="CheckWebsiteEnabled"} 7 +garage_api_admin_request_count{api_endpoint="Health"} 3 # HELP garage_api_admin_request_duration Duration of API calls to the various Admin API endpoints ... ``` diff --git a/doc/book/reference-manual/monitoring.md b/doc/book/reference-manual/monitoring.md index 6e3fea05..9275c981 100644 --- a/doc/book/reference-manual/monitoring.md +++ b/doc/book/reference-manual/monitoring.md @@ -135,12 +135,12 @@ garage_cluster_partitions_quorum 256 ### Metrics of the API endpoints -#### `garage_api_admin_request_counter` (counter) +#### `garage_api_admin_request_count` (counter) Counts the number of requests to a given endpoint of the administration API. Example: ``` -garage_api_admin_request_counter{api_endpoint="Metrics"} 127041 +garage_api_admin_request_count{api_endpoint="Metrics"} 127041 ``` #### `garage_api_admin_request_duration` (histogram) @@ -153,20 +153,20 @@ garage_api_admin_request_duration_sum{api_endpoint="Metrics"} 605.250344830999 garage_api_admin_request_duration_count{api_endpoint="Metrics"} 127041 ``` -#### `garage_api_s3_request_counter` (counter) +#### `garage_api_s3_request_count` (counter) Counts the number of requests to a given endpoint of the S3 API. Example: ``` -garage_api_s3_request_counter{api_endpoint="CreateMultipartUpload"} 1 +garage_api_s3_request_count{api_endpoint="CreateMultipartUpload"} 1 ``` -#### `garage_api_s3_error_counter` (counter) +#### `garage_api_s3_error_count` (counter) Counts the number of requests to a given endpoint of the S3 API that returned an error. Example: ``` -garage_api_s3_error_counter{api_endpoint="GetObject",status_code="404"} 39 +garage_api_s3_error_count{api_endpoint="GetObject",status_code="404"} 39 ``` #### `garage_api_s3_request_duration` (histogram) @@ -179,7 +179,7 @@ garage_api_s3_request_duration_sum{api_endpoint="CreateMultipartUpload"} 0.04634 garage_api_s3_request_duration_count{api_endpoint="CreateMultipartUpload"} 1 ``` -#### `garage_api_k2v_request_counter` (counter), `garage_api_k2v_error_counter` (counter), `garage_api_k2v_error_duration` (histogram) +#### `garage_api_k2v_request_count` (counter), `garage_api_k2v_error_count` (counter), `garage_api_k2v_error_duration` (histogram) Same as for S3, for the K2V API. @@ -187,12 +187,12 @@ Same as for S3, for the K2V API. ### Metrics of the Web endpoint -#### `garage_web_request_counter` (counter) +#### `garage_web_request_count` (counter) Number of requests to the web endpoint ``` -garage_web_request_counter{method="GET"} 80 +garage_web_request_count{method="GET"} 80 ``` #### `garage_web_request_duration` (histogram) @@ -205,12 +205,12 @@ garage_web_request_duration_sum{method="GET"} 1.0528433229999998 garage_web_request_duration_count{method="GET"} 80 ``` -#### `garage_web_error_counter` (counter) +#### `garage_web_error_count` (counter) Number of requests to the web endpoint resulting in errors ``` -garage_web_error_counter{method="GET",status_code="404 Not Found"} 64 +garage_web_error_count{method="GET",status_code="404 Not Found"} 64 ``` @@ -257,20 +257,20 @@ garage_block_write_duration_sum 195.59170078500006 garage_block_write_duration_count 3571 ``` -#### `garage_block_delete_counter` (counter) +#### `garage_block_delete_count` (counter) Counts the number of data blocks that have been deleted from storage. ``` -garage_block_delete_counter 122 +garage_block_delete_count 122 ``` -#### `garage_block_resync_counter` (counter), `garage_block_resync_duration` (histogram) +#### `garage_block_resync_count` (counter), `garage_block_resync_duration` (histogram) Counts the number of resync operations the node has executed, and evaluates their duration. ``` -garage_block_resync_counter 308897 +garage_block_resync_count 308897 garage_block_resync_duration_bucket{le="0.5"} 308892 garage_block_resync_duration_sum 139.64204196100016 garage_block_resync_duration_count 308897 @@ -298,28 +298,28 @@ garage_block_resync_errored_blocks 0 ### Metrics related to RPCs (remote procedure calls) between nodes -#### `garage_rpc_netapp_request_counter` (counter) +#### `garage_rpc_netapp_request_count` (counter) Number of RPC requests emitted ``` -garage_rpc_request_counter{from="",rpc_endpoint="garage_block/manager.rs/Rpc",to=""} 176 +garage_rpc_request_count{from="",rpc_endpoint="garage_block/manager.rs/Rpc",to=""} 176 ``` -#### `garage_rpc_netapp_error_counter` (counter) +#### `garage_rpc_netapp_error_count` (counter) Number of communication errors (errors in the Netapp library, generally due to disconnected nodes) ``` -garage_rpc_netapp_error_counter{from="",rpc_endpoint="garage_block/manager.rs/Rpc",to=""} 354 +garage_rpc_netapp_error_count{from="",rpc_endpoint="garage_block/manager.rs/Rpc",to=""} 354 ``` -#### `garage_rpc_timeout_counter` (counter) +#### `garage_rpc_timeout_count` (counter) Number of RPC timeouts, should be close to zero in a healthy cluster. ``` -garage_rpc_timeout_counter{from="",rpc_endpoint="garage_rpc/membership.rs/SystemRpc",to=""} 1 +garage_rpc_timeout_count{from="",rpc_endpoint="garage_rpc/membership.rs/SystemRpc",to=""} 1 ``` #### `garage_rpc_duration` (histogram) @@ -343,43 +343,43 @@ Table garbage collector TODO queue length garage_table_gc_todo_queue_length{table_name="block_ref"} 0 ``` -#### `garage_table_get_request_counter` (counter), `garage_table_get_request_duration` (histogram) +#### `garage_table_get_request_count` (counter), `garage_table_get_request_duration` (histogram) Number of get/get_range requests internally made on each table, and their duration. ``` -garage_table_get_request_counter{table_name="bucket_alias"} 315 +garage_table_get_request_count{table_name="bucket_alias"} 315 garage_table_get_request_duration_bucket{table_name="bucket_alias",le="0.5"} 315 garage_table_get_request_duration_sum{table_name="bucket_alias"} 0.048509778000000024 garage_table_get_request_duration_count{table_name="bucket_alias"} 315 ``` -#### `garage_table_put_request_counter` (counter), `garage_table_put_request_duration` (histogram) +#### `garage_table_put_request_count` (counter), `garage_table_put_request_duration` (histogram) Number of insert/insert_many requests internally made on this table, and their duration ``` -garage_table_put_request_counter{table_name="block_ref"} 677 +garage_table_put_request_count{table_name="block_ref"} 677 garage_table_put_request_duration_bucket{table_name="block_ref",le="0.5"} 677 garage_table_put_request_duration_sum{table_name="block_ref"} 61.617528636 garage_table_put_request_duration_count{table_name="block_ref"} 677 ``` -#### `garage_table_internal_delete_counter` (counter) +#### `garage_table_internal_delete_count` (counter) Number of value deletions in the tree (due to GC or repartitioning) ``` -garage_table_internal_delete_counter{table_name="block_ref"} 2296 +garage_table_internal_delete_count{table_name="block_ref"} 2296 ``` -#### `garage_table_internal_update_counter` (counter) +#### `garage_table_internal_update_count` (counter) Number of value updates where the value actually changes (includes creation of new key and update of existing key) ``` -garage_table_internal_update_counter{table_name="block_ref"} 5996 +garage_table_internal_update_count{table_name="block_ref"} 5996 ``` #### `garage_table_merkle_updater_todo_queue_length` (gauge) diff --git a/script/telemetry/grafana-garage-dashboard-elasticsearch.json b/script/telemetry/grafana-garage-dashboard-elasticsearch.json index d079c161..35f66ed9 100644 --- a/script/telemetry/grafana-garage-dashboard-elasticsearch.json +++ b/script/telemetry/grafana-garage-dashboard-elasticsearch.json @@ -161,7 +161,7 @@ }, "metrics": [ { - "field": "garage_api_request_counter", + "field": "garage_api_request_count", "hide": true, "id": "1", "type": "sum" @@ -412,7 +412,7 @@ }, "metrics": [ { - "field": "garage_api_error_counter", + "field": "garage_api_error_count", "hide": true, "id": "1", "type": "sum" @@ -540,7 +540,7 @@ }, "metrics": [ { - "field": "garage_web_request_counter", + "field": "garage_web_request_count", "hide": true, "id": "1", "type": "sum" @@ -794,7 +794,7 @@ }, "metrics": [ { - "field": "garage_web_error_counter", + "field": "garage_web_error_count", "hide": true, "id": "1", "type": "sum" @@ -918,7 +918,7 @@ "hide": false, "metrics": [ { - "field": "garage_table_get_request_counter", + "field": "garage_table_get_request_count", "hide": true, "id": "1", "type": "sum" @@ -1042,7 +1042,7 @@ "hide": false, "metrics": [ { - "field": "garage_table_put_request_counter", + "field": "garage_table_put_request_count", "hide": true, "id": "1", "type": "sum" @@ -1386,7 +1386,7 @@ }, "metrics": [ { - "field": "garage_block_resync_counter", + "field": "garage_block_resync_count", "hide": true, "id": "1", "type": "sum" @@ -1824,7 +1824,7 @@ }, "metrics": [ { - "field": "garage_block_resync_error_counter", + "field": "garage_block_resync_error_count", "hide": true, "id": "1", "settings": {}, @@ -2041,7 +2041,7 @@ }, "metrics": [ { - "field": "garage_block_corruption_counter", + "field": "garage_block_corruption_count", "hide": true, "id": "1", "type": "sum" @@ -2165,7 +2165,7 @@ }, "metrics": [ { - "field": "garage_rpc_netapp_error_counter", + "field": "garage_rpc_netapp_error_count", "hide": true, "id": "1", "type": "sum" @@ -2292,7 +2292,7 @@ }, "metrics": [ { - "field": "garage_rpc_request_counter", + "field": "garage_rpc_request_count", "hide": true, "id": "1", "type": "sum" @@ -2654,7 +2654,7 @@ }, "metrics": [ { - "field": "garage_rpc_garage_error_counter", + "field": "garage_rpc_garage_error_count", "hide": true, "id": "1", "type": "sum" @@ -2995,4 +2995,4 @@ "uid": "ODT8K4B7e", "version": 7, "weekStart": "" -} \ No newline at end of file +} diff --git a/script/telemetry/grafana-garage-dashboard-prometheus.json b/script/telemetry/grafana-garage-dashboard-prometheus.json index 421cb4db..10b3a911 100644 --- a/script/telemetry/grafana-garage-dashboard-prometheus.json +++ b/script/telemetry/grafana-garage-dashboard-prometheus.json @@ -250,7 +250,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "sum by (api_endpoint) (rate(garage_api_s3_request_counter {job=\"garage\"}[$__rate_interval]))", + "expr": "sum by (api_endpoint) (rate(garage_api_s3_request_count {job=\"garage\"}[$__rate_interval]))", "hide": false, "interval": "", "legendFormat": "{{api_endpoint}}", @@ -345,7 +345,7 @@ "uid": "${DS_DS_PROMETHEUS}" }, "exemplar": true, - "expr": "sum(rate(garage_web_request_counter {job=\"garage\"}[$__rate_interval]))", + "expr": "sum(rate(garage_web_request_count {job=\"garage\"}[$__rate_interval]))", "hide": false, "interval": "", "legendFormat": "Web request rate", @@ -439,7 +439,7 @@ "uid": "${DS_DS_PROMETHEUS}" }, "exemplar": true, - "expr": "sum by (rpc_endpoint) (rate(garage_rpc_request_counter {job=\"garage\"}[$__rate_interval]))", + "expr": "sum by (rpc_endpoint) (rate(garage_rpc_request_count {job=\"garage\"}[$__rate_interval]))", "hide": false, "interval": "", "legendFormat": "{{rpc_endpoint}}", @@ -534,7 +534,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "sum by (api_endpoint, status_code) (rate(garage_api_s3_error_counter {job=\"garage\"}[$__rate_interval]))", + "expr": "sum by (api_endpoint, status_code) (rate(garage_api_s3_error_count {job=\"garage\"}[$__rate_interval]))", "hide": false, "interval": "", "legendFormat": "{{api_endpoint}} {{status_code}}", diff --git a/src/api/common/generic_server.rs b/src/api/common/generic_server.rs index 87a5637d..458536e3 100644 --- a/src/api/common/generic_server.rs +++ b/src/api/common/generic_server.rs @@ -84,14 +84,14 @@ impl ApiServer { region, api_handler, request_counter: meter - .u64_counter(format!("garage_api.{}.request_counter", A::API_NAME)) + .u64_counter(format!("garage_api.{}.request_count", A::API_NAME)) .with_description(format!( "Number of API calls to the various {} API endpoints", A::API_NAME_DISPLAY )) .init(), error_counter: meter - .u64_counter(format!("garage_api.{}.error_counter", A::API_NAME)) + .u64_counter(format!("garage_api.{}.error_count", A::API_NAME)) .with_description(format!( "Number of API calls to the various {} API endpoints that resulted in errors", A::API_NAME_DISPLAY diff --git a/src/block/metrics.rs b/src/block/metrics.rs index e2cabbd3..a084add9 100644 --- a/src/block/metrics.rs +++ b/src/block/metrics.rs @@ -86,12 +86,12 @@ impl BlockManagerMetrics { .init(), resync_counter: meter - .u64_counter("garage_block.resync_counter") + .u64_counter("garage_block.resync_count") .with_description("Number of calls to resync_block") .init() .bind(&[]), resync_error_counter: meter - .u64_counter("garage_block.resync_error_counter") + .u64_counter("garage_block.resync_error_count") .with_description("Number of calls to resync_block that returned an error") .init() .bind(&[]), @@ -101,11 +101,11 @@ impl BlockManagerMetrics { .init() .bind(&[]), resync_send_counter: meter - .u64_counter("garage_block.resync_send_counter") + .u64_counter("garage_block.resync_send_count") .with_description("Number of blocks sent to another node in resync operations") .init(), resync_recv_counter: meter - .u64_counter("garage_block.resync_recv_counter") + .u64_counter("garage_block.resync_recv_count") .with_description("Number of blocks received from other nodes in resync operations") .init() .bind(&[]), @@ -136,13 +136,13 @@ impl BlockManagerMetrics { .init() .bind(&[]), delete_counter: meter - .u64_counter("garage_block.delete_counter") + .u64_counter("garage_block.delete_count") .with_description("Number of blocks deleted") .init() .bind(&[]), corruption_counter: meter - .u64_counter("garage_block.corruption_counter") + .u64_counter("garage_block.corruption_count") .with_description("Data corruptions detected on block reads") .init() .bind(&[]), diff --git a/src/rpc/metrics.rs b/src/rpc/metrics.rs index 25a028ae..178897ad 100644 --- a/src/rpc/metrics.rs +++ b/src/rpc/metrics.rs @@ -14,19 +14,19 @@ impl RpcMetrics { let meter = global::meter("garage_rpc"); RpcMetrics { rpc_counter: meter - .u64_counter("garage_rpc.request_counter") + .u64_counter("garage_rpc.request_count") .with_description("Number of RPC requests emitted") .init(), rpc_timeout_counter: meter - .u64_counter("garage_rpc.timeout_counter") + .u64_counter("garage_rpc.timeout_count") .with_description("Number of RPC timeouts") .init(), rpc_netapp_error_counter: meter - .u64_counter("garage_rpc.netapp_error_counter") + .u64_counter("garage_rpc.netapp_error_count") .with_description("Number of communication errors (errors in the Netapp library)") .init(), rpc_garage_error_counter: meter - .u64_counter("garage_rpc.garage_error_counter") + .u64_counter("garage_rpc.garage_error_count") .with_description("Number of RPC errors (errors happening when handling the RPC)") .init(), rpc_duration: meter diff --git a/src/table/metrics.rs b/src/table/metrics.rs index b9caaf7b..1946b6ab 100644 --- a/src/table/metrics.rs +++ b/src/table/metrics.rs @@ -104,7 +104,7 @@ impl TableMetrics { .init(), get_request_counter: meter - .u64_counter("garage_table.get_request_counter") + .u64_counter("garage_table.get_request_count") .with_description("Number of get/get_range requests internally made on this table") .init() .bind(&[KeyValue::new("table_name", table_name)]), @@ -114,7 +114,7 @@ impl TableMetrics { .init() .bind(&[KeyValue::new("table_name", table_name)]), put_request_counter: meter - .u64_counter("garage_table.put_request_counter") + .u64_counter("garage_table.put_request_count") .with_description("Number of insert/insert_many requests internally made on this table") .init() .bind(&[KeyValue::new("table_name", table_name)]), @@ -125,12 +125,12 @@ impl TableMetrics { .bind(&[KeyValue::new("table_name", table_name)]), internal_update_counter: meter - .u64_counter("garage_table.internal_update_counter") + .u64_counter("garage_table.internal_update_count") .with_description("Number of value updates where the value actually changes (includes creation of new key and update of existing key)") .init() .bind(&[KeyValue::new("table_name", table_name)]), internal_delete_counter: meter - .u64_counter("garage_table.internal_delete_counter") + .u64_counter("garage_table.internal_delete_count") .with_description("Number of value deletions in the tree (due to GC or repartitioning)") .init() .bind(&[KeyValue::new("table_name", table_name)]), diff --git a/src/web/web_server.rs b/src/web/web_server.rs index e32266dc..69392c86 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -54,11 +54,11 @@ impl WebMetrics { let meter = global::meter("garage/web"); Self { request_counter: meter - .u64_counter("garage_web.request_counter") + .u64_counter("garage_web.request_count") .with_description("Number of requests to the web endpoint") .init(), error_counter: meter - .u64_counter("garage_web.error_counter") + .u64_counter("garage_web.error_count") .with_description("Number of requests to the web endpoint resulting in errors") .init(), request_duration: meter