# List GCP metrics

List the Google Cloud metrics a GCP source can collect. The list is empty until the source's GCP project is connected and has finished its first sync.

[endpoint]
method = "GET"
base_url = "https://telemetry.betterstack.com"
path = "/api/v4/sources/{source_id}/gcp-metrics"

[[path_param]]
name = "source_id"
required = true
type = "string"
description = "GCP source whose metrics are listed. Get its ID via [List sources](/docs/logs/api/list-all-existing-sources/)."

[[query_param]]
name = "page"
type = "integer"
description = "Page to return, starting at 1."

[[query_param]]
name = "per_page"
default = "50"
type = "integer"
description = "Results per page. Maximum 250."

[[query_param]]
name = "team_id"
type = "string"
description = "Team to use, such as `t123`. Get the ID via [List teams](/docs/uptime/api/teams/list/). Required when you can access more than one team."

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"
[/endpoint]

[info]
#### Results are paginated
Use `pagination.next` and `pagination.prev` to move through pages or jump to a specific one using `page` and `per_page`. See [Pagination](/docs/getting-started/integrations/api/#pagination).
[/info]

[responses]
[[response]]
status = 200
description = "Returns the list of GCP metrics."
body = '''
{
  "data": [
    {
      "id": "123456789",
      "type": "gcp_metric",
      "attributes": {
        "metric_type": "compute.googleapis.com/instance/cpu/utilization",
        "display_name": "CPU utilization",
        "description": "Fractional utilization of the allocated CPU on this instance.",
        "kind": "GAUGE",
        "service_name": "compute.googleapis.com",
        "collected": true
      }
    }
  ],
  "pagination": {
    "first": "https://telemetry.betterstack.com/api/v4/sources/123456/gcp-metrics?page=1",
    "last": "https://telemetry.betterstack.com/api/v4/sources/123456/gcp-metrics?page=1",
    "prev": null,
    "next": null,
    "total_count": 1
  }
}
'''

[[response]]
status = 401
description = "The API token is missing or invalid."
body = '''
{
  "errors": "Invalid Team API token. How to find your Team API token: https://betterstack.com/docs/logs/api/getting-started/#obtaining-a-logtail-api-token"
}
'''

[[response]]
status = 403
description = "Your role doesn't allow viewing this, or the token can't be used for this API."

[[response]]
status = 404
description = "The source doesn't exist, isn't a `gcp` source, or the token can't access it."
body = '''
{
  "errors": "Resource with the provided ID was not found"
}
'''
[/responses]

[params]
title = "Response attributes"

[[param]]
name = "id"
type = "string"
description = "The ID of the GCP metric."

[[param]]
name = "type"
type = "string"
description = "Always `gcp_metric`."

[[param]]
name = "metric_type"
type = "string"
description = "Google Cloud metric type, such as `compute.googleapis.com/instance/cpu/utilization`."

[[param]]
name = "display_name"
type = "string"
description = "Name Google Cloud shows for the metric."

[[param]]
name = "description"
type = "string"
description = "What the metric measures, as Google Cloud describes it."

[[param]]
name = "kind"
type = "string"
description = "Google Cloud metric kind, `GAUGE`, `DELTA` or `CUMULATIVE`."

[[param]]
name = "service_name"
type = "string"
description = "Google Cloud service the metric belongs to, such as `compute.googleapis.com`."

[[param]]
name = "collected"
type = "boolean"
description = "Whether the source's `gcp_metrics_filters` collect this metric. Change them via [Update a source](/docs/logs/api/update-source/)."

[[param]]
name = "pagination.first"
type = "string"
description = "The URL of the first page of results."

[[param]]
name = "pagination.last"
type = "string"
description = "The URL of the last page of results."

[[param]]
name = "pagination.prev"
type = "string or null"
description = "The URL of the previous page, or `null` on the first page."

[[param]]
name = "pagination.next"
type = "string or null"
description = "The URL of the next page, or `null` on the last page."

[[param]]
name = "pagination.total_count"
type = "integer"
description = "How many results the whole list holds, across every page."
[/params]

#### Example cURL

```shell
[label List GCP metrics]
curl --request GET \
  --url https://telemetry.betterstack.com/api/v4/sources/123456/gcp-metrics \
  --header "Authorization: Bearer $TOKEN"
```
