Skip to content

Commit b0e61cb

Browse files
Merge pull request #11751 from rabbitmq/mergify/bp/v4.0.x/pr-11746
2 parents 6ca765b + 5396599 commit b0e61cb

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
-define(METRICS_RAW, [
5959

60-
%%% Those are global, i.e. they contain no reference to queue/vhost/channel
60+
%% Global metrics, as in, they contain no references to queues, virtual hosts or channel
6161
{connection_churn_metrics, [
6262
{2, undefined, connections_opened_total, counter, "Total number of connections opened"},
6363
{3, undefined, connections_closed_total, counter, "Total number of connections closed or terminated"},
@@ -86,6 +86,35 @@
8686
{2, ?MILLISECOND, erlang_uptime_seconds, gauge, "Node uptime", uptime}
8787
]},
8888

89+
{node_memory, [
90+
{2, undefined, memory_code_module_bytes, gauge, "Code module memory footprint", code},
91+
{2, undefined, memory_client_connection_reader_bytes, gauge, "Client connection reader processes footprint in bytes", connection_readers},
92+
{2, undefined, memory_client_connection_writer_bytes, gauge, "Client connection writer processes footprint in bytes", connection_writers},
93+
{2, undefined, memory_client_connection_channel_bytes, gauge, "Client connection channel processes footprint in bytes", connection_channels},
94+
{2, undefined, memory_client_connection_other_bytes, gauge, "Client connection other processes footprint in bytes", connection_other},
95+
{2, undefined, memory_classic_queue_erlang_process_bytes, gauge, "Classic queue processes footprint in bytes", queue_procs},
96+
{2, undefined, memory_quorum_queue_erlang_process_bytes, gauge, "Quorum queue processes footprint in bytes", quorum_queue_procs},
97+
{2, undefined, memory_quorum_queue_dlx_erlang_process_bytes, gauge, "Quorum queue DLX worker processes footprint in bytes", quorum_queue_dlx_procs},
98+
{2, undefined, memory_stream_erlang_process_bytes, gauge, "Stream processes footprint in bytes", stream_queue_procs},
99+
{2, undefined, memory_stream_replica_reader_erlang_process_bytes, gauge, "Stream replica reader processes footprint in bytes", stream_queue_replica_reader_procs},
100+
{2, undefined, memory_stream_coordinator_erlang_process_bytes, gauge, "Stream coordinator processes footprint in bytes", stream_queue_coordinator_procs},
101+
{2, undefined, memory_plugin_bytes, gauge, "Total plugin footprint in bytes", plugins},
102+
{2, undefined, memory_modern_metadata_store_bytes, gauge, "Modern metadata store footprint in bytes", metadata_store},
103+
{2, undefined, memory_other_erlang_process_bytes, gauge, "Other processes footprint in bytes", other_proc},
104+
{2, undefined, memory_metrics_bytes, gauge, "Metric table footprint in bytes", metrics},
105+
{2, undefined, memory_management_stats_db_bytes, gauge, "Management stats database footprint in bytes", mgmt_db},
106+
{2, undefined, memory_classic_metadata_store_bytes, gauge, "Classic metadata store footprint in bytes", mnesia},
107+
{2, undefined, memory_quorum_queue_ets_table_bytes, gauge, "Quorum queue ETS tables footprint in bytes", quorum_ets},
108+
{2, undefined, memory_modern_metadata_store_ets_table_bytes, gauge, "Modern metadata store ETS tables footprint in bytes", metadata_store_ets},
109+
{2, undefined, memory_other_ets_table_bytes, gauge, "Other ETS tables footprint in bytes", other_ets},
110+
{2, undefined, memory_binary_heap_bytes, gauge, "Binary heap size in bytes", binary},
111+
{2, undefined, memory_message_index_bytes, gauge, "Message index footprint in bytes", msg_index},
112+
{2, undefined, memory_atom_table_bytes, gauge, "Atom table size in bytes", atom},
113+
{2, undefined, memory_other_system_bytes, gauge, "Other runtime footprint in bytes", other_system},
114+
{2, undefined, memory_runtime_allocated_unused_bytes, gauge, "Runtime allocated but unused blocks size in bytes", allocated_unused},
115+
{2, undefined, memory_runtime_reserved_unallocated_bytes, gauge, "Runtime reserved but unallocated blocks size in bytes", reserved_unallocated}
116+
]},
117+
89118
{node_persister_metrics, [
90119
{2, undefined, io_read_ops_total, counter, "Total number of I/O read operations", io_read_count},
91120
{2, undefined, io_read_bytes_total, counter, "Total number of I/O bytes read", io_read_bytes},
@@ -127,7 +156,7 @@
127156
{4, undefined, auth_attempts_detailed_failed_total, counter, "Total number of failed authentication attempts with source info"}
128157
]},
129158

130-
%%% Those metrics have reference only to a queue name. This is the only group where filtering (e.g. by vhost) makes sense.
159+
%%% These metrics only reference a queue name. This is the only group where filtering (e.g. by vhost) makes sense.
131160
{queue_coarse_metrics, [
132161
{2, undefined, queue_messages_ready, gauge, "Messages ready to be delivered to consumers"},
133162
{3, undefined, queue_messages_unacked, gauge, "Messages delivered to consumers but not yet acknowledged"},
@@ -601,6 +630,38 @@ get_data(vhost_status, _, _) ->
601630
false -> 0
602631
end}
603632
|| VHost <- rabbit_vhost:list() ];
633+
get_data(node_memory, _, _) ->
634+
BreakdownPL = rabbit_vm:memory(),
635+
KeysOfInterest = [
636+
code,
637+
connection_readers,
638+
connection_writers,
639+
connection_channels,
640+
connection_other,
641+
queue_procs,
642+
quorum_queue_procs,
643+
quorum_queue_dlx_procs,
644+
stream_queue_procs,
645+
stream_queue_replica_reader_procs,
646+
stream_queue_coordinator_procs,
647+
plugins,
648+
metadata_store,
649+
other_proc,
650+
metrics,
651+
mgmt_db,
652+
mnesia,
653+
quorum_ets,
654+
metadata_store_ets,
655+
other_ets,
656+
binary,
657+
msg_index,
658+
atom,
659+
other_system,
660+
allocated_unused,
661+
reserved_unallocated
662+
],
663+
Data = maps:to_list(maps:with(KeysOfInterest, maps:from_list(BreakdownPL))),
664+
[{node_memory, Data}];
604665
get_data(exchange_bindings, _, _) ->
605666
Exchanges = lists:foldl(fun
606667
(#exchange{internal = true}, Acc) ->

deps/rabbitmq_prometheus/test/rabbit_prometheus_http_SUITE.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ aggregated_metrics_test(Config) ->
381381
?assertEqual(match, re:run(Body, "^rabbitmq_queue_consumers ", [{capture, none}, multiline])),
382382
?assertEqual(match, re:run(Body, "TYPE rabbitmq_auth_attempts_total", [{capture, none}, multiline])),
383383
?assertEqual(nomatch, re:run(Body, "TYPE rabbitmq_auth_attempts_detailed_total", [{capture, none}, multiline])),
384+
%% Memory breakdown
385+
?assertEqual(match, re:run(Body, "^rabbitmq_memory_quorum_queue_erlang_process_bytes ", [{capture, none}, multiline])),
386+
?assertEqual(match, re:run(Body, "^rabbitmq_memory_classic_queue_erlang_process_bytes ", [{capture, none}, multiline])),
387+
?assertEqual(match, re:run(Body, "^rabbitmq_memory_binary_heap_bytes ", [{capture, none}, multiline])),
384388
%% Check the first metric value in each ETS table that requires converting
385389
?assertEqual(match, re:run(Body, "^rabbitmq_erlang_uptime_seconds ", [{capture, none}, multiline])),
386390
?assertEqual(match, re:run(Body, "^rabbitmq_io_read_time_seconds_total ", [{capture, none}, multiline])),

0 commit comments

Comments
 (0)