GitLab alerting
The GitLab data source supports Grafana Alerting, which lets you create alert rules based on GitLab query results. You can monitor GitLab activity and receive notifications when conditions are met.
For general information about Grafana Alerting, refer to Alerting.
Before you begin
- Configure the GitLab data source.
- Familiarize yourself with Grafana alert rules.
Create an alert rule
Any GitLab query can be used as the data source for an alert rule. To create an alert:
- Navigate to Alerting > Alert rules.
- Click New alert rule.
- Select your GitLab data source.
- Configure a query using any supported resource type.
- Add reduce and threshold expressions to define your alert condition.
- Configure labels, notifications, and evaluation intervals.
- Click Save rule.
Example use cases
The following examples show common alerting scenarios with the GitLab data source. Each requires adding transformations or expressions to produce a numeric value for the alert condition.
Alert on failed pipelines
Monitor a project for pipeline failures:
- Create a query with resource type Pipelines.
- Set the Project Id and filter Status to
failed. - Add a Reduce expression that counts the number of results.
- Add a Threshold expression to alert when the count exceeds
0.
Alert on open merge requests
Monitor when too many merge requests are open:
- Create a query with resource type Merge Requests.
- Set the Project Id and filter State to
opened. - Add a Reduce expression that counts the number of results.
- Add a Threshold expression to alert when the count exceeds your desired limit.
Alert on deployment failures
Monitor for failed deployments in an environment:
- Create a query with resource type Deployments.
- Set the Project Id and filter Status Query to
failed. - Add a Reduce expression that counts the number of results.
- Add a Threshold expression to alert when the count exceeds
0.
Alert when no deployments occur
Detect when a project has not deployed within the evaluation window, which may indicate a stalled release process:
- Create a query with resource type Deployments.
- Set the Project Id and filter Status Query to
success. - Add a Reduce expression that counts the number of results.
- Add a Threshold expression to alert when the count is below
1. - Set the evaluation interval to match your expected deployment cadence (for example, every 24 hours).
Alert on stale merge requests
Detect merge requests that have been open longer than a specific number of days:
- Create a query with resource type Merge Requests.
- Set the Project Id and filter State to
opened. - Add a Math expression that calculates the age in days:
($A.created_at - now()) / -86400000. - Add a Reduce expression with function Max to find the oldest open merge request.
- Add a Threshold expression to alert when the value exceeds your limit (for example,
14for two weeks).



