This is documentation for the next version of Grafana documentation. For the latest stable release, go to the latest version.
Create an alert based on Grafana Advisor results
Note
Grafana Advisor performs regular checks on data sources, plugins, and your Grafana instance, and will expand its capabilities in future releases to cover more aspects of your Grafana environment. You can suggest new checks and provide feedback through this form.
This guide explains how to create a Grafana alert that monitors Advisor check results and fires when Advisor detects failures.
To create the alert, complete the following steps:
- Create a service account and token
- Set up the Grafana Infinity data source
- Create the alert rule
- Save the alert rule
Create a service account and token
Advisor results are available through the Advisor HTTP API. To query the API, create a service account and a token:
- In your Grafana instance, go to Administration > Users and access > Service accounts.
- Click Add service account.
- Enter a name, for example
advisor-alert-service-account. - Set the role to Admin to ensure the service account has the required permissions.
- Click Create.
- In the service account details, click Add service account token.
- Enter a token name and set an expiration date.
- Click Generate token.
Caution
Copy the token value immediately and store it securely. You can’t view it again.
Set up the Grafana Infinity data source
The Grafana Infinity data source queries the Advisor HTTP API using the service account token.
Note
Use Infinity plugin v3.3.0 or later, which supports the JQ parser used in this guide.
- Go to Connections > Add new connection.
- Search for
Infinity. - If the plugin isn’t installed, click Install and wait for the installation to finish.
- On the plugin page, click Add new data source.
- Configure the data source:
- Name: Enter a descriptive name, for example
Advisor API. - Authentication: In Auth type, select Bearer Token. In the Auth details section, paste the service account token you created. In the Allowed hosts section, enter your Grafana URL, for example
https://your-grafana-host.com, and click Add.
- Name: Enter a descriptive name, for example
- Click Save & test to verify the connection.
Create the alert rule
After you set up the data source, create an alert rule based on Advisor results:
- Go to Alerting > Alert rules.
- Click New alert rule.
- Enter a rule name, for example
Advisor failures alert.
Configure the query
Configure the query to retrieve the Advisor checks:
- In Data source, select the Infinity data source you set up.
- Configure the query settings:
- Type: JSON
- Parser: JQ
- Source: URL
- Format: Table
- Method: GET
- URL:
https://<GRAFANA_HOST>/apis/advisor.grafana.app/v0alpha1/namespaces/<NAMESPACE>/checks
Replace the following placeholders in the URL:
<GRAFANA_HOST>: The host of your Grafana instance.<NAMESPACE>: The namespace of your Grafana instance. Check how to get the namespace of your instance in the namespace API reference.
For more information about this endpoint, refer to the Advisor HTTP API.
Configure parsing options
In Rows/Root, paste the following JQ expression:
.items | map({
type: .metadata.labels["advisor.grafana.app/type"],
creationTimestamp: .metadata.creationTimestamp,
failuresCount: (.status.report.failures | length)
}) | group_by(.type) | map(sort_by(.creationTimestamp) | last)This expression returns the most recent result for each check type. It transforms each check into an object with the check type, timestamp, and failure count, and keeps the latest check of each type. The result shows the current state of each check type, such as data sources, plugins, or configuration, with its failure count. You can use it to alert when any check type has more than 0 failures.
In Columns, add the following columns:
- Selector:
creationTimestamp, Format: Time - Selector:
failuresCount, Format: Number - Selector:
type, Format: String
Filter by check type
Optionally, you can alert only on specific check types:
- Go to the Computed columns, Filter, Group by section.
- Add a Filter, for example
type == "license". Replacelicensewith the check type you want to alert on.
Set the alert condition
Set the condition that fires the alert:
- In Alert condition, select WHEN Last OF QUERY Is above 0. The alert fires when any check type has failures.
- Click Preview alert rule condition to view the result of the query.
Complete the alert configuration
Select your preferred evaluation behavior, for example every 24 hours, and configure the notification settings.
Save the alert rule
Click Save and verify that the alert fires as expected.
Your alert now monitors Advisor results and notifies you when Advisor detects failures.


