<br />

<br />

This document provides troubleshooting information for using log-based alerting
policies. The content on this page doesn't apply to alerting policies that
monitor metric data---including log-based metrics---or SQL query results.

## No matching logs are available

**This entry applies only to
log-based alerting policies. It doesn't
apply to alerting policies that monitor metric data---including
log-based metrics---or SQL query results**.

When you test your filter for a log-based alerting policy, no logs are returned.
Check the following common errors:

- You are trying to filter on excluded logs. Log-based alerting policies operate
  only on included logs.

- You are trying to filter by log buckets, or for other Google Cloud
  resources such as Cloud Billing accounts or organizations.
  Log-based alerting policies operate at Google Cloud project level.

- Your query is too restrictive.

  Check that your field names and regular expressions
  are correct. You can
  use the **Query** pane in Logs Explorer or the **Preview logs**
  button in the alert-configuration interface to help validate the query. For
  information about creating queries, see
  [Logging query language](https://docs.cloud.google.com/logging/docs/view/logging-query-language.md.txt).

  <br />

## Alerting policy isn't working

You've created a log-based alerting policy, but it isn't working as you
expected. For example:

### Cloud Monitoring isn't sending notifications for the alerting policy

**This entry applies only to
log-based alerting policies. It doesn't
apply to alerting policies that monitor metric data---including
log-based metrics---or SQL query results**.

To resolve this failure, do the following:

- View the most recent notification from your alerting policy to determine if
  the policy has reached the limit of 20 notifications per day.

- View your alerting policy and make sure that it isn't extracting the
  `timestamp` label. Extraction of this label prevents the
  alerting policy from creating alerts and sending notifications.

- View and, if necessary, reduce the minimum time between notifications.

### Cloud Monitoring isn't creating alerts

**This entry applies only to
log-based alerting policies. It doesn't
apply to alerting policies that monitor metric data---including
log-based metrics---or SQL query results**.

To resolve this failure, do the following:

- View your alerting policy and make sure that it isn't extracting the
  `timestamp` label. Extraction of this label prevents the
  alerting policy from creating alerts and sending notifications.

- A log-based alerting policy can create a maximum of
  2 new alerts per minute. If your alerting policy
  extracts labels, then
  this limit might prevent creating some alerts.

- Go to the **Alerts** page in Cloud Monitoring and filter the
  table by policy name. The results show the current and past alerts:

  - If there are no alerts, then verify that the query used is
    finding matching logs.

    Check that your field names and regular expressions
    are correct. You can
    use the **Query** pane in Logs Explorer or the **Preview logs**
    button in the alert-configuration interface to help validate the query. For
    information about creating queries, see
    [Logging query language](https://docs.cloud.google.com/logging/docs/view/logging-query-language.md.txt).

    <br />

  - If there are past alerts but no recent ones for the current day,
    then you might have reached the limit of
    20 alerts per day.
    View the most recent notification from your alerting policy to determine
    whether the limit has been reached. Note that this daily limit resets at
    a random time, rather than at a fixed time like midnight.

### Cloud Monitoring creates too many alerts

**This entry applies only to
log-based alerting policies. It doesn't
apply to alerting policies that monitor metric data---including
log-based metrics---or SQL query results**.

If you are receiving more alerts than you expect, then refine the
query in the alerting policy to make it more restrictive.

Check that your field names and regular expressions
are correct. You can
use the **Query** pane in Logs Explorer or the **Preview logs**
button in the alert-configuration interface to help validate the query. For
information about creating queries, see
[Logging query language](https://docs.cloud.google.com/logging/docs/view/logging-query-language.md.txt).

<br />

## Alerts aren't closing

**This entry applies only to
log-based alerting policies. It doesn't
apply to alerting policies that monitor metric data---including
log-based metrics---or SQL query results**.

If you don't close an alert, then Cloud Logging closes the
alert after the autoclose duration for the alerting policy has passed.
The default autoclose duration is 7 days, but you can set
it to any value between 30 minutes and
7 days. You can also manually close alerts at
any time, as described in [Closing alerts](https://docs.cloud.google.com/logging/docs/alerting/log-based-incidents.md.txt#closing).