public class AlertSummaryGroupedRenderer extends AlertSummaryRenderer
AlertSummaryGroupedRenderer
is used to format the results of
queries to the alerts endpoint. Each alert instance returned from the backend
is grouped by its alert definition and its state is then aggregated into the
summary information for that definition.
The finalized structure is:
{ "alerts_summary_grouped" : [ { "definition_id" : 1, "definition_name" : "datanode_process", "summary" : { "CRITICAL": { "count": 1, "maintenance_count" : 1, "original_timestamp": 1415372992337, "latest_text" : "TCP Connection Failure" }, "OK": { "count": 1, "maintenance_count" : 0, "original_timestamp": 1415372992337, "latest_text" : "TCP OK" }, "UNKNOWN": { "count": 0, "maintenance_count" : 0, "original_timestamp": 0 }, "WARN": { "count": 0, "maintenance_count" : 0, "original_timestamp": 0 } } }, { "definition_id" : 2, "definition_name" : "namenode_process", "summary" : { "CRITICAL": { "count": 1, "maintenance_count" : 0, "original_timestamp": 1415372992337 }, "OK": { "count": 1, "maintenance_count" : 0, "original_timestamp": 1415372992337 }, "UNKNOWN": { "count": 0, "maintenance_count" : 0, "original_timestamp": 0 }, "WARN": { "count": 0, "maintenance_count" : 0, "original_timestamp": 0 } } } ] }The nature of a
Renderer
is that it manipulates the dataset returned
by a query. In the case of alert data, the query could potentially return
thousands of results if there are thousands of nodes in the cluster. This
could present a performance issue that can only be addressed by altering the
incoming query and modifying it to instruct the backend to return a JPA SUM
instead of a collection of entities.Modifier and Type | Class and Description |
---|---|
static class |
AlertSummaryGroupedRenderer.AlertDefinitionSummary
The
AlertSummaryGroupedRenderer.AlertDefinitionSummary is a simple data structure for keeping
track of each alert definition's summary information as the result set is
being iterated over. |
Constructor and Description |
---|
AlertSummaryGroupedRenderer() |
Modifier and Type | Method and Description |
---|---|
protected void |
addRequiredAlertProperties(Set<String> properties)
Adds properties to the backend request that are required by this renderer.
|
Result |
finalizeResult(Result queryResult)
Finalize the query results.
|
static Map<String,AlertSummaryGroupedRenderer.AlertDefinitionSummary> |
generateEmptySummary(Long definitionId,
String definitionName) |
static void |
updateSummary(Map<String,AlertSummaryGroupedRenderer.AlertDefinitionSummary> summaries,
Long definitionId,
String definitionName,
AlertState state,
Long originalTimestampObject,
MaintenanceState maintenanceState,
String alertText) |
finalizeProperties, getResultPostProcessor
addKeys, addPrimaryKey, addSubResources, copyPropertiesToResult, ensureRequiredProperties, getSchema, init, isRequestWithNoProperties, populateSubResourceDefaults, requiresPropertyProviderInput
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
init, requiresPropertyProviderInput
public Result finalizeResult(Result queryResult)
AlertResourceProvider.ALERT_STATE
into a single summary
structure.
This will iterate over all of the nodes in the result tree and combine
their AlertResourceProvider.ALERT_STATE
into a single summary
structure.finalizeResult
in interface Renderer
finalizeResult
in class AlertSummaryRenderer
queryResult
- result of query in native (default) formatpublic static void updateSummary(Map<String,AlertSummaryGroupedRenderer.AlertDefinitionSummary> summaries, Long definitionId, String definitionName, AlertState state, Long originalTimestampObject, MaintenanceState maintenanceState, String alertText)
public static Map<String,AlertSummaryGroupedRenderer.AlertDefinitionSummary> generateEmptySummary(Long definitionId, String definitionName)
protected void addRequiredAlertProperties(Set<String> properties)
AlertResourceProvider.ALERT_STATE
and
AlertResourceProvider.ALERT_ORIGINAL_TIMESTAMP
.
Additionally adds AlertResourceProvider.ALERT_ID
and
AlertResourceProvider.ALERT_DEFINITION_NAME
.addRequiredAlertProperties
in class AlertSummaryRenderer
properties
- the properties collection to add to.Copyright © 2022 Apache Software Foundation. All rights reserved.