Skip to content

Commit eca7e05

Browse files
committed
management: Expose current mount stats in API and UI
This adds the configured mounts, if there are any, to the API JSON response for the `/api/nodes` and `/api/node/<node>` endpoints and to the overview and node-detail UI pages. Time series data is not collected for these metrics - that should be scraped from the Prometheus endpoint instead.
1 parent 1145d8e commit eca7e05

File tree

5 files changed

+59
-8
lines changed

5 files changed

+59
-8
lines changed

deps/rabbitmq_management/priv/www/js/global.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ var ALL_COLUMNS =
141141
{'Statistics': [['file_descriptors', 'File descriptors', true],
142142
['erlang_processes', 'Erlang processes', true],
143143
['memory', 'Memory', true],
144-
['disk_space', 'Disk space', true]],
144+
['disk_space', 'Disk space', true],
145+
['mount_space', 'Other disks', true]],
145146
'General': [['uptime', 'Uptime', true],
146147
['cores', 'Cores', true],
147148
['info', 'Info', true],

deps/rabbitmq_management/priv/www/js/tmpl/node.ejs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@
131131
<% } %>
132132
</td>
133133
</tr>
134+
<%
135+
for (var i = 0; i < node.mount_stats.length; i++) {
136+
var mount = node.mount_stats[i];
137+
%>
138+
<tr>
139+
<th>
140+
<%= fmt_string(mount.name) %> disk space
141+
</th>
142+
<td>
143+
<%= node_stat_bar('available', 'limit', 'low watermark', mount, fmt_bytes_axis,
144+
mount.available < mount.limit ? 'red' : 'green',
145+
mount.available < mount.limit ? 'disk_free-alarm' : null,
146+
true) %>
147+
</td>
148+
</tr>
149+
<% } %>
134150
</table>
135151
</div>
136152
</div>

deps/rabbitmq_management/priv/www/js/tmpl/overview.ejs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@
9393
<% if (show_column('overview', 'disk_space')) { %>
9494
<th>Disk space</th>
9595
<% } %>
96+
<% if (show_column('overview', 'mount_space')) { %>
97+
<%
98+
var other_disk_names = [];
99+
var unique_disk_names = {};
100+
for (var i = 0; i < nodes.length; i++) {
101+
for (var j = 0; j < nodes[i].mount_stats.length; j++) {
102+
var name = nodes[i].mount_stats[j].name;
103+
if (!Object.hasOwnProperty(unique_disk_names, name)) {
104+
unique_disk_names[name] = true;
105+
other_disk_names.push(name);
106+
}
107+
}
108+
}
109+
%>
110+
<% for (var i = 0; i < other_disk_names.length; i++) { %>
111+
<th><%= fmt_string(other_disk_names[i]) %> disk space</th>
112+
<% } %>
113+
<% } %>
96114
<% if (show_column('overview', 'uptime')) { %>
97115
<th>Uptime</th>
98116
<% } %>
@@ -180,6 +198,20 @@
180198
<% } %>
181199
</td>
182200
<% } %>
201+
<% if (show_column('overview', 'mount_space')) { %>
202+
<% for (var i = 0; i < other_disk_names.length; i++) {
203+
var mount = node.mount_stats.find((m) => m.name == other_disk_names[i]);
204+
%>
205+
<td>
206+
<% if (mount) { %>
207+
<%= node_stat_bar('available', 'limit', 'low watermark',
208+
mount, fmt_bytes_axis,
209+
node.disk_free_alarm ? 'red' : 'green',
210+
node.disk_free_alarm ? 'disk_free-alarm' : null, true) %>
211+
<% } %>
212+
</td>
213+
<% } %>
214+
<% } %>
183215
<% if (show_column('overview', 'uptime')) { %>
184216
<td><span><%= fmt_uptime(node.uptime) %></span></td>
185217
<% } %>

deps/rabbitmq_management/src/rabbit_mgmt_db.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ node_stats(Ranges, Objs, Interval) ->
661661
StatsD = [{cluster_links, NodeNodeStats}],
662662
MgmtStats = maps:get(mgmt_stats, NData),
663663
Details = augment_details(Obj, []), % augmentation needs to be node local
664-
combine(Props, Obj) ++ Details ++ Stats ++ StatsD ++ MgmtStats
664+
MountStats = [{mount_stats, maps:get(mount_stats, NData, [])}],
665+
combine(Props, Obj) ++ Details ++ Stats ++ StatsD ++ MgmtStats ++ MountStats
665666
end || Obj <- Objs].
666667

667668
combine(New, Old) ->

deps/rabbitmq_management_agent/src/rabbit_mgmt_data.erl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,15 @@ vhost_data(Ranges, Id) ->
108108

109109
node_data(Ranges, Id) ->
110110
maps:from_list(
111-
[{mgmt_stats, mgmt_queue_length_stats(Id)}] ++
112-
[{node_node_metrics, node_node_metrics()}] ++
113-
node_raw_detail_stats_data(Ranges, Id) ++
114-
[raw_message_data(node_coarse_stats,
111+
[{mgmt_stats, mgmt_queue_length_stats(Id)},
112+
{node_node_metrics, node_node_metrics()},
113+
{node_stats, lookup_element(node_stats, Id)},
114+
{mount_stats, [maps:to_list(M) || M <- rabbit_disk_monitor:get_mount_free()]},
115+
raw_message_data(node_coarse_stats,
115116
pick_range(coarse_node_stats, Ranges), Id),
116117
raw_message_data(node_persister_stats,
117-
pick_range(coarse_node_stats, Ranges), Id),
118-
{node_stats, lookup_element(node_stats, Id)}] ++
118+
pick_range(coarse_node_stats, Ranges), Id)] ++
119+
node_raw_detail_stats_data(Ranges, Id) ++
119120
node_connection_churn_rates_data(Ranges, Id)).
120121

121122
overview_data(_Pid, User, Ranges, VHosts) ->

0 commit comments

Comments
 (0)