# Monitor connectors


Integration Connectors is integrated with [Cloud Monitoring](https://docs.cloud.google.com/monitoring).
This means that all your Integration Connectors metrics and usage data is automatically available
to Cloud Monitoring. To know about the type of metrics sent by the Integration Connectors service,
see [Integration Connectors metrics](https://docs.cloud.google.com/monitoring/api/metrics_gcp_c.md.txt#gcp-connectors).

You can visualize your Integration Connectors metrics and data using the following Cloud Monitoring tools:

- [Custom dashboards](https://docs.cloud.google.com/integration-connectors/docs/cloud-monitoring.md.txt#custom-dashboard)
- [Metrics Explorer](https://docs.cloud.google.com/integration-connectors/docs/cloud-monitoring.md.txt#metrics-explorer)

## Before you begin

Before you use Cloud Monitoring, enable the Cloud Monitoring API.


[Enable the Cloud Monitoring API](https://console.cloud.google.com/apis/enableflow?apiid=monitoring.googleapis.com)

> [!NOTE]
> **Note:** You may incur additional charges for using Cloud Monitoring API directly. For more information, see [Cloud Monitoring pricing](https://docs.cloud.google.com/monitoring#section-7).

## Access metrics using custom dashboards

To create custom monitoring dashboards for your Integration Connectors resources in
your Google Cloud project, do the following:

1. In the Google Cloud console, go to the **Cloud Monitoring \> Dashboard Overview** page:

   [Go to Dashboard Overview page](https://console.cloud.google.com/monitoring/dashboards)
2. Click **Create dashboard**.
3. Optionally, modify the name of the dashboard.
4. Click or drag and drop a chart on the canvas.
5. In the chart configuration properties, perform the following:
   1. Expand the **Resource \& Metric** menu and select **Connectors** as the **Active resource**.
   2. Choose the desired [metrics](https://docs.cloud.google.com/monitoring/api/metrics_gcp_c.md.txt#gcp-connectors) that you want to visualize.
   3. Click **Apply**.
6. Add additional charts to your dashboard as desired.

For more information about custom dashboards, see [Create and manage custom dashboards](https://docs.cloud.google.com/monitoring/charts/dashboards.md.txt).

## Access metrics using Metrics Explorer


The Cloud Monitoring [Metric Explorer](https://docs.cloud.google.com/monitoring/charts/metrics-explorer.md.txt) helps you build temporary metric charts to visualize the available resource metrics for your Google Cloud project. Once you have created a metric chart, if desired, you can also save it to a custom monitoring dashboard.


To create a chart using the Integration Connectors resource metrics, do the following:

1. In the Google Cloud console, go to the **Cloud Monitoring \> Metrics explorer** page:

   [Go to Metrics explorer page](https://console.cloud.google.com/monitoring/metrics-explorer)
2. In the **Select a metric** pane, expand the **Metric** menu and select **Connectors** as the **Active resource**.
3. Choose the desired [metrics](https://docs.cloud.google.com/monitoring/api/metrics_gcp_c.md.txt#gcp-connectors) that you want to visualize.
4. Click **Apply**.

You can also select filters, group by metric labels, perform aggregations, and select chart viewing options using the Metric Explorer. For more information, see [Create charts with Metrics Explorer](https://docs.cloud.google.com/monitoring/charts/metrics-explorer.md.txt).

## Monitor using PromQL

You can use [PromQL](https://docs.cloud.google.com/monitoring/promql.md.txt) to create custom monitoring dashboards based
on various metrics. PromQL queries let you aggregate your connection data based on metrics such as
connector provider and connector version. You can write PromQL queries by using the
[code editor](https://docs.cloud.google.com/monitoring/promql/promql-in-monitoring.md.txt).

The following examples show how to use the PromQL queries to gather connection data.

### Example - Monitor request count

The following PromQL query shows how to get and aggregate request count data for active connections:

```sql
sum by (location, connection, provider) (
  sum_over_time({"connectors.googleapis.com/connection/request_count", monitored_resource="connectors.googleapis.com/Connection"}[1m])
) and on (location, connection, provider)
  avg_over_time({"connectors.googleapis.com/connection/state", monitored_resource="connectors.googleapis.com/Connection"}[1m]) > 0
```

### Example - Monitor active nodes

The following PromQL query shows how to get and aggregate active node count data for all your connections:

```sql
sum by (location, connection, provider) (
  sum_over_time({"connectors.googleapis.com/connection/nodes", monitored_resource="connectors.googleapis.com/Connection"}[1m])
) and on (location, connection, provider)
  avg_over_time({"connectors.googleapis.com/connection/state", monitored_resource="connectors.googleapis.com/Connection"}[1m]) > 0
```

### Example - Monitor connection status over a time period

The following PromQL query shows how to get the status trend over a time period for all your connections:

```sql
count by (status, connection) (
  {"connectors.googleapis.com/connection/connection_status",
    monitored_resource="connectors.googleapis.com/Connection"
  } == 1
)
```

If you want to know the status of connections at the current point in time, use the [Metrics
Explorer](https://docs.cloud.google.com/integration-connectors/docs/cloud-monitoring#metrics-explorer) in the Google Cloud console instead of a PromQL query.

> [!NOTE]
> **Note:** You can also [configure alerts](https://docs.cloud.google.com/integration-connectors/docs/alerts.md.txt) to know if a connection is in a particular state. For example, you can configure an alert that is triggered when a connection goes to an Error state.

## What's next

Understand how to view and manage various Google Cloud services and third party applications (applicable to your
Google Cloud project) that are integrated with Cloud Monitoring. For more information, see
[Manage integrations in Cloud Monitoring](https://docs.cloud.google.com/monitoring/agent/integrations.md.txt).