<a id="examples-c3-alert-actions-triggers"></a>

# Control Center Alerts Usage Example for Confluent Platform

Follow these examples to set up triggers and actions.

<a id="config-triggers-ex"></a>

## Example triggers

This section provides trigger examples using the Control Center web UI for alerts.

<a id="alert-trigger-cluster-offline"></a>

### Create a trigger for Control Center cluster down

If you have a Control Center-dedicated cluster running, you can set up an alert to notify you if a non-Control Center
cluster goes down. Follow these steps to create an alert trigger for cluster down using the UI rather
than the [properties file configurations](configure.md#c3-cluster-offline).

<!-- first nav step click bell -->
1. Click the Alerts bell icon in the top banner. The **Alerts** page
   opens to the **History** tab by default.

1. Click the **Trigger** tab.
2. Click **+ New trigger**.
3. In the **General** field, enter a unique name for the trigger. For example, `Cluster down`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
4. In the **Components** fields:
   - For **Component type**, select **Cluster**.
   - For **Cluster id**, select the ID of the cluster where you want to apply the trigger.
     You can specify any cluster ID except for the ID of the Control Center cluster.
5. In the **Criteria** fields:
   - For **Metric**, select **Cluster down**.
   - For **Condition**, select **Yes**.
6. Click **Save**. The trigger saved message appears and
   prompts you to create or select an action now or do it later.

   Create a corresponding [action](actions.md#new-edit-action-form) or actions
   for the trigger as applicable to your environment.

   For next steps, see the cluster down action examples:
   - [Create an email action](#alert-email-action)
   - [Create a Slack webhook action](#alert-slack-webhook-action)
   - [Create a PagerDuty notification and incident
     action](#alert-pagerduty-webhook-action)

<a id="urp-cluster-trigger"></a>

### Create a cluster trigger for under-replicated partitions

Follow these steps to create an alert trigger for any under-replicated
topic partitions (URP) in a cluster.
Alert on topic partitions when the number of in-sync replicas is less than
replication factor.
The number of in sync replicas should equal the total number of replicas.
Investigate whenever the under replicated partitions value is greater than
zero (0).

This example creates a cluster trigger. The under-replicated topic partitions
metric is also available
for a [topic trigger](#urp-topic-trigger).

**To create a cluster trigger for URP:**

<!-- first nav step click bell -->
1. Click the Alerts bell icon in the top banner. The **Alerts** page
   opens to the **History** tab by default.

1. Click the **Trigger** tab.
2. Click **+ New trigger**.
3. In the **General** field, enter a unique name for the trigger. For example, `URP my_cluster`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
4. In the **Components** fields:
   - For **Component type**, select `Cluster`.
   - For **Cluster id**, select the ID of the cluster where you want to apply the trigger.

   There is a known issue when multiple clusters are selected for a
   broker or cluster trigger. As a recommended best practice, only select a single cluster
   for the trigger. For more information, see the known issues section in the release notes.
   <!-- link to known issue when available -->
5. In the **Criteria** fields:
   - For **Metric**, select `Under-replicated topic partitions`.
   - For **Condition**, select `Greater than`.
   - For **Value**, type `0` (zero).
6. Click **Save**. The trigger saved message appears and
   prompts you to create or select an action now or do it later.

   Create a corresponding [action](actions.md#new-edit-action-form) or actions
   for the trigger as applicable to your environment.

<a id="urp-topic-trigger"></a>

### Create a topic trigger for under-replicated partitions

Follow these steps to create an alert trigger for under-replicated partitions
(URP)
in a specific topic.

This example creates a topic trigger. The under-replicated topic partitions
metric
is also available
for a [cluster trigger](#urp-cluster-trigger).

**To create a topic trigger for URP:**

<!-- first nav step click bell -->
1. Click the Alerts bell icon in the top banner. The **Alerts** page
   opens to the **History** tab by default.

1. Click the **Trigger** tab.
2. Click **+ New trigger**.
3. In the **General** field, enter a unique name for the trigger. For example, `URP users topic`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
4. In the **Components** fields:
   - For **Component type**, select `Topic`.
   - For **Cluster id**, select the ID of the cluster where you want to apply the trigger.
   - For **Condition**, select `Equals` (to select one specific topic).
   - For **Topic name**, select the name of the topic to alert
     for under-replicated partitions. Enter some text of the topic name to
     filter the list if necessary.
5. In the **Criteria** fields:
   - For **Metric**, select `Under-replicated topic partitions`.
   - For **Condition**, select `Greater than`.
   - For **Value**, type `0` (zero).
6. Click **Save**. The trigger saved message appears and
   prompts you to create or select an action now or do it later.

   Create a corresponding [action](actions.md#new-edit-action-form) or actions
   for the trigger as applicable to your environment.

<a id="consumer-lag-trigger"></a>

### Create a consumer group trigger for consumer lag

Follow these steps to create an alert trigger for consumer lag
in a specific consumer group. Consumer lag measures how many messages a
consumer group is behind. This example sets up the alert
from the context of the Consumer groups page. Most of the fields are
already pre-populated. Just enter a trigger name and the lag value
you want to alert on as appropriate for your environment. This example
triggers an alert when the consumer lag is greater than 100.

#### NOTE
Consumer group alerts in Confluent Control Center are based on the total cumulative lag for **all**
partitions in **all** topics consumed in a Consumer group.

**To create a consumer lag trigger:**

1. From the navigation menu, click the tile for your desired cluster.
2. Click **Consumers**.
3. Click the link for the consumer group. The Consumer lag tab appears.
   ![Consumer lag page set up an alert](images/c3-consumer-lag-alert-button.png)
4. Click the **Set up an alert** button. The New trigger form
   appears with most fields pre-populated.
5. Enter a unique name for the trigger. For example, `Consumer group lag`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
6. In the **Criteria** fields:
   - For **Condition**, select `Greater than`.
   - For **Value**, type `100`.

   ![Consumer lag consumer group trigger example](images/c3-cgroup-trigger-clag.png)
7. Click **Save**. The trigger saved message appears and
   prompts you to create or select an action now or do it later.

   Create a corresponding [action](actions.md#new-edit-action-form) or actions
   for the trigger as applicable to your environment.

<a id="config-actions-ex"></a>

## Example actions

This section provides action examples using the web UI for alerts.

<a id="alert-email-action"></a>

### Create an email action for cluster down

Follow these steps to create an email action that can be assigned to one or
more triggers. This
example creates an action to send an email alert for cluster down once per hour.

Prerequisites:

- [Enable email alerts](configure.md#enable-disable-alerts-props)
- [Configure SMTP settings](configure.md#config-smtp-email)
- [Create a trigger for Control Center cluster down](#alert-trigger-cluster-offline)

**To create an email action:**

<!-- first nav step click bell -->
1. Click the Alerts bell icon in the top banner. The **Alerts** page
   opens to the **History** tab by default.

1. Click the **Actions** tab.
2. Click **+ New action**.
3. In the **General** tab, enter a unique name for the action. For example, `Send email to
   DevOps`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
4. (Optional) The action is enabled by default. Switch the
   **Enabled** toggle to **Disabled** if you
   are not ready to activate the action. The action remains disabled regardless
   of the [pause or resume all actions](actions.md#pause-resume-alerts-actions-ui)
   status.
5. From the **Triggers** list, select one or more triggers to assign to the
   Action.
6. In the **Actions** fields:
   - Select **Send email** for the **Action** field.
   - Enter one or more email addresses separated by a comma in the
     **Recipient email address** field.
   - Enter a subject for the email. For example, `Attention DevOps: Control
     Center Cluster Down Alert!`
   - Enter **Renotify Frequency**. For example, `1 hour` for the notification to be sent every hour.
   - Select the frequency option. For example, `Per hour`.
7. Click **Save**. The action is added to the Actions management page.

<a id="alert-slack-webhook-action"></a>

### Create a Slack notification action for cluster down

Follow these steps to create a Slack webhook action that can be assigned
to one or more triggers. This
example creates a Slack notification to post to a designated Slack channel
once per day until
the issue is acknowledged and resolved.

Prerequisites:

- Configure and test the incoming webhook
  in [Slack](https://api.slack.com/incoming-webhooks).
- Ensure the webhook Control Center configuration setting is enabled
  (it is by default). See
  [enable the webhook action](configure.md#enable-disable-webhooks).
- Create one or more [triggers](triggers.md#new-edit-trigger-form) to associate
  the action with. For
  this example, see [Create a trigger for Control Center cluster down](#alert-trigger-cluster-offline).

**To create a Slack action:**

<!-- first nav step click bell -->
1. Click the Alerts bell icon in the top banner. The **Alerts** page
   opens to the **History** tab by default.

1. Click the **Actions** tab.
2. Click **+ New action**.
3. In the **General** tab, enter a unique name for the action. For example,
   `Control Center Cluster down Slack webhook`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
4. (Optional) The action is enabled by default. Switch the
   **Enabled** toggle to **Disabled** if you
   are not ready to activate the action. The action remains disabled regardless
   of the [pause or resume all actions](actions.md#pause-resume-alerts-actions-ui)
   status.
5. From the **Triggers** list, select one or more triggers to assign to the
   action.
6. In the **Actions** fields:
   - Select **Send Slack notification** for the **Action** field.
   - Enter the Slack webhook URL in the **Webhook URL** field.
   - Enter a brief subject for the notification. For
     example: `Attention DevOps: Control Center Cluster Down Alert!`
   - Enter **Renotify Frequency**. For example, `1 hour` for the notification to be sent every hour.
   - Select the frequency option. For example, `Per day`.
   - (Optional) To override the username originally configured in Slack,
     enter the Slack handle. For example, `@otherslackusername`.
   - (Optional) To override the slack channel originally configured in Slack,
     enter the alternative channel. For example, `#DevOpsOnCall`.
7. Click **Save**. The action is added to the Actions management page.

<a id="alert-pagerduty-webhook-action"></a>

### Create a PagerDuty notification action for cluster down

Follow these steps to create a PagerDuty webhook notification action that
can be assigned to one or more triggers. This
example creates a PagerDuty notification to create a critical incident
for Control Center’s cluster down.

Prerequisites:

- Configure the PagerDuty Service integration and generate an Integration Key. Refer
  to the [PagerDuty](https://support.pagerduty.com/docs/services-and-integrations)
  documentation for complete details.
- Ensure the webhook Control Center configuration setting is enabled
  (it is by default). See [enable the webhook action](configure.md#enable-disable-webhooks).
- Create one or more [triggers](triggers.md#new-edit-trigger-form) to associate
  the action with. For
  this example, see [Create a trigger for Control Center cluster down](#alert-trigger-cluster-offline).

  **To create a PagerDuty action:**

<!-- first nav step click bell -->
1. Click the Alerts bell icon in the top banner. The **Alerts** page
   opens to the **History** tab by default.

1. Click the **Actions** tab.
2. Click **+ New action**.
3. In the **General** field, enter a unique name for the action. For example, `Control Center
   Cluster down PagerDuty incident`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
4. (Optional) The action is enabled by default. Switch the **Enabled** toggle
   to **Disabled** if you
   are not ready to activate the action. The action remains disabled regardless
   of the [pause or resume all actions](actions.md#pause-resume-alerts-actions-ui)
   status.
5. From the **Triggers** list, select one or more triggers to assign to the
   action.
6. In the **Actions** fields:
   - Select `Send PagerDuty notification` for the **Action** field.
   - Enter a brief subject for the notification. For
     example: `Attention DevOps: Control Center Cluster Down Alert!`
   - Enter **Renotify Frequency**. For example, `1 hour` for the notification to be sent every hour.
   - Select the frequency option. For example, `Per day`.
   - Enter the **Integration key** generated from following the PagerDuty
     instructions.
   - Select the **Payload severity** for the incident that the notification
     will create
     automatically. Available options are: Critical, Error, Warning, or Info.
     For this example,
     select `Critical`.
7. Click **Save**. The action is added to the Actions management page.

### Create a generic webhook notification action for cluster down

Follow these steps to create a generic webhook notification action that
can be assigned to one or more triggers. This
example creates a generic webhook notification to create a critical incident
for Control Center’s cluster down.

Prerequisites:

- Configure the generic webhook integration. For more information, see
  [Prometheus](https://prometheus.io/docs/alerting/latest/configuration/#webhook_config)
  documentation.
- Ensure the webhook Control Center configuration setting is enabled
  (it is by default). For more information, see [enable the webhook action](configure.md#enable-disable-webhooks).
- Create one or more [triggers](triggers.md#new-edit-trigger-form) to associate
  the action with. For
  this example, see [Create a trigger for Control Center cluster down](#alert-trigger-cluster-offline).

  **To create a generic webhook action:**

<!-- first nav step click bell -->
1. Click the Alerts bell icon in the top banner. The **Alerts** page
   opens to the **History** tab by default.

1. Click the **Actions** tab.
2. Click **+ New action**.
3. In the **General** field, enter a unique name for the action. For example, `Control Center
   Cluster down generic webhook incident`.

   Uniqueness is not enforced.
   Use unique and descriptive names to avoid confusion.
4. (Optional) The action is enabled by default. Switch the **Enabled** toggle
   to **Disabled** if you
   are not ready to activate the action. The action remains disabled regardless
   of the [pause or resume all actions](actions.md#pause-resume-alerts-actions-ui)
   status.
5. From the **Triggers** list, select one or more triggers to assign to the
   action.
6. In the **Actions** fields:
   - Select `Send webhook notification` for the **Action** field.
   - Enter **Renotify Frequency**. For example, `1 hour` for the notification to be sent every hour.
   - Select the frequency option. For example, `1 hour`.
   - Enter the **Webhook URL**.
7. Click **Save**. The action is added to the Actions management page.
