Enabling alerts posted to a URL

About this task

Configure OpsCenter to send alert data to a specified URL that has a page capable of receiving and processing POST data.

For example, a simple PHP script containing print_r($_POST); echoes the received POST request.

An example POST request with its payload:

POST / HTTP/1.0
Host: localhost
User-Agent: Twisted PageGetter
Content-Length: 184
Content-type: application/x-www-form-urlencoded
connection: close

target_node=None&event_source=OpsCenter&success=None&level=1&level_str=INFO&api_source_ip=None&user=None&time=1400098707681966&action=18&message=OpsCenter+starting+up.&source_node=None

The request body contains fields described in Alerts along with the cluster name where applicable. JSON, template, and form URL-encoded content types are supported. To specify the field format and which fields are sent, reference the configuration file for examples of the key-value pair formatting.

Multiple instances of the posturl.conf file results in multiple instances of the event plugin. The configuration file can have any name provided the file has the .conf file extension, contains the valid event plugin identifier [posturl], and resides in the event-plugins directory location. All configuration files are loaded, so DataStax recommends that you differentiate the file names. For example, use posturl1.conf, posturl2.conf, and so on. Multiple plugin instances facilitate flexibility when setting up alerts for development and production clusters. All OpsCenter event plugins support multiple configurations files and subsequent plugin instances.

For related information, refer to OpsCenter installation and configuration locations.

OpsCenter can post alerts via http or https. To enable https, update the URL from http:// to https://.

Prerequisites

  • Make sure your web server and posting script are configured to receive alerts.

  • Locate the opscenterd.conf file. The location of this file depends on the type of installation:

    • Package installations: /etc/opscenter/opscenterd.conf

    • Tarball installations: install_location/conf/opscenterd.conf

  • If your machine is connected behind a proxy, open opscenterd.conf for editing and add the following under [http_proxy_settings]:

    proxy_url = http://your_proxy:port
    proxy_username = your_proxy_username
    proxy_password = your_proxy_password

Procedure

  1. Locate the posturl.conf file. The location of this file depends on the type of installation:

    • Package installations: /etc/opscenter/event-plugins/posturl.conf

    • Tarball installations: installation_location/conf/event-plugins/posturl.conf

  2. On the OpsCenter daemon host, open posturl.conf for editing.

  3. Set enabled=1.

  4. Specify the levels and clusters for which the alert configuration runs if you do not want alerts called for all levels and clusters.

  5. Adjust the connection timeout (connection_timeout) if the connection to the posturl is taking too long.

  6. For url, provide a valid path to the posting script.

  7. Set a username and password for HTTP Basic authentication.

  8. Set the type of posted data for post_type.

    Supported options are form (default), json, or template. Customize the message using the available key values described in the config file comments.

  9. Save posturl.conf and restart the OpsCenter daemon.

  10. Verify events are posting correctly.

Sample posturl.conf file

In a system with posting form data enabled for critical and alert-level events for all clusters, posturl.conf looks like:

[posturl]

enabled=1

# levels can be a comma-delimited list of any of the following:

# DEBUG,INFO,WARN,ERROR,CRITICAL,ALERT
# If left empty, will listen for all levels
levels=CRITICAL,ALERT

# clusters is a comma-delimited list of cluster names for which
# this alert config will be eligible to run.
# If left empty, this alert will be called for events on all clusters
clusters=

# the URL to send a HTTP POST to
url=http://host/path/to/script

# Set a username for basic HTTP authorization
#username=foo

# Set a password for basic HTTP authorization
#password=bar

# Set the type of posted data. Available options are 'form', 'json', and 'template'
post_type=form

# Fields specified here will override the default event data fields.
#
# They must be formatted as key-value pair, with key and value separated by
# an equals (=). Each pair after the first must be on its own line,
# indented beyond the first line
#
# You may use tokens found within the default event data for or in
# values. For example, some available keys are:
#   cluster, time, level_str, message, target_node, event_source, success, api_source_ip, user, source_node
# Keys must be encapsulated in {brackets}.
#
#fields=textKey=value
#    mixedKey=cluster-{cluster}
#    event-msg={message}

Examples of Configuration Settings

Example adding a static custom field to posturl.conf using the fields prefix. Specify all of the fields to include:

fields=message={message}
message_type=CRITICAL

Example form data displaying the message and cluster name:

FORM DATA: array (
   'event-msg' => 'OpsCenter starting up.',
   'mixedKey' => 'cluster-C1',
   'textKey' => 'value',
)

Example JSON data displaying the message and cluster name:

JSON DATA:
  {{
    "event-msg": "OpsCenter starting up.",
    "mixedKey": "cluster:C1",
    "textKey": "value"
  }}

Example template data displaying the message and cluster name:

TEMPLATE DATA:
  {{
    "event-msg": "OpsCenter starting up.",
    "mixedKey": "cluster:C1",
    "textKey": "value"
  }}

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com