Skip to content

Commit 1145d8e

Browse files
committed
prometheus: Add core metrics per-mount for free space and limit
This adds two gauge metrics which are emitted per configured mount, one for available bytes and the other for the low watermark. The label `"disk=<name>"` is attached to both gauges to distinguish which mount the gauge applies to.
1 parent 5aeb92e commit 1145d8e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

deps/rabbitmq_prometheus/metrics.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ These metrics are specific to the stream protocol.
136136
| rabbitmq_process_resident_memory_bytes | Memory used in bytes |
137137
| rabbitmq_resident_memory_limit_bytes | Memory high watermark in bytes |
138138

139+
### Per-mount disk space
140+
141+
| Metric | Description |
142+
| --- | --- |
143+
| rabbitmq_mount_space_available_bytes | Disk space available in bytes on configured mount |
144+
| rabbitmq_mount_space_available_limit_bytes | Disk space available low watermark in bytes on configured mount |
145+
146+
Both metrics have a `disk` label identifying the configured disk name which was measured.
147+
139148
### Connections
140149

141150
| Metric | Description |

deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
{2, undefined, erlang_net_ticktime_seconds, gauge, "Inter-node heartbeat interval", net_ticktime},
8686
{2, ?MILLISECOND, erlang_uptime_seconds, gauge, "Node uptime", uptime}
8787
]},
88+
{mount_metrics, [
89+
{2, undefined, mount_space_available_bytes, gauge, "Disk space available in bytes on configured mount"},
90+
{3, undefined, mount_space_available_limit_bytes, gauge, "Disk space available low watermark in bytes on configured mount"}
91+
]},
8892

8993
{node_persister_metrics, [
9094
{2, undefined, io_read_ops_total, counter, "Total number of I/O read operations", io_read_count},
@@ -856,6 +860,12 @@ get_data(exchange_names, _, _) ->
856860
Label = <<"vhost=\"", VHost/binary, "\",exchange=\"", Name/binary, "\",type=\"", (atom_to_binary(EType))/binary, "\"">>,
857861
[{Label, 1}|Acc]
858862
end, [], rabbit_exchange:list());
863+
get_data(mount_metrics, _, _) ->
864+
[{<<"disk=", Name/binary>>, Available, Limit}
865+
|| #{name := Name,
866+
available := Available,
867+
limit := Limit} <- rabbit_disk_monitor:get_mount_free(),
868+
Available =/= 'NaN'];
859869
get_data(Table, _, _) ->
860870
ets:tab2list(Table).
861871

0 commit comments

Comments
 (0)