public class Alert extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Alert.AlertSeverity |
Constructor and Description |
---|
Alert()
Construct new alert object
|
Modifier and Type | Method and Description |
---|---|
void |
addCustomMetadata(String key,
String value)
Set a custom metadata value
|
boolean |
addMetadata(AlertMeta.Key key,
List<String> value)
Add metadata as a list of values
|
boolean |
addMetadata(AlertMeta.Key key,
String value)
Add metadata
|
void |
addToPayload(String line)
Add new line to payload buffer
|
String |
assemblePayload()
Assemble a complete payload buffer that contains alert metadata information in addition to the
alert payload.
|
boolean |
equals(Object o) |
static Alert |
fromJSON(String input)
Return
Alert from JSON string |
static Alert |
fromJSON(String input,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Return
Alert from JSON string |
HashMap<String,Object> |
generateTemplateVariables()
Return HashMap used by Freemarker to generate an HTML alert email
|
UUID |
getAlertId()
Returns unique alert ID for this alert.
|
String |
getCategory()
Get alert category
|
String |
getCustomMetadataValue(String key)
Return a custom metadata value
|
String |
getEmailTemplate()
Get email template name
|
ArrayList<AlertMeta> |
getMetadata()
Get alert metadata
|
String |
getMetadataValue(AlertMeta.Key key)
Return a specific metadata value
|
String |
getNotifyMergeKey()
Get alert merge key for notifications from metadata
|
String |
getPayload()
Get alert payload
|
Alert.AlertSeverity |
getSeverity()
Get alert severity
|
String |
getSlackCatchallTemplate()
Get slack catchall template name
|
String |
getSlackTemplate()
Get slack template name
|
String |
getSubcategory()
Get alert subcategory
|
String |
getSummary()
Get alert summary
|
org.joda.time.DateTime |
getTimestamp()
Get alert timestamp
|
Boolean |
hasCorrectFields()
Determine if an alert has all mandatory fields set correctly
|
int |
hashCode() |
void |
setAlertId(UUID alertId)
Override generated unique ID for alert
|
void |
setCategory(String category)
Set alert category
|
void |
setEmailTemplate(String templateName)
Set email template name
|
void |
setMetadata(ArrayList<AlertMeta> metadata)
Set alert metadata
|
boolean |
setMetadataValue(AlertMeta.Key key,
String value)
Change an existing metadata value
|
void |
setNotifyMergeKey(String key)
Set alert merge key for notifications in metadata
|
void |
setSeverity(Alert.AlertSeverity severity)
Set alert severity
|
void |
setSlackCatchallTemplate(String templateName)
Set slack catchall template name
|
void |
setSlackTemplate(String templateName)
Set slack template name
|
void |
setSubcategory(String subcategory)
Set alert subcategory
|
void |
setSummary(String summary)
Set alert summary
|
void |
setTimestamp(org.joda.time.DateTime timestamp)
Override alert timestamp
|
String |
toJSON()
Return JSON string representation.
|
public Boolean hasCorrectFields()
Pipelines should call this on any Alert
object that is going to be submitted to
ensure it will not be dropped by the output transforms.
public String assemblePayload()
public void setSummary(String summary)
summary
- Alert summary stringpublic String getSummary()
public void setNotifyMergeKey(String key)
If a merge key is set in metadata for an alert, some output transforms will utilize this key to group any other alerts with the same key together to minimize generation of similar/duplicate alerts.
key
- Merge key for alert notificationspublic String getNotifyMergeKey()
public void setSeverity(Alert.AlertSeverity severity)
severity
- Severitypublic Alert.AlertSeverity getSeverity()
public void addToPayload(String line)
line
- Line to append to existing payload bufferpublic String getPayload()
public String getMetadataValue(AlertMeta.Key key)
key
- Key to return data forpublic String getCustomMetadataValue(String key)
Custom metadata includes arbitrary keys that are not standardized, such as keys set in configuration ticks. This method should not be used under normal circumstances.
key
- Key to return data forpublic boolean setMetadataValue(AlertMeta.Key key, String value)
If the key does not exist, it will be added. Note that if multiple entries exist with the same key, this method will only change the first encountered.
key
- Key to setvalue
- Value to set for keypublic void setMetadata(ArrayList<AlertMeta> metadata)
metadata
- ArrayListpublic boolean addMetadata(AlertMeta.Key key, String value)
key
- Keyvalue
- Valuepublic boolean addMetadata(AlertMeta.Key key, List<String> value)
Only valid for LIST type fields.
key
- Keyvalue
- Listpublic void addCustomMetadata(String key, String value)
Custom metadata includes arbitrary keys that are not standardized, such as keys set in configuration ticks. This method should not be used under normal circumstances.
key
- Key to setvalue
- Value to setpublic void setTimestamp(org.joda.time.DateTime timestamp)
timestamp
- Alert timestamppublic org.joda.time.DateTime getTimestamp()
public void setCategory(String category)
category
- Alert category stringpublic String getCategory()
public String getSubcategory()
public void setSubcategory(String subcategory)
subcategory
- Subcategory stringpublic void setEmailTemplate(String templateName)
templateName
- Freemarker template name with file extensionpublic String getEmailTemplate()
public void setSlackTemplate(String templateName)
templateName
- Freemarker template name with file extensionpublic String getSlackTemplate()
public void setSlackCatchallTemplate(String templateName)
templateName
- Freemarker template name with file extensionpublic String getSlackCatchallTemplate()
public void setAlertId(UUID alertId)
alertId
- Alert ID for alertpublic UUID getAlertId()
UUID
associated with alert.public static Alert fromJSON(String input)
Alert
from JSON stringinput
- Alert in JSONAlert
object or null if deserialization fails.public static Alert fromJSON(String input, com.fasterxml.jackson.databind.ObjectMapper mapper)
Alert
from JSON stringinput
- Alert in JSONmapper
- ObjectMapperAlert
object or null if deserialization fails.public String toJSON()
Copyright © 2022. All rights reserved.