Query and view open PA alerts

After creating alert rules in your GDCH project, you can query and view alerts on dashboards from the user interface (UI) of the project's system monitoring instance or query alerts from the GDCH Observability HTTP API.

Query and view alerts on dashboards

You can view alerts on dashboards from the system monitoring instance of the platform-obs project.

The system monitoring instance includes organization-level metrics, logs, and alerts to perform monitoring processes such as network monitoring and server monitoring.

Before you begin

Before querying and viewing alerts on dashboards, you must obtain access to the system monitoring instance. For more information, see Get access to dashboards.

System monitoring instance endpoint

The following URL is the endpoint of the monitoring instance of the platform-obs project:

https://GDCH_URL/platform-obs/grafana

Replace GDCH_URL with the URL of your organization in GDCH.

The system monitoring instance of the platform-obs project contains default dashboards with information about alerts for data observability. For example, the Alerts - Overview dashboard contains sample information about the number of alerts for a specific data source, classified as critical, warning, information, and unknown alerts. The dashboard also contains a line graph of the alerts history, showing the number of alerts open per hour for the data source.

The Alerts - Overview dashboard shows information about the number of alerts for a specific data source and a line graph of the alerts history, showing the number of alerts open per hour for the data source.

Figure 1. The Alerts - Overview dashboard of the system monitoring instance.

Querying alerts from the user interface (UI) lets you visually retrieve alerting information from your project and get an integrated view of resources for awareness and quick resolution of problems.

Query alerts from the HTTP API

The Observability platform exposes an HTTP API endpoint for querying and reading metrics, alerts, and other time series data from your project for system monitoring.

Query alerts directly from the Observability HTTP API to set up automated tasks, adapt responses, and build integrations according to your use case. For example, insert the output into another command, export details to text file formats, or configure a Linux cron job. You can call the Observability HTTP API from the command-line interface (CLI) or a web browser and obtain the result in JSON format.

This section explains how to call the Observability HTTP API endpoint from the CLI using the API specification to query alerts.

Before you begin

You must obtain authorization to query alerts from the CLI. To get the permissions you need to access the Observability HTTP API endpoint, ask your Organization IAM Admin to grant you the corresponding viewer role in the platform-obs namespace.

For information about setting role bindings from the GDCH console, see Grant access to resources.

HTTP API endpoint

The following URL is the HTTP API endpoint for accessing alerts in the platform-obs project:

https://GDCH_URL/platform-obs/cortex/alertmanager/

Replace GDCH_URL with the URL of your organization in GDCH.

Authenticate the cURL request

  1. Download and install the gdcloud CLI.
  2. Set the gdcloud core/organization_console_url property:

    gdcloud config set core/organization_console_url https://GDCH_URL
    

    Replace GDCH_URL with the URL of an organization in GDCH.

  3. Sign in with the configured identity provider:

    gdcloud auth login
    
  4. Use your user and password to authenticate and sign in.

When the login is successful, you can use the authorization header in your cURL request through the gdcloud auth print-identity-token command. For more information, see gdcloud auth.

Call the API endpoint

Follow these steps to reach the HTTP API endpoint from the CLI and query alerts:

  1. Ensure you meet the prerequisites and the login authentication for the cURL request.
  2. Open the CLI.
  3. Use the curl tool to call the HTTP API endpoint and extend the URL using the standard https://prometheus.io/docs/prometheus/latest/querying/api/#alertmanagers to query alerts. For example:

    curl https://GDCH_URL/PROJECT_NAME/cortex/alertmanager/api/v1/alertmanagers \
    -H "Authorization: Bearer $(gdcloud auth print-identity-token \
    --audiences=https://GDCH_URL)"
    

    Replace the following:

    • GDCH_URL: the URL of an organization in GDCH
    • PROJECT_NAME: the name of your project

You obtain the output following the command. The API response is in JSON format.