Alerts Configuration

Configuration - JSON Structure

Alerts are stored as JSON configuration, in Ceptor's configuration as a property named "alerts_JSON_" in the abstract server configuration named "alerts" (the Ceptor Console will create it for you if it does not already exists - but if you need to change it using APIs, you need to know the naming).

Example alert actions
{"actions": [
  {
    "name": "Log the alert",
    "type": "log",
    "conditions": [],
    "level": "WARN"
  },
  {
    "name": "Alert Administrator",
    "type": "sms",
    "conditions": [],
    "mobile": "+4526164023"
  },
  {
    "name": "Send email to admin",
    "type": "email",
    "conditions": [],
    "email": "kr@asseco.dk",
    "email.prefix": "[Alert !!!]"
  },
  {
    "name": "Create an action",
    "type": "log",
    "conditions": [{
      "name": "Only server down",
      "type": "server_down"
    }],
    "logger": "alerts",
    "level": "ERROR"
  },
  {
    "name": "Run a script",
    "type": "script",
    "conditions": [],
    "script": "%{script}//\r\n// Example javascript that simply writes both the configuration and alerts to stdout\r\n//\r\n\r\nprint(context.configuration);\r\nprint(context.alert.getType());\r\nprint(context.alert.getID());\r\nprint(context.alert.getTitle() + ' - ' + context.alert.getMessage());\r\nprint(context.alert.toJSONString());"
  }
]}

The "alerts_JSON_" property contains a JSON array called "actions", and each action looks like this:

KeyDescription
nameName of the Alert Action
type

Type of action, must be one of:

  • sms
  • email
  • console
  • log
  • script
conditionsJSON Array of conditions - if empty, no conditions are defined, meaning Alert Action matches all alerts.
loggerName of logger to log message to - only for actions of type "log"
levelLogger Level, either TRACE, DEBUG, INFO, WARN or ERROR - only for actions of type "log"
emailEmail address - only for actions of type "email"
email.prefixEmail subject prefix - only for actions of type "email"
mobileMobile phone number - only for actions of type "sms"
scriptScript to execute - only for actions of type "script"


For conditions, each condition is a JSON object within the conditions array in an Alert Action

KeyDescription
type

Type of alert to match, one of:

  • certificateexpires_soon
  • certificate_is_expired
  • server_down
  • server_up
subjectPattern matching certificate Subject
issuerPattern matching certificate Issuer
destinationPattern matching gateway destination name
gatewayPattern matching gateway name
hostPattern matching hostname
portPort number
scriptScript to execute to decide if this condition matches

Configuration - Properties

In order to be able to send emails / SMS messages, some configuration is required - this configuration must be set for the Ceptor Configuration Server which processes the alert actions defined.

Example configuration:

<group name="alerts" description="Alert actions related configuration">
	<property name="mail.from" value="" description=""/>
	<property name="mail.replyto" value="" description=""/>
	<property name="mail.smtp.host" value="" description=""/>
	<property name="mail.smtp.password" value="" description=""/>
	<property name="mail.smtp.port" value="25" description=""/>
	<property name="mail.smtp.protocol" value="smtps" description=""/>
	<property name="mail.smtp.user" value="" description=""/>
	<property name="sms.apikey" value="" description="For CPSMS, if present, sms.password is not used"/>
	<property name="sms.appnr" value="1231" description="For unwire, specify from phone number"/>
	<property name="sms.flashsms" value="false" description="If true, SMS is sent as flash SMS"/>
	<property name="sms.from" value="Ceptor" description="Max 11 characters from name or number"/>
	<property name="sms.httpProxyHost" value="" description="HTTP Proxy Server"/>
	<property name="sms.httpProxyPassword" value="" description="HTTP Proxy Password for proxy authentication"/>
	<property name="sms.httpProxyPort" value="8080" description="HTTP Proxy Port"/>
	<property name="sms.httpProxyUser" value="" description="HTTP Proxy Userid to use for authentication"/>
	<property name="sms.mediacode" value="" description="For unwire, specify mediacode"/>
	<property name="sms.password" value="" description="Password for SMS gateway"/>
	<property name="sms.provider" value="cpsms" description="cpsms or unwire depending on which SMS provider to use (locallogging for logging codes to log file)"/>
	<property name="sms.smsc" value="dk.tdc" description="For unwire, specify operator to use"/>
	<property name="sms.username" value="portalprotect" description="Username for SMS gateway"/>
	<property name="sms.verifysslhostname" value="true" description="Set to false to turn off hostname verification"/>
	<property name="sms.verifysslservercert" value="true" description="Set to false to turn SSL server certificate validation"/>
</group>

The following properties exists for sending alerts via Email:

NameDefaultDescription
mail.smtp.host
Hostname of SMTP server
mail.smtp.protocolsmtpsEmail protocol, should be smtp or smtps
mail.smtp.port25Port number of SMTP server
mail.smtp.user
Userid for authenticating to SMTP server
mail.smtp.password
Password for SMTP Server - see Encrypting or Obfuscating Passwords for info on encrypting it
mail.from
Sender of the email
mail.replyto
If present, the reply-to email header is set to this.


And the following properties exists for sending alerts via SMS:

NameDefaultDescription
sms.httpProxyHost
HTTP Proxy hostname
sms.httpProxyPort
HTTP Proxy port
sms.httpProxyUser
HTTP Proxy username
sms.httpProxyPassword
HTTP Proxy password
sms.fromCeptorName of Sender - shows up as SMS sender
sms.flashsmsfalseTrue if SMS should be sent as flash SMS - flash SMS's are not saved in the history, and shown as popup.
sms.verifysslhostnametrueSet to false to turn off hostname validation of SMS server
sms.verifysslservercerttrueSet to false to turn off SSL certificate validation when calling the SMS server
sms.providercpsmsName of SMS Provider, either cpsms or unwire
When SMS Provider is cpsms
sms.serverhttps://www.cpsms.dkServer to use when sending SMS
sms.username
Username from CPSMS
sms.password
Password
sms.apikey
API Key - if specified, the API Key is used instead of password when authenticating to the SMS provider.
When SMS provider is unwire
sms.serverhttps://gw.unwire.comUnwire gateway Server URL.
sms.username
Userid for unwire account
sms.password
Password for unwire account
sms.smscdk.tcpSMSC - contact unwire for info
sms.appnr1231Number to send via - contact unwire for info
sms.mediacode
Optional mediacode - contact unwire for info

Alerts - JSON Structure

Each Alert has its own JSON Structure

Example Alert
{
  "type": "server_up",
  "id": "63ba3e15-0275-4c8b-aa0f-b2340873cc1e",
  "title": "Server api.worldbank.org:80 up",
  "message": "Server worldbank_sandbox (api.worldbank.org@api.worldbank.org:80) is back up after 42 minutes",
  "gateway": "gateway1",
  "destination": "worldbank_sandbox",
  "host": "api.worldbank.org",
  "port": 80,
  "duration": 2520512
}

This is a list of the keys / attributes that the alert can contain:

KeyDescription
type

Type of alert, one of:

  • certificateexpires_soon
  • certificate_is_expired
  • server_down
  • server_up
idUnique ID of this alert
titleAlert title
messageMessage body
sourceFor Certificates, the source, e.g. name of keystore or file it was loaded from.
ownerFor Certificates, the name of the module that loaded the certificate, e.g. "sessionctrl1"
purposePurpose of the certificate, e.g. SAML Signing or JWT Validation
certificateX.509 Base64 encoded version of the certificate
gatewayGateway name
destinationDestination name
hostHostname
portPort number

© Ceptor ApS. All Rights Reserved.