Safe Haskell | None |
---|---|
Language | Haskell2010 |
The alerta API allows you to query and modify
- Alerts
- Environments
- Services
- Blackouts
- Heartbeats
- API Keys
- Users
- Customers
- createAlert :: Maybe ApiKey -> Alert -> ClientM CreateAlertResp
- getAlert :: Maybe ApiKey -> UUID -> ClientM AlertResp
- deleteAlert :: Maybe ApiKey -> UUID -> ClientM Resp
- setAlertStatus :: Maybe ApiKey -> UUID -> StatusChange -> ClientM Resp
- tagAlert :: Maybe ApiKey -> UUID -> Tags -> ClientM Resp
- untagAlert :: Maybe ApiKey -> UUID -> Tags -> ClientM Resp
- updateAlertAttributes :: Maybe ApiKey -> UUID -> Attributes -> ClientM Resp
- listAlerts :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe [AlertAttr] -> Maybe [AlertAttr] -> Maybe ShouldReverse -> [AlertAttr] -> Maybe PageNo -> Maybe Limit -> ClientM AlertsResp
- alertHistory :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe Limit -> ClientM AlertHistoryResp
- countAlerts :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> ClientM AlertCountResp
- top10 :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe AlertAttr -> ClientM Top10Resp
- flappingTop10 :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe AlertAttr -> ClientM Top10Resp
- listEnvironments :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe Limit -> ClientM EnvironmentsResp
- listServices :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe Limit -> ClientM ServicesResp
- createBlackout :: Maybe ApiKey -> Blackout -> ClientM BlackoutResp
- deleteBlackout :: Maybe ApiKey -> UUID -> ClientM Resp
- listBlackouts :: Maybe ApiKey -> ClientM BlackoutsResp
- createHeartbeat :: Maybe ApiKey -> Heartbeat -> ClientM CreateHeartbeatResp
- getHeartbeat :: Maybe ApiKey -> UUID -> ClientM HeartbeatResp
- deleteHeartbeat :: Maybe ApiKey -> UUID -> ClientM Resp
- listHeartbeats :: Maybe ApiKey -> ClientM HeartbeatsResp
- createApiKey :: ApiKey -> CreateApiKey -> ClientM CreateApiKeyResp
- deleteApiKey :: Maybe ApiKey -> ApiKey -> ClientM Resp
- listApiKeys :: Maybe ApiKey -> ClientM ApiKeysResp
- createUser :: Maybe ApiKey -> User -> ClientM UserResp
- deleteUser :: Maybe ApiKey -> UUID -> ClientM Resp
- updateUser :: Maybe ApiKey -> UUID -> UserAttr Nonempty -> ClientM Resp
- listUsers :: Maybe ApiKey -> Maybe CustomerName -> Maybe Email -> ClientM UsersResp
- createCustomer :: Maybe ApiKey -> Customer -> ClientM CustomerResp
- deleteCustomer :: Maybe ApiKey -> UUID -> ClientM Resp
- listCustomers :: Maybe ApiKey -> ClientM CustomersResp
- type Resource = Text
- type Event = Text
- type Service = Text
- type Environment = Text
- type Group = Text
- type Origin = Text
- type AlertType = Text
- type UserName = Text
- type CustomerName = Text
- type Tag = Text
- type Email = Text
- type Password = Text
- type Provider = Text
- type UUID = Text
- type Href = Text
- type ShouldReverse = Bool
- type Limit = Int
- type PageNo = Int
- type QueryString = Text
- type IsRepeat = Bool
- type FieldQuery = (QueryAttr, Text, MatchType, Bool)
- data MatchType
- (=.) :: QueryAttr -> Text -> FieldQuery
- (!=) :: QueryAttr -> Text -> FieldQuery
- (~.) :: QueryAttr -> Text -> FieldQuery
- (!~) :: QueryAttr -> Text -> FieldQuery
- data Resp
- = OkResp
- | ErrorResp {
- respMessage :: Text
- data Severity
- data Status
- data TrendIndication
- data Alert = Alert {
- alertResource :: Resource
- alertEvent :: Event
- alertEnvironment :: Maybe Environment
- alertSeverity :: Maybe Severity
- alertCorrelate :: Maybe [Event]
- alertStatus :: Maybe Status
- alertService :: Maybe [Service]
- alertGroup :: Maybe Group
- alertValue :: Maybe Value
- alertText :: Maybe Text
- alertTags :: Maybe [Tag]
- alertAttributes :: Maybe (Map Text Text)
- alertOrigin :: Maybe Origin
- alertType :: Maybe AlertType
- alertCreateTime :: Maybe UTCTime
- alertTimeout :: Maybe Int
- alertRawData :: Maybe Text
- alertCustomer :: Maybe CustomerName
- mkAlert :: Resource -> Event -> Service -> Alert
- data AlertInfo = AlertInfo {
- alertInfoId :: UUID
- alertInfoResource :: Resource
- alertInfoEvent :: Event
- alertInfoEnvironment :: Environment
- alertInfoSeverity :: Maybe Severity
- alertInfoCorrelate :: [Event]
- alertInfoStatus :: Maybe Status
- alertInfoService :: [Service]
- alertInfoGroup :: Group
- alertInfoValue :: Value
- alertInfoText :: Text
- alertInfoTags :: [Tag]
- alertInfoAttributes :: Map Text Text
- alertInfoOrigin :: Origin
- alertInfoType :: AlertType
- alertInfoCreateTime :: UTCTime
- alertInfoTimeout :: Int
- alertInfoRawData :: Maybe Text
- alertInfoCustomer :: Maybe CustomerName
- alertInfoDuplicateCount :: Maybe Int
- alertInfoRepeat :: Maybe Bool
- alertInfoPreviousSeverity :: Maybe Severity
- alertInfoTrendIndication :: Maybe TrendIndication
- alertInfoReceiveTime :: UTCTime
- alertInfoLastReceiveId :: Maybe UUID
- alertInfoLastReceiveTime :: UTCTime
- alertInfoHistory :: [HistoryItem]
- alertInfoHref :: Href
- data AlertAttr
- = IdAlertAttr
- | ResourceAlertAttr
- | EventAlertAttr
- | EnvironmentAlertAttr
- | SeverityAlertAttr
- | CorrelateAlertAttr
- | StatusAlertAttr
- | ServiceAlertAttr
- | GroupAlertAttr
- | ValueAlertAttr
- | TextAlertAttr
- | TagsAlertAttr
- | AttributesAlertAttr
- | OriginAlertAttr
- | TypeAlertAttr
- | CreateTimeAlertAttr
- | TimeoutAlertAttr
- | RawDataAlertAttr
- | CustomerAlertAttr
- | DuplicateCountAlertAttr
- | RepeatAlertAttr
- | PreviousSeverityAlertAttr
- | TrendIndicationAlertAttr
- | ReceiveTimeAlertAttr
- | LastReceiveIdAlertAttr
- | LastReceiveTimeAlertAttr
- | HistoryAlertAttr
- | HrefAlertAttr
- data QueryAttr
- = EventQueryAttr
- | EnvironmentQueryAttr
- | SeverityQueryAttr
- | CorrelateQueryAttr
- | StatusQueryAttr
- | ServiceQueryAttr
- | GroupQueryAttr
- | ValueQueryAttr
- | TextQueryAttr
- | TagsQueryAttr
- | AttributesQueryAttr
- | OriginQueryAttr
- | TypeQueryAttr
- | CreateTimeQueryAttr
- | TimeoutQueryAttr
- | RawDataQueryAttr
- | CustomerQueryAttr
- | RepeatQueryAttr
- | PreviousSeverityQueryAttr
- | TrendIndicationQueryAttr
- | ReceiveTimeQueryAttr
- | LastReceiveIdQueryAttr
- | LastReceiveTimeQueryAttr
- | HistoryQueryAttr
- | HrefQueryAttr
- data HistoryItem
- = StatusHistoryItem { }
- | SeverityHistoryItem { }
- data ExtendedHistoryItem
- = StatusExtendedHistoryItem {
- statusExtendedHistoryItemId :: UUID
- statusExtendedHistoryItemResource :: Resource
- statusExtendedHistoryItemEvent :: Event
- statusExtendedHistoryItemEnvironment :: Environment
- statusExtendedHistoryItemStatus :: Status
- statusExtendedHistoryItemService :: [Service]
- statusExtendedHistoryItemGroup :: Group
- statusExtendedHistoryItemText :: Text
- statusExtendedHistoryItemTags :: [Tag]
- statusExtendedHistoryItemAttributes :: Map Text Text
- statusExtendedHistoryItemOrigin :: Origin
- statusExtendedHistoryItemUpdateTime :: UTCTime
- statusExtendedHistoryItemCustomer :: Maybe CustomerName
- | SeverityExtendedHistoryItem {
- severityExtendedHistoryItemId :: UUID
- severityExtendedHistoryItemResource :: Resource
- severityExtendedHistoryItemEvent :: Event
- severityExtendedHistoryItemEnvironment :: Environment
- severityExtendedHistoryItemSeverity :: Severity
- severityExtendedHistoryItemService :: [Service]
- severityExtendedHistoryItemGroup :: Group
- severityExtendedHistoryItemValue :: Value
- severityExtendedHistoryItemText :: Text
- severityExtendedHistoryItemTags :: [Tag]
- severityExtendedHistoryItemAttributes :: Map Text Text
- severityExtendedHistoryItemOrigin :: Origin
- severityExtendedHistoryItemUpdateTime :: UTCTime
- severityExtendedHistoryItemCustomer :: Maybe CustomerName
- = StatusExtendedHistoryItem {
- newtype Tags = Tags {}
- newtype Attributes = Attributes {
- attributes :: Map Text Text
- data StatusChange = StatusChange {}
- data CreateAlertResp
- data AlertResp
- = OkAlertResp { }
- | ErrorAlertResp { }
- data AlertsResp
- = OkAlertsResp {
- okAlertsRespAlerts :: [AlertInfo]
- okAlertsRespTotal :: Int
- okAlertsRespPage :: PageNo
- okAlertsRespPageSize :: Int
- okAlertsRespPages :: Int
- okAlertsRespMore :: Bool
- okAlertsRespSeverityCounts :: Maybe (Map Severity Int)
- okAlertsRespStatusCounts :: Maybe (Map Status Int)
- okAlertsRespLastTime :: UTCTime
- okAlertsRespAutoRefresh :: Bool
- okAlertsRespMessage :: Maybe Text
- | ErrorAlertsResp { }
- = OkAlertsResp {
- data AlertCountResp
- data ResourceInfo = ResourceInfo {}
- data Top10Info = Top10Info {}
- data Top10Resp
- = OkTop10Resp { }
- | ErrorTop10Resp { }
- data AlertHistoryResp
- data EnvironmentInfo = EnvironmentInfo {}
- data EnvironmentsResp
- data ServiceInfo = ServiceInfo {}
- data ServicesResp
- data Blackout = Blackout {}
- blackout :: Environment -> Blackout
- data BlackoutInfo = BlackoutInfo {
- blackoutInfoId :: UUID
- blackoutInfoPriority :: Int
- blackoutInfoEnvironment :: Environment
- blackoutInfoResource :: Maybe Resource
- blackoutInfoService :: Maybe [Service]
- blackoutInfoEvent :: Maybe Event
- blackoutInfoGroup :: Maybe Group
- blackoutInfoTags :: Maybe [Tag]
- blackoutInfoCustomer :: Maybe CustomerName
- blackoutInfoStartTime :: UTCTime
- blackoutInfoEndTime :: UTCTime
- blackoutInfoDuration :: Int
- data BlackoutStatus
- data ExtendedBlackoutInfo = ExtendedBlackoutInfo {
- extendedBlackoutInfoId :: UUID
- extendedBlackoutInfoPriority :: Int
- extendedBlackoutInfoEnvironment :: Environment
- extendedBlackoutInfoResource :: Maybe Resource
- extendedBlackoutInfoService :: Maybe [Service]
- extendedBlackoutInfoEvent :: Maybe Event
- extendedBlackoutInfoGroup :: Maybe Group
- extendedBlackoutInfoTags :: Maybe [Tag]
- extendedBlackoutInfoCustomer :: Maybe CustomerName
- extendedBlackoutInfoStartTime :: UTCTime
- extendedBlackoutInfoEndTime :: UTCTime
- extendedBlackoutInfoDuration :: Int
- extendedBlackoutInfoRemaining :: Int
- extendedBlackoutInfoStatus :: BlackoutStatus
- data BlackoutResp
- data BlackoutsResp
- data Heartbeat = Heartbeat {}
- data HeartbeatInfo = HeartbeatInfo {}
- data CreateHeartbeatResp
- data HeartbeatResp
- data HeartbeatsResp
- data ApiKey = ApiKey {}
- data CreateApiKey = CreateApiKey {}
- data ApiKeyType
- data ApiKeyInfo = ApiKeyInfo {}
- data CreateApiKeyResp
- data ApiKeysResp
- data User = User {}
- user :: UserName -> Email -> Password -> User
- data UserAttr u = UserAttr {}
- data IsEmpty
- emptyUserAttr :: UserAttr Empty
- checkNonempty :: UserAttr u -> Either (UserAttr Empty) (UserAttr Nonempty)
- withUserName :: UserAttr u -> UserName -> UserAttr Nonempty
- withUserLogin :: UserAttr u -> Email -> UserAttr Nonempty
- withUserPassword :: UserAttr u -> Password -> UserAttr Nonempty
- withUserProvider :: UserAttr u -> Provider -> UserAttr Nonempty
- withUserText :: UserAttr u -> Text -> UserAttr Nonempty
- withUserEmailVerified :: UserAttr u -> Bool -> UserAttr u
- data UserInfo = UserInfo {}
- data RoleType
- data ExtendedUserInfo = ExtendedUserInfo {}
- data UserResp
- = OkUserResp { }
- | ErrorUserResp { }
- data UsersResp
- = OkUsersResp { }
- | ErrorUsersResp { }
- data Customer = Customer {}
- data CustomerInfo = CustomerInfo {}
- data CustomerResp
- data CustomersResp
- run :: (Show a, FromJSON a, ToJSON a) => ClientM a -> IO a
- run' :: (Show a, FromJSON a, ToJSON a) => ClientM a -> IO ()
- prettyPrintEncoding :: ToJSON a => a -> IO ()
- now :: () -> UTCTime
Bindings
Alerts
createAlert :: Maybe ApiKey -> Alert -> ClientM CreateAlertResp Source #
setAlertStatus :: Maybe ApiKey -> UUID -> StatusChange -> ClientM Resp Source #
updateAlertAttributes :: Maybe ApiKey -> UUID -> Attributes -> ClientM Resp Source #
Alert history and alert queries
:: Maybe ApiKey | |
-> Maybe QueryString | this is a JSON document describing a Mongo query see http://docs.mongodb.org/manual/reference/operator/query/ |
-> [UUID] | |
-> IsRepeat | |
-> [FieldQuery] | |
-> Maybe [AlertAttr] | alert attributes to show |
-> Maybe [AlertAttr] | alert attributes to hide |
-> Maybe ShouldReverse | |
-> [AlertAttr] | |
-> Maybe PageNo | |
-> Maybe Limit | |
-> ClientM AlertsResp |
alertHistory :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe Limit -> ClientM AlertHistoryResp Source #
countAlerts :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> ClientM AlertCountResp Source #
top10 :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe AlertAttr -> ClientM Top10Resp Source #
flappingTop10 :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe AlertAttr -> ClientM Top10Resp Source #
Environments
listEnvironments :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe Limit -> ClientM EnvironmentsResp Source #
Services
listServices :: Maybe ApiKey -> Maybe QueryString -> [UUID] -> IsRepeat -> [FieldQuery] -> Maybe Limit -> ClientM ServicesResp Source #
Blackouts
createBlackout :: Maybe ApiKey -> Blackout -> ClientM BlackoutResp Source #
Heartbeats
getHeartbeat :: Maybe ApiKey -> UUID -> ClientM HeartbeatResp Source #
API keys
createApiKey :: ApiKey -> CreateApiKey -> ClientM CreateApiKeyResp Source #
listApiKeys :: Maybe ApiKey -> ClientM ApiKeysResp Source #
Users
Customers
createCustomer :: Maybe ApiKey -> Customer -> ClientM CustomerResp Source #
Types
General domain terms
type Environment = Text Source #
type CustomerName = Text Source #
Query and sorting options
type ShouldReverse Source #
= Bool | whether to reverse the order of a sort |
type QueryString = Text Source #
This is a JSON document describing a Mongo query, see http://docs.mongodb.org/manual/reference/operator/query/
true for duplicate, false if an alert is correlated (in which case alerta appends an item to the history)
Field queries
Matches can be either literal or regular expressions. n.b. regexes are case-insensitive and are not anchored, i.e. no need to write .*regex.*
(=.) :: QueryAttr -> Text -> FieldQuery Source #
Convenient syntax for the four types of field queries viz. literal, negated literal, regex, negated regex.
(!=) :: QueryAttr -> Text -> FieldQuery Source #
Convenient syntax for the four types of field queries viz. literal, negated literal, regex, negated regex.
(~.) :: QueryAttr -> Text -> FieldQuery Source #
Convenient syntax for the four types of field queries viz. literal, negated literal, regex, negated regex.
(!~) :: QueryAttr -> Text -> FieldQuery Source #
Convenient syntax for the four types of field queries viz. literal, negated literal, regex, negated regex.
Generic response
This type is used for basic responses that have no content beyond whether they succeeded or failed with an error message.
Alerts
Alert severity
Unknown | |
Trace | 8 (grey) |
Debug | 7 (purple) |
Informational | 6 (green) |
Ok | 5 (green) |
Normal | 5 (green) |
Cleared | 5 (green) |
Indeterminate | 5 (silver) |
Warning | 4 (blue) |
Minor | 3 (yellow) |
Major | 2 (orange) |
Critical | 1 (red) |
Security | 0 (black) |
Status of an alert.
OpenStatus | status code 1 |
AssignStatus | status code 2 |
AckStatus | status code 3 |
ClosedStatus | status code 4 |
ExpiredStatus | status code 5 |
UnknownStatus | status code 9 |
data TrendIndication Source #
Data required to create (post) an alert.
Alert | |
|
mkAlert :: Resource -> Event -> Service -> Alert Source #
Create an alert with just the mandatory fields.
Data returned from the server about an alert
Alert attributes, used for sorting, grouping and for field-based queries
These are the valid keys for use in field queries.
NB no id
, repeat
or duplicateCount
as these have special handling.
data ExtendedHistoryItem Source #
When performing an alert history query an enriched version of the alert history is returned with extra fields.
newtype Attributes Source #
Attributes are key-value pairs that can be attached to an alert.
data StatusChange Source #
data CreateAlertResp Source #
OkCreateAlertResp | |
| |
ErrorCreateAlertResp | |
data AlertsResp Source #
data ResourceInfo Source #
This also has a field corresponding to the "group-by" query parameter used i.e. if you group by origin, then the result will have an "origin" field.
This dependently-typed feature is not currently captured in the Haskell types.
Environments
data EnvironmentInfo Source #
Services
Blackouts
Blackout | |
|
blackout :: Environment -> Blackout Source #
Create a blackout with only the mandatory fields
data BlackoutInfo Source #
A note on blackout priorities:
Priority is
- by default
- if resource and not event present
- if service present
- if event and not resource
- if group present
- if resource and event present
- if tags present
Somewhat bizarrely, the saved blackout only includes an attribute
{resource,service,event,group,tags}
if it was used to deduce the priority, i.e. a priority 6 blackout will have resource and event attributes, but no tags attribute, even if it was supplied when it was created.
BlackoutInfo | |
|
data BlackoutStatus Source #
data ExtendedBlackoutInfo Source #
Heartbeats
Data needed to create a heartbeat
API keys
40-char UTF8
data CreateApiKey Source #
Data needed to create an API key
CreateApiKey | |
|
data ApiKeyType Source #
Users
User attributes, used in updating a user. It's an error to update a user with all attributes missing.
We track whether at least one attribute has been set with a phantom type.
Alerta bugs:
- can't update password without also passing provider=basic as alerta checks the update message, not the user.
- can't set email_verified to false without providing another parameter.
The helper functions "withUserName" etc. can be used in conjunction with the default empty UserAttr to build up a nonempty UserAttr.
OkUsersResp | |
| |
ErrorUsersResp | |
Customers
data CustomerInfo Source #
Helpers
run :: (Show a, FromJSON a, ToJSON a) => ClientM a -> IO a Source #
Run a Servant client function, pretty-printing the JSON returned.
run' :: (Show a, FromJSON a, ToJSON a) => ClientM a -> IO () Source #
Run a Servant client function, pretty-printing the JSON returned, and discarding the return value.
prettyPrintEncoding :: ToJSON a => a -> IO () Source #
Pretty-print the JSON encoding of the supplied value.