Skip to content

Commit 5bce45b

Browse files
authored
Add processor architectures to cluster stats (#68351)
This change adds a new "architectures" section to the cluster stats, containing a summary of how many nodes in the cluster are on each processor architecture. The intention is to make it easier to see whether clusters are running on aarch64, or mixed x86_64/aarch64, which may aid support as aarch64 becomes more commonly used. Backport of #68264
1 parent 5aa7848 commit 5bce45b

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

docs/reference/cluster/stats.asciidoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,23 @@ Human-readable name of an operating system used by one or more selected nodes.
766766
Number of selected nodes using the operating system.
767767
======
768768

769+
`architectures`::
770+
(array of objects)
771+
Contains statistics about processor architectures (for example, x86_64 or
772+
aarch64) used by selected nodes.
773+
+
774+
.Properties of `architectures`
775+
[%collapsible%open]
776+
======
777+
`arch`:::
778+
(string)
779+
Name of an architecture used by one or more selected nodes.
780+
781+
`count`:::
782+
(string)
783+
Number of selected nodes using the architecture.
784+
======
785+
769786
`mem`::
770787
(object)
771788
Contains statistics about memory used by selected nodes.
@@ -1252,6 +1269,12 @@ The API returns the following response:
12521269
"count": 1
12531270
}
12541271
],
1272+
"architectures": [
1273+
{
1274+
"arch": "x86_64",
1275+
"count": 1
1276+
}
1277+
],
12551278
"mem" : {
12561279
"total" : "16gb",
12571280
"total_in_bytes" : 17179869184,

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ public static class OsStats implements ToXContentFragment {
248248
final int allocatedProcessors;
249249
final ObjectIntHashMap<String> names;
250250
final ObjectIntHashMap<String> prettyNames;
251+
final ObjectIntHashMap<String> architectures;
251252
final org.elasticsearch.monitor.os.OsStats.Mem mem;
252253

253254
/**
@@ -256,6 +257,7 @@ public static class OsStats implements ToXContentFragment {
256257
private OsStats(List<NodeInfo> nodeInfos, List<NodeStats> nodeStatsList) {
257258
this.names = new ObjectIntHashMap<>();
258259
this.prettyNames = new ObjectIntHashMap<>();
260+
this.architectures = new ObjectIntHashMap<>();
259261
int availableProcessors = 0;
260262
int allocatedProcessors = 0;
261263
for (NodeInfo nodeInfo : nodeInfos) {
@@ -268,6 +270,9 @@ private OsStats(List<NodeInfo> nodeInfos, List<NodeStats> nodeStatsList) {
268270
if (nodeInfo.getInfo(OsInfo.class).getPrettyName() != null) {
269271
prettyNames.addTo(nodeInfo.getInfo(OsInfo.class).getPrettyName(), 1);
270272
}
273+
if (nodeInfo.getInfo(OsInfo.class).getArch() != null) {
274+
architectures.addTo(nodeInfo.getInfo(OsInfo.class).getArch(), 1);
275+
}
271276
}
272277
this.availableProcessors = availableProcessors;
273278
this.allocatedProcessors = allocatedProcessors;
@@ -308,6 +313,8 @@ static final class Fields {
308313
static final String NAMES = "names";
309314
static final String PRETTY_NAME = "pretty_name";
310315
static final String PRETTY_NAMES = "pretty_names";
316+
static final String ARCH = "arch";
317+
static final String ARCHITECTURES = "architectures";
311318
static final String COUNT = "count";
312319
}
313320

@@ -340,6 +347,18 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params)
340347
}
341348
}
342349
builder.endArray();
350+
builder.startArray(Fields.ARCHITECTURES);
351+
{
352+
for (final ObjectIntCursor<String> arch : architectures) {
353+
builder.startObject();
354+
{
355+
builder.field(Fields.ARCH, arch.key);
356+
builder.field(Fields.COUNT, arch.value);
357+
}
358+
builder.endObject();
359+
}
360+
}
361+
builder.endArray();
343362
mem.toXContent(builder, params);
344363
return builder;
345364
}

x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public void testToXContent() throws IOException {
267267
when(mockOsInfo.getAllocatedProcessors()).thenReturn(16);
268268
when(mockOsInfo.getName()).thenReturn("_os_name");
269269
when(mockOsInfo.getPrettyName()).thenReturn("_pretty_os_name");
270+
when(mockOsInfo.getArch()).thenReturn("_architecture");
270271

271272
final JvmInfo mockJvmInfo = mock(JvmInfo.class);
272273
when(mockNodeInfo.getInfo(JvmInfo.class)).thenReturn(mockJvmInfo);
@@ -492,6 +493,12 @@ public void testToXContent() throws IOException {
492493
+ "\"count\":1"
493494
+ "}"
494495
+ "],"
496+
+ "\"architectures\":["
497+
+ "{"
498+
+ "\"arch\":\"_architecture\","
499+
+ "\"count\":1"
500+
+ "}"
501+
+ "],"
495502
+ "\"mem\":{"
496503
+ "\"total_in_bytes\":100,"
497504
+ "\"free_in_bytes\":79,"

0 commit comments

Comments
 (0)