You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "DomGarguilo (via GitHub)" <gi...@apache.org> on 2026/04/17 16:19:06 UTC
[PR] Centralize Monitor Server table definitons on backend [accumulo]
DomGarguilo opened a new pull request, #6321:
URL: https://github.com/apache/accumulo/pull/6321
This PR centralizes all of the Monitor table definitions into one place on the backend. We can now more or less define a monitor table via a `List<Metric>` where that list gets mapped 1:1 to the view on the front end. All order and filtering of the columns takes place next to this `List` on the backend.
* reworked server process monitor table views to return a backend-defined table model with `columns`, `data` (rows), `status` (used for banners and status LEDs), and timestamp
* Added a new `record Column` so the backend can define and send each columns
* key
* label
* description
* uiClass
* Added `enum ServerTable` to serve as the IDs for each table and to be used as the API param in `/rest-v2/servers/view;table=<table>`
* Added a new enum `ServersView`. There should be on `ServersView` per UI table
* added a method for each `ServersView` where each tables shape is defined. These methods return a `List<Metric>` which maps directly to the frontend table columns. This is where we define which and in what order the columns will be for each table.
* removed the generated `columns.js` and its supporting code. Now the frontend builds the table headers and DataTables column config directly from the returned backend column definitions
Now to add a new table to the UI:
* add a new ServerTable enum value and create the corresponding metric selection method in `ServersView` for that table
* cache the table in SystemInformation with the corresponding server set
* add a fetch helper method in the javascript that calls `/rest-v2/servers/view;table=<NEW_TABLE>`
* point the page JS at that helper and storage key and use the existing generic table render methods
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3111439103
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -59,54 +66,102 @@ public record Status(boolean hasServers, boolean hasProblemServers, boolean hasM
String message) {
}
- public static final String TYPE_COL_NAME = "Server Type";
- public static final String RG_COL_NAME = "Resource Group";
- public static final String ADDR_COL_NAME = "Server Address";
- public static final String TIME_COL_NAME = "Last Contact";
+ /**
+ * Definition of a column to be rendered in the UI
+ */
+ public record Column(String key, String label, String description, String uiClass) {
+ }
+
+ private record ServerMetricRow(ServerId server, MetricResponse response,
+ Map<String,Number> metrics) {
+ }
+
+ /**
+ * Server-process table identifiers accepted by /rest-v2/servers/view. These enum names are used
+ * directly as the frontend table parameter values.
+ */
+ public enum ServerTable {
+ COMPACTORS,
+ GC_SUMMARY,
+ GC_FILES,
+ GC_WALS,
+ MANAGERS,
+ MANAGER_FATE,
+ MANAGER_COMPACTIONS,
+ SCAN_SERVERS,
+ TABLET_SERVERS
+ }
private static final String LEVEL_OK = "OK";
private static final String LEVEL_WARN = "WARN";
+ public static final String RG_COL_KEY = "resourceGroup";
+ public static final String ADDR_COL_KEY = "serverAddress";
+ public static final String TIME_COL_KEY = "lastContact";
+
+ /**
+ * Common columns that are included in every ServersView table
+ */
+ private static final List<Column> COMMON_COLUMNS = List.of(
+ new Column(TIME_COL_KEY, "Last Contact",
+ "Time since the server last responded to the monitor", "duration"),
+ new Column(RG_COL_KEY, "Resource Group", "Resource Group", ""),
+ new Column(ADDR_COL_KEY, "Server Address", "Server address", ""));
+
public final List<Map<String,Object>> data = new ArrayList<>();
- public final Set<String> columns = new TreeSet<>();
+ public final List<Column> columns;
public final Status status;
public final long timestamp;
public ServersView(final Set<ServerId> servers, final long problemServerCount,
- final Cache<ServerId,MetricResponse> allMetrics, final long timestamp) {
+ final Cache<ServerId,MetricResponse> allMetrics, final long timestamp,
+ final List<Column> requestedColumns) {
AtomicInteger serversMissingMetrics = new AtomicInteger(0);
- servers.forEach(sid -> {
- Map<String,Object> metrics = new TreeMap<>();
-
- columns.add(TYPE_COL_NAME);
- metrics.put(TYPE_COL_NAME, sid.getType().name());
- columns.add(RG_COL_NAME);
- metrics.put(RG_COL_NAME, sid.getResourceGroup().canonical());
- columns.add(ADDR_COL_NAME);
- metrics.put(ADDR_COL_NAME, sid.toHostPortString());
-
- MetricResponse mr = allMetrics.getIfPresent(sid);
- if (mr != null) {
- // Don't use the timestamp for the last contact duration,
- // use the current time.
- columns.add(TIME_COL_NAME);
- metrics.put(TIME_COL_NAME, System.currentTimeMillis() - mr.getTimestamp());
-
- Map<String,Number> serverMetrics = metricValuesByName(mr);
- for (Entry<String,Number> e : serverMetrics.entrySet()) {
- columns.add(e.getKey());
- metrics.put(e.getKey(), e.getValue());
- }
- data.add(metrics);
- } else {
+ // Grab the current metrics for each server
+ List<ServerMetricRow> serverMetricRows = servers.stream().sorted().map(serverId -> {
+ MetricResponse metricResponse = allMetrics.getIfPresent(serverId);
+ boolean hasMetricData = hasMetricData(metricResponse);
+ Map<String,Number> serverMetrics =
+ hasMetricData ? metricValuesByName(metricResponse) : Map.of();
+
+ if (!hasMetricData) {
serversMissingMetrics.incrementAndGet();
}
+
+ return new ServerMetricRow(serverId, metricResponse, serverMetrics);
+ }).toList();
+
+ Set<String> presentMetricNames = serverMetricRows.stream()
+ .flatMap(row -> row.metrics().keySet().stream()).collect(Collectors.toSet());
+
+ // Keep common columns and filter out metric columns that have no values
+ this.columns = requestedColumns.stream()
+ .filter(col -> isCommonColumn(col.key()) || presentMetricNames.contains(col.key()))
Review Comment:
removed in 7e2775f
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3111228200
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -131,6 +186,107 @@ private static Status buildStatus(int serverCount, long problemServerCount,
problemServerCount, serversMissingMetrics, LEVEL_WARN, message);
}
+ private static boolean hasMetricData(MetricResponse mr) {
+ return mr != null && mr.getMetrics() != null && !mr.getMetrics().isEmpty();
+ }
+
+ private static boolean isCommonColumn(String key) {
+ return COMMON_COLUMNS.stream().anyMatch(col -> col.key().equals(key));
+ }
+
+ /**
+ * Builds the final ordered columns for a table. First adds the common columns, then adds the
+ * table specific metrics.
+ */
+ public static List<Column> columnsFor(ServerTable table) {
+ List<Column> cols = new ArrayList<>(COMMON_COLUMNS);
+ cols.addAll(metricsForTable(table).stream().map(ServersView::metricColumn).toList());
+ return cols;
+ }
+
+ private static List<Metric> metricsForTable(ServerTable table) {
+ return switch (table) {
+ case COMPACTORS -> compactorMetrics();
+ case GC_SUMMARY -> gcSummaryMetrics();
+ case GC_FILES -> gcFileMetrics();
+ case GC_WALS -> gcWalMetrics();
+ case MANAGERS -> managerMetrics();
+ case MANAGER_FATE -> managerFateMetrics();
+ case MANAGER_COMPACTIONS -> managerCompactionMetrics();
+ case SCAN_SERVERS -> scanServerMetrics();
+ case TABLET_SERVERS -> tabletServerMetrics();
+ };
+ }
+
+ /**
+ * The following helper methods are where the metrics included in each table are defined as well
+ * as their order.
+ */
+ private static List<Metric> compactorMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.COMPACTION,
+ MetricDocSection.COMPACTOR);
+ }
+
+ private static List<Metric> gcSummaryMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER);
+ }
+
+ private static List<Metric> gcFileMetrics() {
+ return Arrays.stream(Metric.values()).filter(metric -> {
+ String name = metric.getName();
+ return metric.getDocSection() == MetricDocSection.GARBAGE_COLLECTION
+ && !name.startsWith("accumulo.gc.wal.");
+ }).toList();
+ }
+
+ private static List<Metric> gcWalMetrics() {
+ return Arrays.stream(Metric.values())
+ .filter(metric -> metric.getName().startsWith("accumulo.gc.wal."))
+ .collect(Collectors.toList());
+ }
+
+ private static List<Metric> managerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.MANAGER);
+ }
+
+ private static List<Metric> managerFateMetrics() {
+ return metricList(MetricDocSection.FATE);
+ }
+
+ private static List<Metric> managerCompactionMetrics() {
+ return metricList(MetricDocSection.COMPACTION);
+ }
+
+ private static List<Metric> scanServerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.SCAN_SERVER,
+ MetricDocSection.SCAN, MetricDocSection.BLOCK_CACHE);
+ }
+
+ private static List<Metric> tabletServerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.TABLET_SERVER,
Review Comment:
> it was neat to see this working and really easy to change.
Great! This was the goal so I'm glad things were easy.
> we need scan queued, running, and failed metrics
Yea this seems like a good follow on. Should we create a ticket to track this?
> Probably want to eventually put the smallest set of metrics in the table for all servers that indicates if a server is healthy, then maybe we could have a per server page that one could click on and see all that the monitor knows about a specific server.
This seems like a good idea to me. The goal with these changes is to make it easy to figure out what info to put in each table however I am not sure where the best place to discuss or document that info per table is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3102624249
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -131,6 +186,107 @@ private static Status buildStatus(int serverCount, long problemServerCount,
problemServerCount, serversMissingMetrics, LEVEL_WARN, message);
}
+ private static boolean hasMetricData(MetricResponse mr) {
+ return mr != null && mr.getMetrics() != null && !mr.getMetrics().isEmpty();
+ }
+
+ private static boolean isCommonColumn(String key) {
+ return COMMON_COLUMNS.stream().anyMatch(col -> col.key().equals(key));
+ }
+
+ /**
+ * Builds the final ordered columns for a table. First adds the common columns, then adds the
+ * table specific metrics.
+ */
+ public static List<Column> columnsFor(ServerTable table) {
+ List<Column> cols = new ArrayList<>(COMMON_COLUMNS);
+ cols.addAll(metricsForTable(table).stream().map(ServersView::metricColumn).toList());
+ return cols;
+ }
+
+ private static List<Metric> metricsForTable(ServerTable table) {
+ return switch (table) {
+ case COMPACTORS -> compactorMetrics();
+ case GC_SUMMARY -> gcSummaryMetrics();
+ case GC_FILES -> gcFileMetrics();
+ case GC_WALS -> gcWalMetrics();
+ case MANAGERS -> managerMetrics();
+ case MANAGER_FATE -> managerFateMetrics();
+ case MANAGER_COMPACTIONS -> managerCompactionMetrics();
+ case SCAN_SERVERS -> scanServerMetrics();
+ case TABLET_SERVERS -> tabletServerMetrics();
+ };
+ }
+
+ /**
+ * The following helper methods are where the metrics included in each table are defined as well
+ * as their order.
+ */
+ private static List<Metric> compactorMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.COMPACTION,
+ MetricDocSection.COMPACTOR);
+ }
+
+ private static List<Metric> gcSummaryMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER);
+ }
+
+ private static List<Metric> gcFileMetrics() {
+ return Arrays.stream(Metric.values()).filter(metric -> {
+ String name = metric.getName();
+ return metric.getDocSection() == MetricDocSection.GARBAGE_COLLECTION
+ && !name.startsWith("accumulo.gc.wal.");
+ }).toList();
+ }
+
+ private static List<Metric> gcWalMetrics() {
+ return Arrays.stream(Metric.values())
+ .filter(metric -> metric.getName().startsWith("accumulo.gc.wal."))
+ .collect(Collectors.toList());
+ }
+
+ private static List<Metric> managerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.MANAGER);
+ }
+
+ private static List<Metric> managerFateMetrics() {
+ return metricList(MetricDocSection.FATE);
+ }
+
+ private static List<Metric> managerCompactionMetrics() {
+ return metricList(MetricDocSection.COMPACTION);
+ }
+
+ private static List<Metric> scanServerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.SCAN_SERVER,
+ MetricDocSection.SCAN, MetricDocSection.BLOCK_CACHE);
+ }
+
+ private static List<Metric> tabletServerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.TABLET_SERVER,
Review Comment:
As an experiment I changed this method to return the following and ran the monitor. It displayed those columns (plus the commons ones prepended) in that order. Not suggesting this change, just sharing the experiment it was neat to see this working and really easy to change.
```java
return List.of(Metric.TSERVER_MINC_RUNNING, Metric.TSERVER_MINC_QUEUED, Metric.TSERVER_HOLD, Metric.SCAN_ZOMBIE_THREADS, Metric.BLOCKCACHE_DATA_REQUESTCOUNT, Metric.BLOCKCACHE_DATA_HITCOUNT, Metric.BLOCKCACHE_DATA_EVICTIONCOUNT);
```
Not something for this PR, but w/ the experiment above realized we need scan queued, running, and failed metrics. Some of those metrics may be there in the form of thread pool metrics, but those are from micrometer and not currently collected by the monitor. May also be good to have failed MinC metric. Then for scan and minc we could have running/queued/failed and those would be really good indications of tserver health. Probably want to eventually put the smallest set of metrics in the table for all servers that indicates if a server is healthy, then maybe we could have a per server page that one could click on and see all that the monitor knows about a specific server.
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -59,54 +66,102 @@ public record Status(boolean hasServers, boolean hasProblemServers, boolean hasM
String message) {
}
- public static final String TYPE_COL_NAME = "Server Type";
- public static final String RG_COL_NAME = "Resource Group";
- public static final String ADDR_COL_NAME = "Server Address";
- public static final String TIME_COL_NAME = "Last Contact";
+ /**
+ * Definition of a column to be rendered in the UI
+ */
+ public record Column(String key, String label, String description, String uiClass) {
+ }
+
+ private record ServerMetricRow(ServerId server, MetricResponse response,
+ Map<String,Number> metrics) {
+ }
+
+ /**
+ * Server-process table identifiers accepted by /rest-v2/servers/view. These enum names are used
+ * directly as the frontend table parameter values.
+ */
+ public enum ServerTable {
+ COMPACTORS,
+ GC_SUMMARY,
+ GC_FILES,
+ GC_WALS,
+ MANAGERS,
+ MANAGER_FATE,
+ MANAGER_COMPACTIONS,
+ SCAN_SERVERS,
+ TABLET_SERVERS
+ }
private static final String LEVEL_OK = "OK";
private static final String LEVEL_WARN = "WARN";
+ public static final String RG_COL_KEY = "resourceGroup";
+ public static final String ADDR_COL_KEY = "serverAddress";
+ public static final String TIME_COL_KEY = "lastContact";
+
+ /**
+ * Common columns that are included in every ServersView table
+ */
+ private static final List<Column> COMMON_COLUMNS = List.of(
+ new Column(TIME_COL_KEY, "Last Contact",
+ "Time since the server last responded to the monitor", "duration"),
+ new Column(RG_COL_KEY, "Resource Group", "Resource Group", ""),
+ new Column(ADDR_COL_KEY, "Server Address", "Server address", ""));
+
public final List<Map<String,Object>> data = new ArrayList<>();
- public final Set<String> columns = new TreeSet<>();
+ public final List<Column> columns;
public final Status status;
public final long timestamp;
public ServersView(final Set<ServerId> servers, final long problemServerCount,
- final Cache<ServerId,MetricResponse> allMetrics, final long timestamp) {
+ final Cache<ServerId,MetricResponse> allMetrics, final long timestamp,
+ final List<Column> requestedColumns) {
AtomicInteger serversMissingMetrics = new AtomicInteger(0);
- servers.forEach(sid -> {
- Map<String,Object> metrics = new TreeMap<>();
-
- columns.add(TYPE_COL_NAME);
- metrics.put(TYPE_COL_NAME, sid.getType().name());
- columns.add(RG_COL_NAME);
- metrics.put(RG_COL_NAME, sid.getResourceGroup().canonical());
- columns.add(ADDR_COL_NAME);
- metrics.put(ADDR_COL_NAME, sid.toHostPortString());
-
- MetricResponse mr = allMetrics.getIfPresent(sid);
- if (mr != null) {
- // Don't use the timestamp for the last contact duration,
- // use the current time.
- columns.add(TIME_COL_NAME);
- metrics.put(TIME_COL_NAME, System.currentTimeMillis() - mr.getTimestamp());
-
- Map<String,Number> serverMetrics = metricValuesByName(mr);
- for (Entry<String,Number> e : serverMetrics.entrySet()) {
- columns.add(e.getKey());
- metrics.put(e.getKey(), e.getValue());
- }
- data.add(metrics);
- } else {
+ // Grab the current metrics for each server
+ List<ServerMetricRow> serverMetricRows = servers.stream().sorted().map(serverId -> {
+ MetricResponse metricResponse = allMetrics.getIfPresent(serverId);
+ boolean hasMetricData = hasMetricData(metricResponse);
+ Map<String,Number> serverMetrics =
+ hasMetricData ? metricValuesByName(metricResponse) : Map.of();
+
+ if (!hasMetricData) {
serversMissingMetrics.incrementAndGet();
}
+
+ return new ServerMetricRow(serverId, metricResponse, serverMetrics);
+ }).toList();
+
+ Set<String> presentMetricNames = serverMetricRows.stream()
+ .flatMap(row -> row.metrics().keySet().stream()).collect(Collectors.toSet());
+
+ // Keep common columns and filter out metric columns that have no values
+ this.columns = requestedColumns.stream()
+ .filter(col -> isCommonColumn(col.key()) || presentMetricNames.contains(col.key()))
Review Comment:
Seems like this will only show columns that have a metric present on at least one server? Would it be possible to always show all the requested columns even if no server currently has metrics? Seems like this could cause columns to blink in and out of existence when auto refresh is enabled.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo merged PR #6321:
URL: https://github.com/apache/accumulo/pull/6321
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3111436466
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java:
##########
@@ -776,8 +776,17 @@ public long getTimestamp() {
return this.timestamp.get();
}
- public ServersView getServerProcessView(ServerId.Type type) {
- Supplier<ServersView> view = this.serverMetricsView.get(type);
+ /**
+ * Cache a ServersView for the given table and set of servers.
+ */
+ private void cacheServerProcessView(ServersView.ServerTable table, Set<ServerId> servers,
+ long problemHostCount) {
+ serverMetricsView.put(table, memoize(() -> new ServersView(Set.copyOf(servers),
Review Comment:
removed in 93705ce
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#issuecomment-4270384049
Tried running this locally and in the web browser debug console I noticed for every page I visited on the monitor it always fetched `/rest-v2/servers/view;table=SCAN_SERVERS` and `/rest-v2/servers/view;table=MANAGERS`. I suspect this is preexisting behavior and also suspect its caused by navbar.js, but not sure. Wondering if this means every page visited is pulling down a list of all scan servers and there metrics? If so may need to open an issue about this.
I first noticed it on the tserver page, it would fetch TABLET_SERVERS, SCAN_SERVERS, and MANAGERS. Then tried visiting the main page and it fetched SCAN_SERVERS and MANAGERS.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3111351967
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -59,54 +66,102 @@ public record Status(boolean hasServers, boolean hasProblemServers, boolean hasM
String message) {
}
- public static final String TYPE_COL_NAME = "Server Type";
- public static final String RG_COL_NAME = "Resource Group";
- public static final String ADDR_COL_NAME = "Server Address";
- public static final String TIME_COL_NAME = "Last Contact";
+ /**
+ * Definition of a column to be rendered in the UI
+ */
+ public record Column(String key, String label, String description, String uiClass) {
+ }
+
+ private record ServerMetricRow(ServerId server, MetricResponse response,
+ Map<String,Number> metrics) {
+ }
+
+ /**
+ * Server-process table identifiers accepted by /rest-v2/servers/view. These enum names are used
+ * directly as the frontend table parameter values.
+ */
+ public enum ServerTable {
+ COMPACTORS,
+ GC_SUMMARY,
+ GC_FILES,
+ GC_WALS,
+ MANAGERS,
+ MANAGER_FATE,
+ MANAGER_COMPACTIONS,
+ SCAN_SERVERS,
+ TABLET_SERVERS
+ }
private static final String LEVEL_OK = "OK";
private static final String LEVEL_WARN = "WARN";
+ public static final String RG_COL_KEY = "resourceGroup";
+ public static final String ADDR_COL_KEY = "serverAddress";
+ public static final String TIME_COL_KEY = "lastContact";
+
+ /**
+ * Common columns that are included in every ServersView table
+ */
+ private static final List<Column> COMMON_COLUMNS = List.of(
+ new Column(TIME_COL_KEY, "Last Contact",
+ "Time since the server last responded to the monitor", "duration"),
+ new Column(RG_COL_KEY, "Resource Group", "Resource Group", ""),
+ new Column(ADDR_COL_KEY, "Server Address", "Server address", ""));
+
public final List<Map<String,Object>> data = new ArrayList<>();
- public final Set<String> columns = new TreeSet<>();
+ public final List<Column> columns;
public final Status status;
public final long timestamp;
public ServersView(final Set<ServerId> servers, final long problemServerCount,
- final Cache<ServerId,MetricResponse> allMetrics, final long timestamp) {
+ final Cache<ServerId,MetricResponse> allMetrics, final long timestamp,
+ final List<Column> requestedColumns) {
AtomicInteger serversMissingMetrics = new AtomicInteger(0);
- servers.forEach(sid -> {
- Map<String,Object> metrics = new TreeMap<>();
-
- columns.add(TYPE_COL_NAME);
- metrics.put(TYPE_COL_NAME, sid.getType().name());
- columns.add(RG_COL_NAME);
- metrics.put(RG_COL_NAME, sid.getResourceGroup().canonical());
- columns.add(ADDR_COL_NAME);
- metrics.put(ADDR_COL_NAME, sid.toHostPortString());
-
- MetricResponse mr = allMetrics.getIfPresent(sid);
- if (mr != null) {
- // Don't use the timestamp for the last contact duration,
- // use the current time.
- columns.add(TIME_COL_NAME);
- metrics.put(TIME_COL_NAME, System.currentTimeMillis() - mr.getTimestamp());
-
- Map<String,Number> serverMetrics = metricValuesByName(mr);
- for (Entry<String,Number> e : serverMetrics.entrySet()) {
- columns.add(e.getKey());
- metrics.put(e.getKey(), e.getValue());
- }
- data.add(metrics);
- } else {
+ // Grab the current metrics for each server
+ List<ServerMetricRow> serverMetricRows = servers.stream().sorted().map(serverId -> {
+ MetricResponse metricResponse = allMetrics.getIfPresent(serverId);
+ boolean hasMetricData = hasMetricData(metricResponse);
+ Map<String,Number> serverMetrics =
+ hasMetricData ? metricValuesByName(metricResponse) : Map.of();
+
+ if (!hasMetricData) {
serversMissingMetrics.incrementAndGet();
}
+
+ return new ServerMetricRow(serverId, metricResponse, serverMetrics);
Review Comment:
No its not serialized directly. `ServerMetricRow` is internal and only used to build `ServersView`. `MetricResponse` is kept and used to compute `lastContact` from `metricResponse.getTimestamp()` in `valueForColumn()`. Only `data`, `columns`, `status`, and `timestamp` end up getting serialized
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3111587151
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -131,6 +186,107 @@ private static Status buildStatus(int serverCount, long problemServerCount,
problemServerCount, serversMissingMetrics, LEVEL_WARN, message);
}
+ private static boolean hasMetricData(MetricResponse mr) {
+ return mr != null && mr.getMetrics() != null && !mr.getMetrics().isEmpty();
+ }
+
+ private static boolean isCommonColumn(String key) {
+ return COMMON_COLUMNS.stream().anyMatch(col -> col.key().equals(key));
+ }
+
+ /**
+ * Builds the final ordered columns for a table. First adds the common columns, then adds the
+ * table specific metrics.
+ */
+ public static List<Column> columnsFor(ServerTable table) {
+ List<Column> cols = new ArrayList<>(COMMON_COLUMNS);
+ cols.addAll(metricsForTable(table).stream().map(ServersView::metricColumn).toList());
+ return cols;
+ }
+
+ private static List<Metric> metricsForTable(ServerTable table) {
+ return switch (table) {
+ case COMPACTORS -> compactorMetrics();
+ case GC_SUMMARY -> gcSummaryMetrics();
+ case GC_FILES -> gcFileMetrics();
+ case GC_WALS -> gcWalMetrics();
+ case MANAGERS -> managerMetrics();
+ case MANAGER_FATE -> managerFateMetrics();
+ case MANAGER_COMPACTIONS -> managerCompactionMetrics();
+ case SCAN_SERVERS -> scanServerMetrics();
+ case TABLET_SERVERS -> tabletServerMetrics();
+ };
+ }
+
+ /**
+ * The following helper methods are where the metrics included in each table are defined as well
+ * as their order.
+ */
+ private static List<Metric> compactorMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.COMPACTION,
+ MetricDocSection.COMPACTOR);
+ }
+
+ private static List<Metric> gcSummaryMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER);
+ }
+
+ private static List<Metric> gcFileMetrics() {
+ return Arrays.stream(Metric.values()).filter(metric -> {
+ String name = metric.getName();
+ return metric.getDocSection() == MetricDocSection.GARBAGE_COLLECTION
+ && !name.startsWith("accumulo.gc.wal.");
+ }).toList();
+ }
+
+ private static List<Metric> gcWalMetrics() {
+ return Arrays.stream(Metric.values())
+ .filter(metric -> metric.getName().startsWith("accumulo.gc.wal."))
+ .collect(Collectors.toList());
+ }
+
+ private static List<Metric> managerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.MANAGER);
+ }
+
+ private static List<Metric> managerFateMetrics() {
+ return metricList(MetricDocSection.FATE);
+ }
+
+ private static List<Metric> managerCompactionMetrics() {
+ return metricList(MetricDocSection.COMPACTION);
+ }
+
+ private static List<Metric> scanServerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.SCAN_SERVER,
+ MetricDocSection.SCAN, MetricDocSection.BLOCK_CACHE);
+ }
+
+ private static List<Metric> tabletServerMetrics() {
+ return metricList(MetricDocSection.GENERAL_SERVER, MetricDocSection.TABLET_SERVER,
Review Comment:
> The goal with these changes is to make it easy to figure out what info to put in each table
For tablet servers I would like to try to focus on a few things w.r.t. metrics, are scans,writes, conditional updates failing or backed up? Hope to try experimenting w/ that in a follow on to this. If those high level indicators show a problem then would need to dig deeper to figure out why.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3110350002
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -59,54 +66,102 @@ public record Status(boolean hasServers, boolean hasProblemServers, boolean hasM
String message) {
}
- public static final String TYPE_COL_NAME = "Server Type";
- public static final String RG_COL_NAME = "Resource Group";
- public static final String ADDR_COL_NAME = "Server Address";
- public static final String TIME_COL_NAME = "Last Contact";
+ /**
+ * Definition of a column to be rendered in the UI
+ */
+ public record Column(String key, String label, String description, String uiClass) {
+ }
+
+ private record ServerMetricRow(ServerId server, MetricResponse response,
+ Map<String,Number> metrics) {
+ }
+
+ /**
+ * Server-process table identifiers accepted by /rest-v2/servers/view. These enum names are used
+ * directly as the frontend table parameter values.
+ */
+ public enum ServerTable {
+ COMPACTORS,
+ GC_SUMMARY,
+ GC_FILES,
+ GC_WALS,
+ MANAGERS,
+ MANAGER_FATE,
+ MANAGER_COMPACTIONS,
+ SCAN_SERVERS,
+ TABLET_SERVERS
+ }
private static final String LEVEL_OK = "OK";
private static final String LEVEL_WARN = "WARN";
+ public static final String RG_COL_KEY = "resourceGroup";
+ public static final String ADDR_COL_KEY = "serverAddress";
+ public static final String TIME_COL_KEY = "lastContact";
+
+ /**
+ * Common columns that are included in every ServersView table
+ */
+ private static final List<Column> COMMON_COLUMNS = List.of(
+ new Column(TIME_COL_KEY, "Last Contact",
+ "Time since the server last responded to the monitor", "duration"),
+ new Column(RG_COL_KEY, "Resource Group", "Resource Group", ""),
+ new Column(ADDR_COL_KEY, "Server Address", "Server address", ""));
+
public final List<Map<String,Object>> data = new ArrayList<>();
- public final Set<String> columns = new TreeSet<>();
+ public final List<Column> columns;
public final Status status;
public final long timestamp;
public ServersView(final Set<ServerId> servers, final long problemServerCount,
- final Cache<ServerId,MetricResponse> allMetrics, final long timestamp) {
+ final Cache<ServerId,MetricResponse> allMetrics, final long timestamp,
+ final List<Column> requestedColumns) {
AtomicInteger serversMissingMetrics = new AtomicInteger(0);
- servers.forEach(sid -> {
- Map<String,Object> metrics = new TreeMap<>();
-
- columns.add(TYPE_COL_NAME);
- metrics.put(TYPE_COL_NAME, sid.getType().name());
- columns.add(RG_COL_NAME);
- metrics.put(RG_COL_NAME, sid.getResourceGroup().canonical());
- columns.add(ADDR_COL_NAME);
- metrics.put(ADDR_COL_NAME, sid.toHostPortString());
-
- MetricResponse mr = allMetrics.getIfPresent(sid);
- if (mr != null) {
- // Don't use the timestamp for the last contact duration,
- // use the current time.
- columns.add(TIME_COL_NAME);
- metrics.put(TIME_COL_NAME, System.currentTimeMillis() - mr.getTimestamp());
-
- Map<String,Number> serverMetrics = metricValuesByName(mr);
- for (Entry<String,Number> e : serverMetrics.entrySet()) {
- columns.add(e.getKey());
- metrics.put(e.getKey(), e.getValue());
- }
- data.add(metrics);
- } else {
+ // Grab the current metrics for each server
+ List<ServerMetricRow> serverMetricRows = servers.stream().sorted().map(serverId -> {
+ MetricResponse metricResponse = allMetrics.getIfPresent(serverId);
+ boolean hasMetricData = hasMetricData(metricResponse);
+ Map<String,Number> serverMetrics =
+ hasMetricData ? metricValuesByName(metricResponse) : Map.of();
+
+ if (!hasMetricData) {
serversMissingMetrics.incrementAndGet();
}
+
+ return new ServerMetricRow(serverId, metricResponse, serverMetrics);
Review Comment:
Does the MetricResponse need to be serialized back to the UI in this case? How / where is it used?
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java:
##########
@@ -776,8 +776,17 @@ public long getTimestamp() {
return this.timestamp.get();
}
- public ServersView getServerProcessView(ServerId.Type type) {
- Supplier<ServersView> view = this.serverMetricsView.get(type);
+ /**
+ * Cache a ServersView for the given table and set of servers.
+ */
+ private void cacheServerProcessView(ServersView.ServerTable table, Set<ServerId> servers,
+ long problemHostCount) {
+ serverMetricsView.put(table, memoize(() -> new ServersView(Set.copyOf(servers),
Review Comment:
I don't think we need to create a copy of the servers set in this case. From where this is called in `finish`, nothing else is going to have a reference to the Set to mutate it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#discussion_r3111314668
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/views/ServersView.java:
##########
@@ -59,54 +66,102 @@ public record Status(boolean hasServers, boolean hasProblemServers, boolean hasM
String message) {
}
- public static final String TYPE_COL_NAME = "Server Type";
- public static final String RG_COL_NAME = "Resource Group";
- public static final String ADDR_COL_NAME = "Server Address";
- public static final String TIME_COL_NAME = "Last Contact";
+ /**
+ * Definition of a column to be rendered in the UI
+ */
+ public record Column(String key, String label, String description, String uiClass) {
+ }
+
+ private record ServerMetricRow(ServerId server, MetricResponse response,
+ Map<String,Number> metrics) {
+ }
+
+ /**
+ * Server-process table identifiers accepted by /rest-v2/servers/view. These enum names are used
+ * directly as the frontend table parameter values.
+ */
+ public enum ServerTable {
+ COMPACTORS,
+ GC_SUMMARY,
+ GC_FILES,
+ GC_WALS,
+ MANAGERS,
+ MANAGER_FATE,
+ MANAGER_COMPACTIONS,
+ SCAN_SERVERS,
+ TABLET_SERVERS
+ }
private static final String LEVEL_OK = "OK";
private static final String LEVEL_WARN = "WARN";
+ public static final String RG_COL_KEY = "resourceGroup";
+ public static final String ADDR_COL_KEY = "serverAddress";
+ public static final String TIME_COL_KEY = "lastContact";
+
+ /**
+ * Common columns that are included in every ServersView table
+ */
+ private static final List<Column> COMMON_COLUMNS = List.of(
+ new Column(TIME_COL_KEY, "Last Contact",
+ "Time since the server last responded to the monitor", "duration"),
+ new Column(RG_COL_KEY, "Resource Group", "Resource Group", ""),
+ new Column(ADDR_COL_KEY, "Server Address", "Server address", ""));
+
public final List<Map<String,Object>> data = new ArrayList<>();
- public final Set<String> columns = new TreeSet<>();
+ public final List<Column> columns;
public final Status status;
public final long timestamp;
public ServersView(final Set<ServerId> servers, final long problemServerCount,
- final Cache<ServerId,MetricResponse> allMetrics, final long timestamp) {
+ final Cache<ServerId,MetricResponse> allMetrics, final long timestamp,
+ final List<Column> requestedColumns) {
AtomicInteger serversMissingMetrics = new AtomicInteger(0);
- servers.forEach(sid -> {
- Map<String,Object> metrics = new TreeMap<>();
-
- columns.add(TYPE_COL_NAME);
- metrics.put(TYPE_COL_NAME, sid.getType().name());
- columns.add(RG_COL_NAME);
- metrics.put(RG_COL_NAME, sid.getResourceGroup().canonical());
- columns.add(ADDR_COL_NAME);
- metrics.put(ADDR_COL_NAME, sid.toHostPortString());
-
- MetricResponse mr = allMetrics.getIfPresent(sid);
- if (mr != null) {
- // Don't use the timestamp for the last contact duration,
- // use the current time.
- columns.add(TIME_COL_NAME);
- metrics.put(TIME_COL_NAME, System.currentTimeMillis() - mr.getTimestamp());
-
- Map<String,Number> serverMetrics = metricValuesByName(mr);
- for (Entry<String,Number> e : serverMetrics.entrySet()) {
- columns.add(e.getKey());
- metrics.put(e.getKey(), e.getValue());
- }
- data.add(metrics);
- } else {
+ // Grab the current metrics for each server
+ List<ServerMetricRow> serverMetricRows = servers.stream().sorted().map(serverId -> {
+ MetricResponse metricResponse = allMetrics.getIfPresent(serverId);
+ boolean hasMetricData = hasMetricData(metricResponse);
+ Map<String,Number> serverMetrics =
+ hasMetricData ? metricValuesByName(metricResponse) : Map.of();
+
+ if (!hasMetricData) {
serversMissingMetrics.incrementAndGet();
}
+
+ return new ServerMetricRow(serverId, metricResponse, serverMetrics);
+ }).toList();
+
+ Set<String> presentMetricNames = serverMetricRows.stream()
+ .flatMap(row -> row.metrics().keySet().stream()).collect(Collectors.toSet());
+
+ // Keep common columns and filter out metric columns that have no values
+ this.columns = requestedColumns.stream()
+ .filter(col -> isCommonColumn(col.key()) || presentMetricNames.contains(col.key()))
Review Comment:
Yea this is definitely an issue. Its a tradeoff. The filter was added to avoid a very wide table full of empty columns but filtering out empty columns is not a good longterm solution. The better longterm solution is to to make the per-table metric Lists smaller and more intentional then always show that list even if that means empty columns.
Maybe for now ill remove that filter so it makes it super obvious there is work to be done to refine the list for each table.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Centralize Monitor Server table definitons on backend [accumulo]
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on PR #6321:
URL: https://github.com/apache/accumulo/pull/6321#issuecomment-4281669509
> for every page I visited on the monitor it always fetched `/rest-v2/servers/view;table=SCAN_SERVERS` and `/rest-v2/servers/view;table=MANAGERS`. I suspect this is preexisting behavior and also suspect its caused by navbar.js, but not sure.
I'm pretty sure you're correct. With this PR the calls the navbar is making need to pull these full table model JSONs to get the data they need. I think it will be a worthwhile follow on to make a dedicated endpoint to return this info. That will be a lot more lightweight and not send a ton of unnecessary data.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org