public class AlertSummaryRenderer extends BaseRenderer implements Renderer
AlertSummaryRenderer is used to format the results of queries to
the alerts endpoint. Each item returned from the query represents an
individual current alert which is then aggregated into a summary structure
based on the alert state.
The finalized structure is:
{
"href" : "http://localhost:8080/api/v1/clusters/c1/alerts?format=summary",
"alerts_summary" : {
"CRITICAL" : {
"count" : 3,
"maintenance_count" : 1,
"original_timestamp" : 1415372828182
},
"OK" : {
"count" : 37,
"maintenance_count" : 0,
"original_timestamp" : 1415375364937
},
"UNKNOWN" : {
"count" : 1,
"maintenance_count" : 0,
"original_timestamp" : 1415372632261
},
"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.| Constructor and Description |
|---|
AlertSummaryRenderer() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addRequiredAlertProperties(Set<String> properties)
Adds properties to the backend request that are required by this renderer.
|
TreeNode<Set<String>> |
finalizeProperties(TreeNode<QueryInfo> queryTree,
boolean isCollection)
Finalize which properties are requested by the query.
|
Result |
finalizeResult(Result queryResult)
Finalize the query results.
|
ResultPostProcessor |
getResultPostProcessor(Request request)
Obtain the associated post processor.
|
addKeys, addPrimaryKey, addSubResources, copyPropertiesToResult, ensureRequiredProperties, getSchema, init, isRequestWithNoProperties, populateSubResourceDefaults, requiresPropertyProviderInputclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinit, requiresPropertyProviderInputpublic TreeNode<Set<String>> finalizeProperties(TreeNode<QueryInfo> queryTree, boolean isCollection)
finalizeProperties in interface RendererqueryTree - tree of query information. Contains query information
for the root query and all sub-queries (children)isCollection - whether the query is a collectionpublic ResultPostProcessor getResultPostProcessor(Request request)
getResultPostProcessor in interface Rendererrequest - original requestpublic Result finalizeResult(Result queryResult)
AlertResourceProvider.ALERT_STATE into a single summary
structure.finalizeResult in interface RendererqueryResult - result of query in native (default) formatprotected void addRequiredAlertProperties(Set<String> properties)
AlertResourceProvider.ALERT_STATE and
AlertResourceProvider.ALERT_ORIGINAL_TIMESTAMP.properties - the properties collection to add to.Copyright © 2022 Apache Software Foundation. All rights reserved.