Configuring alarms for HTTP notification

This process works much like the process for setting up email or SNMP notifications but does not require you to create an additional configuration file. To configure Blue Planet to send HTTP alarm notifications to an external service, you need only to create templates and rules.

A limitation of HTTP dispatch exists. This service must have direct HTTP access to any server that is to receive a POST notification. If you are having trouble with this feature, verify that a ping or Curl command from the Blue Planet server succeeds against your HTTP notification target server.

To create HTTP templates and rules, use a method similar to email or SNMP template creation, with exceptions as noted in Configuring an HTTP rule.

Configuring an HTTP rule
  1. As with email notifications, to create HTTP notifications you must first create a template object. You can either send a JSON payload to the ntfconfig API endpoint for templates programmatically or use a command line tool such as Curl.

    In the following examples, the example payloads send data to the notification config API. This simple method verifies everything is working without setting up an HTTP server to receive notifications.

    1. To create a JSON payload that creates an SNMP template programmatically:

       {
           "name": "Example Template [{{ get('message.header.timestamp') }}]",
           "template_text": "{\"name\": \"Loopback_Template\", \"template_text\": \"I created a template when message {{ get('message.header.envelopeId') }} arrived!\"}"
       }

      Note that the template example is a JSON statement to create another template. You do not need to use JSON, but if you want to use XML or another format, you must define it in the notification_params field of the rule (see below). If you do not provide another content-type, JSON is assumed.

       {
           "name": "Loopback Template",
           "template_text": "I created a template when message {{ get('message.header.envelopeId') }} arrived!"
       }
    2. To post this template using Curl:

      curl -X POST http://HAPROXY_IP/ntfconfig/api/v1/ templates -- header ′content-type: application/json′; -d'{"name": "Example Template [{{ get('message.header.timestamp') }}]", "template_text": "{\"name\": \"Loopback_Template\", \"template_text\": \"I created a template when message {{ get(\u0027message.header.envelopeId\u0027) }} arrived!\"}"}'
  2. To create an HTTP rule, follow steps similar to email rule creation, except set the notification_type field to http. You can then complete the specific requirements for the notification_params field.

    1. To create a JSON payload HTTP rule programmatically:

       {
           "name": "Tron Example Rule",
           "notification_type": "http",
           "topic": "bp.tron.v1.changes",
           "trigger_type": "bp.v1.ObjectChanged",
           "template": 2,
           "notification_params": "{\"target\": \"http://MY_HOST_IP/ntfconfig/api/v1/templates\", \"headers\": {\"Content-Type\": \"application/json\"}, \"cookies\": {}}",
           "extra_compare": "{}"
       }

      This rule listens on the alarm processor output topic and triggers on Alarm Raised events on a specific resource. HTTP rules do not work correctly unless the Content-Type field in notification_params matches the format of data in the template_text of the associated template. The API allows you to associate a rule with a template whose data type does not match, so be sure to double check.

      Cookies is optional, and in most cases you can omit it, as use of HTTP cookies are better served by the use of headers. Similarly, the Content-Type header need not be included. The default is application/json, as follows. If you have no headers to add and are using JSON data, you might omit the whole headers key and provide a target URL only.

    2. To post this rule using Curl:

      curl -X POST http://HAPROXY_IP/ntfconfig/api/v1/rules -- header 'content-type: application/json' -d '{"name": "Tron Example Rule", "notification_type": "http", "topic": "bp.tron.v1.changes", "trigger_type": "bp.v1.ObjectChanged", "template": 2, "notification_params": "{\"target\": \"http://MY_HOST_IP/ntfconfig/api/v1/templates\", \"headers\": {\"Content-Type\": \"application/json\"}, \"cookies\": {}}", "extra_compare": "{}"}'
  3. A new template called Loopback Template is added to the Blue Planet notification API when a matching message of the appropriate type triggers the rule. Because template names are a unique field, this occurs once, and further notification attempts with this rule/template configuration have no effect.

results matching ""

    No results matching ""