# Topline Alerts with Logs

By combining log filters with [Topline Alerts](https://docs.statsig.com/product-analytics/topline-alerts), you can detect failures immediately, without writing custom scripts or dashboards.

### When to use log-based alerts

- **Monitoring success rates**: Catch regressions before they impact SLOs.
- **Detecting error spikes**: Trigger when 5xx or other errors rise above baseline.
- **Isolate by segment**: Identify failures concentrated in a region, client, or device type

## Create a log-based Topline Alert (Statsig Cloud)

This example creates a monitor for the success rate of a GET request.

{% steps %}
{% step title="Navigate to Topline Alerts" %}

- Go to **Analytics → Topline Alerts** in the product menu.
- Click **+Create**.
- Enter a name for your alert.

{% figure %}
![Alert setup step 1](https://docs.statsig.com/images/infra-analytics/loglinealert-1.png)
{% /figure %}
{% /step %}

{% step title="Define Alert Criteria" %}

- Select `statsig::log_line` as your event.
- Apply filters to define what constitutes success and failure.

If you're unsure which fields to filter on, open the [Logs Explorer](https://docs.statsig.com/infra-analytics/logs-explorer) and inspect the log body.

{% figure %}
![Alert setup step 2](https://docs.statsig.com/images/infra-analytics/loglinealert-2.png)
{% /figure %}
{% /step %}

{% step title="Set Up Evaluation Formula" %}

- Define the formula for calculating your success rate.
- (Optional) Add a group-by dimension.

{% figure %}
![Alert setup step 3](https://docs.statsig.com/images/infra-analytics/loglinealert-3.png)
{% /figure %}
{% /step %}

{% step title="Configure Alert Thresholds" %}

- Set thresholds and the evaluation window.

In this example, Statsig triggers a warning when success rate drops below 99.5% and an alert when success rate drops below 99.0%.

{% figure %}
![Alert setup step 4](https://docs.statsig.com/images/infra-analytics/loglinealert-4.png)
{% /figure %}
{% /step %}

{% step title="Configure Notifications" %}

- Add the alert title and description for context.
- Include diagnostic hints (e.g. "Check version X" or "Android requests timing out").
- Add subscribers.
- Set priority.

{% figure %}
![Alert setup step 5](https://docs.statsig.com/images/infra-analytics/loglinealert-5.png)
{% /figure %}
{% /step %}

{% step title="Save the Alert" %}

- Click **Save**.
- After you save your alert, visit the **Diagnostics** tab to view a history of alert triggers.

{% figure %}
![Alert setup step 6](https://docs.statsig.com/images/infra-analytics/loglinealert-6.png)
{% /figure %}
{% /step %}
{% /steps %}

---

## Best practices

- Set up [Slack notifications](https://docs.statsig.com/integrations/slack) for team visibility
- Keep formulas simple (ratios & percentages are easiest to scan)
- Add group-by dimensions (like country or app version) to pinpoint where issues occur
- Write clear notification text that explains what the alert means
