add-alerting-target.sh

add-alerting-target.sh

The
add-alerting-target.sh
script allows you to configure
Resonate
to send alerts to one or more targets via emails (SMTP) or webhooks. It creates AlertManagerConfig custom resources (CRs) that configure how AlertManager routes and delivers notifications.

Command Syntax

./add-alerting-target.sh [options]

Common Options

The following options are common to all alerting target types:
Option
Description
--help
Display help message.
--type <smtp|webhook>
Type of alerting target.
Required:
Yes
--name <name>
Name for the alerting target. Essentially, this is a user-assigned label for the target. It must be unique.
Required:
Yes
--alertgroup <device|service|both>
Filter alerts by alert group.
Default:
both
--group-by <label1,label2,...>
Labels by which to group alerts. See below for the list of possible labels. For example:
--group-by app,severity
Default:
...
(all labels)
--group-wait <duration>
How long to wait before sending the initial notification.
Default: 30s
--group-interval <duration>
How long to wait before sending an updated notification.
Default: 5m
--repeat-interval <duration>
How long to wait before repeating the last notification.
Default: 4h
--matchers '<matcher1,matcher2,matcherN>'
Alert label matchers in the format “name=value” or “name!=value”. There can be multiple matchers delimited by commas.

Alert Grouping Options

The
--alertgroup
parameter lets you filter alerts based on their group:
  • device
    : Only receive reader-related alerts.
  • service
    : Only receive service-related alerts.
  • both
    : Receive both device and service alerts, but exclude alerts with a different or missing alertgroup (default).

Matchers and Filtering

The
--matchers
parameter allows for sophisticated filtering of alerts based on their labels. You can specify multiple matchers, which are applied as AND conditions.
  • Matcher Syntax
    Enter matchers using the following syntax. Multiple matchers can be comma-separated (for example,
    severity=critical,instance=~prod.*
    ).
    Syntax
    Example
    Description
    labelname=value
    app=Device
    Exact match.
    labelname!=value
    app!=Device
    Negative match (not match).
    labelname=~value
    app=~Dev
    'app=~Dev,metric=~Power'
    Regex match (golanguage implementation of regex).
    The first example, matches reader alerts. The second example matches reader power alerts.
    labelname!~value
    app!~Dev
    'app!~Dev,metric!~Power'
    Regex not match (golanguage implementation of regex).
    The first example, matches anything except reader alerts. The second example matches anything except reader power alerts.
  • Common Label Names
    Alerts in
    Resonate
    include these labels that you can filter on:
    Label
    Description
    metric
    The name of the alert.
    app
    The type of entity that threw the alert. Possible values:
    • Device
    • Container Name
    alertgroup
    The category of alert. Possible values:
    • device
    • service
    description
    Brief description of the alert.
    resource
    Unique identifier that threw the alert. Possible values:
    • DeviceId
    • Container Name
    severity
    Severity of the alert. Possible values:
    • critical
    • warning

Target-Specific Options

SMTP (Email) Options
Option
Description
--smtp-from <email>
Sender email address.
Required: Yes
--smtp-to <email>
Recipient email address. You can only specify one address. To send to multiple addresses, repeat the
add-alerting-target
command using a different address and name.
Required: Yes
--smtp-smarthost <host:port>
SMTP server host and port.
Required: Yes
--smtp-auth-username <username>
SMTP authentication username.
--smtp-auth-password <password>
SMTP authentication password.
--smtp-require-tls <true|false>
Whether to require TLS.
Default:
true
--smtp-hello <hostname>
The hostname to identify to the SMTP server.
Webhook Options
Option
Description
--webhook-url <url>
The URL to which to send HTTP POST requests.
Required: Yes
--webhook-max-alerts <number>
Maximum number of alerts to be sent per webhook message.
Default:
0
(all alerts)
--webhook-authorization-type <basic|bearer|none>
Type of authorization to use for webhook requests.
none
performs no authorization.
Default:
none
--webhook-basic-auth-username <username>
Username for basic auth authentication.
Required: With basic auth type.
--webhook-basic-auth-password <password>
Password for basic auth authentication type.
Required: With basic auth type.
--webhook-bearer-token <token>
Bearer token for authorization.
Required: With bearer auth type