Query and view open AO alerts

After creating alert rules in your Google Distributed Cloud (GDC) air-gapped 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 GDC Observability HTTP API.

Query and view alerts on dashboards

You can view alerts on dashboards from the system monitoring instance of your project.

The system monitoring instance includes project-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 your project:

https://GDC_URL/PROJECT_NAMESPACE/grafana

Replace the following:

  • GDC_URL: the URL of your organization in GDC
  • PROJECT_NAMESPACE: the namespace of your project

The user interface (UI) of the system monitoring instance contains default dashboards such as the Alerts - Overview dashboard with information about alerts for data observability. Querying alerts from the 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 Project IAM Admin to grant you the corresponding viewer role in your project namespace.

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

HTTP API endpoint

The following URL is the HTTP endpoint for accessing alerts:

https://GDC_URL/PROJECT_NAME/cortex/alertmanager/

Replace the following:

  • GDC_URL: the URL of your organization in Distributed Cloud
  • PROJECT_NAME: the name of your project

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://GDC_URL
    

    Replace GDC_URL with the URL of an organization in GDC.

  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://GDC_URL/PROJECT_NAME/cortex/alertmanager/api/v1/alertmanagers \
    -H "Authorization: Bearer $(gdcloud auth print-identity-token \
    --audiences=https://GDC_URL)"
    

    Replace the following:

    • GDC_URL: the URL of an organization in GDC
    • PROJECT_NAME: the name of your project

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