---
title: "The Collector HTTP API v2 | Grafana Cloud documentation"
description: "Reference documentation for version 2 of the Grafana Fleet Management Collector HTTP API, which adds paginated and filtered collector listing, collector counts, configuration previews, and bulk operations by filter."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# The Collector HTTP API v2

Version 2 of the Grafana Fleet Management Collector API manages collectors and their remote attributes. It offers CRUD operations on individual collectors, paginated listing with filtering and sorting, collector counts, configuration previews, and bulk updates and deletes by ID or by filter.

For a full definition of the Collector API v2, refer to the [`.proto` file](https://github.com/grafana/fleet-management-api/blob/main/api/collector/v2/collector.proto).

Before you begin, ensure you have the following:

- A Grafana Cloud stack with Fleet Management enabled.
- Your stack’s Fleet Management instance ID and an access policy token with Fleet Management permissions, used as the basic authentication username and password.

## Differences from version 1

Use the Collector API v2 to manage collectors and preview their configuration. Collectors continue to use the [Collector API v1](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api/) to register and fetch their configuration.

Version 2 changes the following behavior compared to version 1:

- **Configuration preview:** The new `PreviewConfig` endpoint returns the configuration a collector would receive, without registering the collector, recording a heartbeat, or reactivating it.
- **Pagination:** `ListCollectors` returns results in pages of up to 500 collectors. Use `next_page_token` from the response to fetch the next page. The response type changes from `Collectors` to `ListCollectorsResponse`.
- **Filtering and sorting:** `ListCollectors` takes a `filter` object instead of a top-level `matchers` list. The filter combines matchers, health statuses, an ID substring, a collector type, and activity states. You can sort by ID or last modified time, in ascending or descending order.
- **Collector state:** `ListCollectors` returns each collector’s health status, last heartbeat, remote configuration status, and capabilities when you set `include_state`.
- **Counting:** The new `CountCollectors` endpoint returns the number of collectors that match a filter.
- **Bulk operations by filter:** The new `BulkUpdateCollectorsByFilter` and `BulkDeleteCollectorsByFilter` endpoints act on every collector that matches a filter, with optional exclusions and an optional expected count as a safety check.
- **Create and update responses:** `CreateCollector` and `UpdateCollector` return the stored collector, including server-assigned timestamps, instead of an empty collector.
- **Empty attribute keys:** `CreateCollector` and `UpdateCollector` reject remote attributes with an empty key with a `400` `invalid_argument` error.
- **Removed fields:** The deprecated `attributes` and `attribute_overrides` fields are gone. Use `local_attributes` and `remote_attributes`.
- **Collector-only endpoints:** The `.proto` file defines `GetConfig`, `RegisterCollector`, and `UnregisterCollector`, but version 2 doesn’t implement them. Requests to them fail with a `501` `unimplemented` error.

## Find the base URL

You can find the base URL for the Collector API in the Grafana Cloud Fleet Management interface.

1. In your Grafana Cloud stack, click **Connections** &gt; **Fleet Management** in the left-side menu.
2. On the Fleet Management interface, switch to the **API** tab.
3. Find the URL in the **Base URL** section. It looks like one of the following URLs, depending on the region where your Grafana Cloud stack is hosted. Replace `collector.v1` with `collector.v2` to call version 2 of the API.
   
   Flat format, where `<CLUSTER_NAME>` is the production cluster of your stack:
   
   ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
   https://fleet-management-<CLUSTER_NAME>.grafana.net/collector.v2.CollectorService/
   ```
   
   Nested format, where `<CSP>` is the cloud provider, `<CSP_REGION>` is the cloud provider’s region identifier, and `<COUNTER>` distinguishes multiple Grafana Cloud regions hosted in the same cloud provider region:
   
   ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
   https://fleet-management-<CLUSTER_NAME>.<CSP>-<CSP_REGION>-<COUNTER>.grafana.net/collector.v2.CollectorService/
   ```
   
   > Caution
   > 
   > Always copy the exact URL from your Fleet Management interface instead of constructing it by hand. For details on the URL differences, refer to [Determine Grafana Cloud URLs based on region](https://grafana.com/docs/grafana-cloud/security-and-account-management/region-url-formats/).

### Secure connection

If you need to secure your API traffic, you can configure a private endpoint in place of the base URL. You can find the service name for endpoint configuration and the private DNS name on the same **API** tab where the base URL is found. For more information, refer to the instructions for your cloud provider:

- [AWS PrivateLink](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/set-up/connectivity-options/aws-privatelink/)
- [Azure Private Link](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/set-up/connectivity-options/azure-private-link/)
- [GCP Private Service Connect](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/set-up/connectivity-options/gcp-private-service-connect/)

## Rate limits and timeouts

You can make a request to the [Fleet Management Tenant API](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/tenant-api/) to find out the requests-per-second limits applied to your stack.

All Collector API v2 requests count toward the `requests_per_second:api` limit reported by the Tenant API, which is 3 requests per second by default. Rate-limited requests fail with a `429` status code.

`ListCollectors`, `CountCollectors`, `BulkUpdateCollectorsByFilter`, and `BulkDeleteCollectorsByFilter` requests time out after 30 seconds and fail with a `504` `deadline_exceeded` error. A by-filter request that times out doesn’t update or delete any collectors. If a filtered request times out, narrow the filter. For `ListCollectors`, you can also try a smaller `page_size`.

## CollectorService

`CollectorService` is the service that manages collectors and their remote attributes.

Expand table

| Method Name                  | Request Type                        | Response Type                        | Description                                                               |
|------------------------------|-------------------------------------|--------------------------------------|---------------------------------------------------------------------------|
| GetCollector                 | GetCollectorRequest                 | Collector                            | Returns information about the collector                                   |
| ListCollectors               | ListCollectorsRequest               | ListCollectorsResponse               | Returns a page of collectors with optional filtering and sort order       |
| CountCollectors              | CountCollectorsRequest              | CountCollectorsResponse              | Returns the number of collectors that match a filter                      |
| PreviewConfig                | PreviewConfigRequest                | PreviewConfigResponse                | Returns the configuration a collector would receive, without side effects |
| CreateCollector              | CreateCollectorRequest              | Collector                            | Creates a new collector and returns it                                    |
| UpdateCollector              | UpdateCollectorRequest              | Collector                            | Updates an existing collector and returns it                              |
| BulkUpdateCollectors         | BulkUpdateCollectorsRequest         | BulkUpdateCollectorsResponse         | Updates the remote attributes of collectors listed by ID                  |
| BulkUpdateCollectorsByFilter | BulkUpdateCollectorsByFilterRequest | BulkUpdateCollectorsByFilterResponse | Updates the remote attributes of every collector that matches a filter    |
| DeleteCollector              | DeleteCollectorRequest              | DeleteCollectorResponse              | Deletes an existing collector                                             |
| BulkDeleteCollectors         | BulkDeleteCollectorsRequest         | BulkDeleteCollectorsResponse         | Deletes collectors listed by ID                                           |
| BulkDeleteCollectorsByFilter | BulkDeleteCollectorsByFilterRequest | BulkDeleteCollectorsByFilterResponse | Deletes every collector that matches a filter                             |
| ListCollectorAttributes      | ListCollectorAttributesRequest      | ListCollectorAttributesResponse      | Returns all attributes that are used for all collectors                   |

## Endpoints

This section describes the request and response messages for each endpoint, in alphabetical order.

> Note
> 
> Protobuf field names are defined in `snake_case`. Responses use `camelCase` field names and can omit fields with default values, such as `0`, `false`, or an empty string. Both `snake_case` and `camelCase` field names are accepted in requests.

### BulkDeleteCollectorsByFilterRequest

`BulkDeleteCollectorsByFilterRequest` is a request to delete every collector that matches a filter. To preview how many collectors a filter matches, make a `CountCollectors` request with the same filter.

Fleet Management selects the matching collectors before it deletes them. Collectors deleted by another request in the meantime are skipped, and collectors changed in the meantime are still deleted.

Expand table

| Field           | Type                 | Label    | Description                                                                                                                                                                                                    |
|-----------------|----------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| filter          | ListCollectorsFilter | required | Collectors that match this [filter](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#listcollectorsfilter) are deleted; at least one filter field must be set |
| exclude\_ids    | list(string)         | optional | IDs of matching collectors to leave untouched; values must be unique                                                                                                                                           |
| expected\_count | integer              | optional | Number of collectors the request must act on, counted after `exclude_ids` are removed; must be `0` or greater                                                                                                  |

Fleet Management compares `exclude_ids` to collector IDs case-insensitively. IDs in `exclude_ids` that don’t match the filter are ignored and don’t change the count.

If `expected_count` is set and the number of matching collectors left after the exclusions differs from it, the request fails with a `400` `failed_precondition` error and no collectors are deleted.

### BulkDeleteCollectorsByFilterResponse

`BulkDeleteCollectorsByFilterResponse` is the response to a `BulkDeleteCollectorsByFilterRequest`.

Expand table

| Field          | Type    | Label | Description                  |
|----------------|---------|-------|------------------------------|
| deleted\_count | integer |       | Number of collectors deleted |

The `deleted_count` can be lower than `expected_count` if another request deletes some of the matching collectors in the meantime.

### BulkDeleteCollectorsRequest

`BulkDeleteCollectorsRequest` is a request to delete multiple collectors. If any collectors don’t exist, the request fails with a `404` `not_found` error and no collectors are deleted.

Expand table

| Field | Type         | Label    | Description                                               |
|-------|--------------|----------|-----------------------------------------------------------|
| ids   | list(string) | required | IDs of collectors to delete; must contain at least one ID |

### BulkDeleteCollectorsResponse

`BulkDeleteCollectorsResponse` is the response to a `BulkDeleteCollectorsRequest`. This message is empty and the results of the delete are defined by the HTTP status code of the response.

### BulkUpdateCollectorsByFilterRequest

`BulkUpdateCollectorsByFilterRequest` is a request to apply remote attribute operations to every collector that matches a filter. It accepts the same [`Operation`](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#operation) list as `BulkUpdateCollectorsRequest`. To preview how many collectors a filter matches, make a `CountCollectors` request with the same filter.

Fleet Management selects the matching collectors before it updates them. Collectors deleted by another request in the meantime are skipped, and collectors changed in the meantime are still updated.

Expand table

| Field           | Type                 | Label    | Description                                                                                                                                                                                                    |
|-----------------|----------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| filter          | ListCollectorsFilter | required | Collectors that match this [filter](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#listcollectorsfilter) are updated; at least one filter field must be set |
| ops             | list(Operation)      | required | Operations applied to collectors in the order they’re provided; must not be empty                                                                                                                              |
| exclude\_ids    | list(string)         | optional | IDs of matching collectors to leave untouched; values must be unique                                                                                                                                           |
| expected\_count | integer              | optional | Number of collectors the request must act on, counted after `exclude_ids` are removed; must be `0` or greater                                                                                                  |

Fleet Management compares `exclude_ids` to collector IDs case-insensitively. IDs in `exclude_ids` that don’t match the filter are ignored and don’t change the count.

The request fails and no collectors are updated in the following cases:

- **`400` `failed_precondition`:** `expected_count` is set and the number of matching collectors left after the exclusions differs from it.
- **`400` `invalid_argument`:** The operations would leave a collector with invalid remote attributes, as described in the [BulkUpdateCollectorsRequest](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#bulkupdatecollectorsrequest) section.
- **`409` `aborted`:** The request conflicted with another request that changed the same collectors. Retry the request.

### BulkUpdateCollectorsByFilterResponse

`BulkUpdateCollectorsByFilterResponse` is the response to a `BulkUpdateCollectorsByFilterRequest`.

Expand table

| Field          | Type    | Label | Description                                                                     |
|----------------|---------|-------|---------------------------------------------------------------------------------|
| updated\_count | integer |       | Number of matching collectors, including any that the operations left unchanged |

The `updated_count` can be lower than `expected_count` if another request deletes some of the matching collectors in the meantime.

### BulkUpdateCollectorsRequest

`BulkUpdateCollectorsRequest` is a request to update multiple collectors’ remote attributes in a single request. If any requested update fails, Fleet Management applies none of the updates. A `BulkUpdateCollectorsRequest` can add, remove, replace, move, or copy remote attributes for the specified collectors. Each [`Operation`](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#operation) applies to every collector in `ids`. IDs that don’t match an existing collector are skipped and don’t cause the request to fail. For a sample request, refer to the [Bulk update collectors](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#bulk-update-collectors) example.

Fleet Management validates each collector after it applies the operations. If the result breaks the [`remote_attributes`](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#collector) limits for any collector, for example more than 100 attributes, a value longer than 150 characters, or a reserved attribute on an OpenTelemetry Collector, the request fails with a `400` `invalid_argument` error. If the request conflicts with another request that changes the same collectors, it fails with a `409` `aborted` error. Retry the request.

Expand table

| Field | Type            | Label    | Description                                                                       |
|-------|-----------------|----------|-----------------------------------------------------------------------------------|
| ids   | list(string)    | required | IDs of the collectors to update; must contain at least one ID                     |
| ops   | list(Operation) | required | Operations applied to collectors in the order they’re provided; must not be empty |

### BulkUpdateCollectorsResponse

`BulkUpdateCollectorsResponse` is the response to a `BulkUpdateCollectorsRequest`. This message is empty and the results of the update are defined by the HTTP status code of the response.

### Collector

`Collector` represents the data for a single collector. The ID uniquely identifies the collector, and the `local_attributes` and `remote_attributes` determine which pipelines to include in the collector’s configuration. Remote attributes take precedence over attributes set in the collector’s local configuration except for any attributes prefixed with `collector.`. `collector.*` attributes are reserved for use by the Fleet Management service. OpenTelemetry Collectors also can’t have the remote attributes `service.name`, `service.namespace`, `service.version`, `service.instance.id`, `os.type`, and `os.description`, or remote attributes in the `host.` and `cloud.` namespaces. For more information, refer to [reserved attributes](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/introduction/glossary/#attribute-reserved).

Expand table

| Field                | Type                      | Label    | Description                                                                                                                                                                   |
|----------------------|---------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| id                   | string                    | required | ID of the collector; OpenTelemetry Collector IDs must be UUIDs                                                                                                                |
| local\_attributes    | map(string)               | optional | Last set of attributes received from the collector when it registered, plus the virtual `collector.ID` attribute; ignored in `CreateCollector` and `UpdateCollector` requests |
| remote\_attributes   | map(string)               | optional | Attributes stored in Fleet Management; up to 100 attributes, with non-empty keys of up to 100 characters and values of up to 150 characters                                   |
| created\_at          | google.protobuf.Timestamp | optional | Timestamp that the collector was created                                                                                                                                      |
| updated\_at          | google.protobuf.Timestamp | optional | Timestamp that the collector was last updated                                                                                                                                 |
| name                 | string                    | optional | Name of the collector used for display purposes only                                                                                                                          |
| enabled              | bool                      | optional | Whether remote configuration for the collector is enabled or not; disabled collectors receive empty configurations                                                            |
| marked\_inactive\_at | google.protobuf.Timestamp | optional | Timestamp of when the collector was marked inactive                                                                                                                           |
| collector\_type      | CollectorType             | optional | Type of collector (Grafana Alloy or OpenTelemetry Collector); if unspecified in a `CreateCollector` or `UpdateCollector` request, it’s set to `COLLECTOR_TYPE_ALLOY`          |
| state                | CollectorState            | optional | Computed runtime state of the collector; only returned by `ListCollectors` when `include_state` is `true`                                                                     |

#### CollectorType

`CollectorType` represents the type of collector. If the `CollectorType` is left unspecified in a `CreateCollector` or `UpdateCollector` request, Fleet Management assigns `COLLECTOR_TYPE_ALLOY`.

Expand table

| Value                        | Description                     |
|------------------------------|---------------------------------|
| COLLECTOR\_TYPE\_UNSPECIFIED | Collector type is not specified |
| COLLECTOR\_TYPE\_ALLOY       | Grafana Alloy collector         |
| COLLECTOR\_TYPE\_OTEL        | OpenTelemetry Collector         |

### CollectorState

`CollectorState` is the computed runtime state of a collector. `ListCollectors` returns it for each collector when the request sets `include_state` to `true`, so you don’t need a separate request for status and last-seen information.

Expand table

| Field                  | Type                      | Label    | Description                                                                                   |
|------------------------|---------------------------|----------|-----------------------------------------------------------------------------------------------|
| status                 | string                    |          | Computed health status of the collector: `healthy`, `warning`, or `error`                     |
| last\_seen             | google.protobuf.Timestamp | optional | Timestamp of the collector’s most recent heartbeat; omitted if no heartbeat exists            |
| remote\_config\_status | RemoteConfigStatus        | optional | Last remote configuration status reported by the collector; omitted if none has been reported |
| capabilities           | uint64                    | optional | OpAMP capabilities bitmask reported by the collector; omitted if none has been reported       |

Fleet Management computes the `status` as follows:

- **`error`:** The collector reported that it failed to apply its last remote configuration.
- **`healthy`:** The collector sent a heartbeat in the last 30 minutes.
- **`warning`:** The collector’s last heartbeat is older than 30 minutes or doesn’t exist.

#### RemoteConfigStatus

Expand table

| Field          | Type                 | Label    | Description                                                  |
|----------------|----------------------|----------|--------------------------------------------------------------|
| status         | RemoteConfigStatuses |          | Current status of the last received remote configuration     |
| error\_message | string               | optional | Error message when `status` is `RemoteConfigStatuses_FAILED` |

##### RemoteConfigStatuses

Expand table

| Value                          | Description                                                                 |
|--------------------------------|-----------------------------------------------------------------------------|
| RemoteConfigStatuses\_UNSET    | Status not set                                                              |
| RemoteConfigStatuses\_APPLIED  | Remote config was successfully applied by the collector                     |
| RemoteConfigStatuses\_APPLYING | Collector is currently applying the remote config                           |
| RemoteConfigStatuses\_FAILED   | Applying the previously received remote config failed (see `error_message`) |

### CountCollectorsRequest

`CountCollectorsRequest` is the request to count collectors that match a filter. It accepts the same [`ListCollectorsFilter`](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#listcollectorsfilter) as `ListCollectors`. If no filter is specified, all collectors are counted.

Expand table

| Field  | Type                 | Label    | Description                               |
|--------|----------------------|----------|-------------------------------------------|
| filter | ListCollectorsFilter | optional | Filters to apply when counting collectors |

### CountCollectorsResponse

`CountCollectorsResponse` is the response to a `CountCollectorsRequest`. If no collectors match, the response omits the `count` field.

Expand table

| Field | Type    | Label | Description                                    |
|-------|---------|-------|------------------------------------------------|
| count | integer |       | Total number of collectors matching the filter |

### CreateCollectorRequest

`CreateCollectorRequest` is the request to create a new collector. If no `collector_type` is specified in this request, `COLLECTOR_TYPE_ALLOY` is assigned by default. If `enabled` isn’t specified, the collector is enabled. Fleet Management ignores any `local_attributes` in this request.

The request fails in the following cases:

- **`409` `already_exists`:** A collector with the same ID already exists.
- **`429` `resource_exhausted`:** Your stack has reached its collector limit.
- **`400` `invalid_argument`:** The ID is empty, an OpenTelemetry Collector ID isn’t a UUID, or the remote attributes have an empty key, use a reserved attribute or namespace, or exceed the limits.

Expand table

| Field     | Type      | Label    | Description                           |
|-----------|-----------|----------|---------------------------------------|
| collector | Collector | required | New collector; `id` must not be empty |

### DeleteCollectorRequest

`DeleteCollectorRequest` is the request to delete an existing collector. If the collector doesn’t exist, the request fails with a `404` `not_found` error.

Expand table

| Field | Type   | Label    | Description                   |
|-------|--------|----------|-------------------------------|
| id    | string | required | ID of the collector to delete |

### DeleteCollectorResponse

`DeleteCollectorResponse` is the response to a `DeleteCollectorRequest`. This message is empty and the results of the delete are defined by the HTTP status code of the response.

### GetCollectorRequest

`GetCollectorRequest` is the request to retrieve a collector’s information. Its response is a `Collector` message. If the collector doesn’t exist, the request fails with a `404` `not_found` error.

Expand table

| Field | Type   | Label    | Description                     |
|-------|--------|----------|---------------------------------|
| id    | string | required | ID of the collector to retrieve |

### ListCollectorAttributesRequest

`ListCollectorAttributesRequest` is the request to list all attributes that are used for all collectors.

### ListCollectorAttributesResponse

`ListCollectorAttributesResponse` is the response to a `ListCollectorAttributesRequest`. It contains maps of all attributes and all their values that are used for all collectors.

Expand table

| Field              | Type                    | Label | Description                                              |
|--------------------|-------------------------|-------|----------------------------------------------------------|
| local\_attributes  | map(string, Attributes) |       | Local attributes for all collectors                      |
| remote\_attributes | map(string, Attributes) |       | Attributes stored in Fleet Management for all collectors |

If at least one collector exists, `local_attributes` includes the virtual attribute `collector.ID` with an empty list of values.

#### ListCollectorAttributesResponse.AttributesEntry

Expand table

| Field | Type       |
|-------|------------|
| key   | string     |
| value | Attributes |

##### Attributes

Expand table

| Field  | Type        | Label | Description                       |
|--------|-------------|-------|-----------------------------------|
| values | list(Value) |       | All values for a single attribute |

###### Value

Expand table

| Field | Type   | Label | Description                   |
|-------|--------|-------|-------------------------------|
| value | string |       | Single value for an attribute |

### ListCollectorsFilter

`ListCollectorsFilter` groups the filters you can apply when listing, counting, bulk updating, or bulk deleting collectors. A collector must match every filter that you set.

Expand table

| Field            | Type          | Label    | Description                                                                                                                                                                  |
|------------------|---------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| matchers         | list(string)  | optional | Matchers used to filter collectors by attribute; follows the syntax of Prometheus [Alertmanager matchers](https://prometheus.io/docs/alerting/latest/configuration/#matcher) |
| statuses         | list(string)  | optional | Health statuses to include: `healthy`, `warning`, or `error`; values must be unique; if empty, collectors of all statuses are included                                       |
| id               | string        | optional | Includes only collectors whose ID contains this value; case-insensitive; 256 character limit                                                                                 |
| collector\_type  | CollectorType | optional | Includes only collectors of this type; if unset or `COLLECTOR_TYPE_UNSPECIFIED`, collectors of all types are included                                                        |
| activity\_states | list(string)  | optional | Activity states to include: `active` or `inactive`; values must be unique; if empty, collectors of all activity states are included                                          |

Matchers apply to the collector’s combined attributes: its local attributes, its remote attributes, which take precedence over local attributes with the same key, and the virtual `collector.ID` attribute. A collector is `active` if it hasn’t been marked inactive, and `inactive` otherwise. Health statuses follow the rules in the [CollectorState](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#collectorstate) section. Requests with an invalid matcher, or an invalid or duplicate value in `statuses` or `activity_states`, fail with a `400` `invalid_argument` error.

### ListCollectorsRequest

`ListCollectorsRequest` is the request to list collectors one page at a time, with optional filtering and sort order. If no filter is specified, all collectors are returned.

To fetch the next page, send the same request with `page_token` set to the `next_page_token` from the previous response. If you change `filter`, `sort_by`, or `sort_descending`, omit `page_token` and start again from the first page. An invalid `page_token` fails with a `400` `invalid_argument` error.

Expand table

| Field            | Type                         | Label    | Description                                                                                                                                                                                                  |
|------------------|------------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| page\_token      | string                       | optional | Token for the page to fetch; omit to fetch the first page                                                                                                                                                    |
| page\_size       | integer                      | optional | Maximum number of collectors to return per page; default is `100` and maximum is `500`                                                                                                                       |
| sort\_by         | ListCollectorsRequest.SortBy | optional | Field to sort results by; default is `SORT_BY_ID`                                                                                                                                                            |
| sort\_descending | bool                         | optional | Whether to sort results in descending order; default is `false`                                                                                                                                              |
| filter           | ListCollectorsFilter         | optional | [Filters](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#listcollectorsfilter) to apply to the list of collectors                                         |
| include\_state   | bool                         | optional | Whether to include each collector’s [`CollectorState`](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#collectorstate) in the response; default is `false` |

If `page_size` is `0` or less, Fleet Management uses the default of `100`. If `page_size` is greater than `500`, Fleet Management uses `500`. Every page except the last contains exactly this number of collectors. The last page might contain fewer collectors or be empty.

#### ListCollectorsRequest.SortBy

Expand table

| Value                    | Description                                      |
|--------------------------|--------------------------------------------------|
| SORT\_BY\_UNSPECIFIED    | Default; sorts by collector ID                   |
| SORT\_BY\_ID             | Sorts by collector ID                            |
| SORT\_BY\_LAST\_MODIFIED | Sorts by the time the collector was last updated |

### ListCollectorsResponse

`ListCollectorsResponse` is the response to a `ListCollectorsRequest`.

Expand table

| Field             | Type            | Label | Description                                                          |
|-------------------|-----------------|-------|----------------------------------------------------------------------|
| collectors        | list(Collector) |       | Collectors on the current page                                       |
| next\_page\_token | string          |       | Token for fetching the next page; omitted if there are no more pages |

### Operation

`Operation` is a single operation to apply to a collector’s remote attributes.

The `path` and `from` fields use the format `remoteAttributes.<ATTRIBUTE_KEY>`. For example, the path for the `env` remote attribute is `remoteAttributes.env`. Everything after the first `.` is the attribute key, so `remoteAttributes.team.name` refers to the `team.name` attribute. You can’t modify attributes in the reserved `collector.` namespace.

If any operation is invalid, the request fails with a `400` `invalid_argument` error and no collectors are updated. An operation is invalid in the following cases:

- **Path:** `path` or `from` is empty, doesn’t start with `remoteAttributes.`, has no attribute key after the prefix, or refers to a `collector.` attribute.
- **`ADD`:** The operation has no `value`. An empty string is a valid value.
- **`REPLACE`:** The operation has no `value`, or `value` is an empty string.
- **`MOVE` and `COPY`:** The operation has no `from`.
- **Operation type:** `op` isn’t set or isn’t one of the values in the [Operation.OpType](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#operationoptype) table.

Expand table

| Field    | Type             | Label    | Description                                                                                 |
|----------|------------------|----------|---------------------------------------------------------------------------------------------|
| op       | Operation.OpType | required | Operation to perform                                                                        |
| path     | string           | required | Path for the operation formatted as a JSON path, for example `remoteAttributes.env`         |
| from     | string           | optional | Used by the `MOVE` and `COPY` operations for the source path to move or copy the value from |
| value    | string           | optional | Value for `ADD` and `REPLACE` operations, as well as selective removal                      |
| oldValue | string           | optional | Old value to match against for a selective replace                                          |

#### Operation.OpType

Expand table

| Value   | Description                                                                                                                                                                        |
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ADD     | Adds a new attribute or replaces one with the specified `path`                                                                                                                     |
| REMOVE  | Removes the attribute at the specified `path`; if `value` is set, removes it only if its value matches `value`                                                                     |
| REPLACE | Replaces the existing value of the attribute at the specified `path` but doesn’t create one if none exists; if `oldValue` is set, replaces it only if its value matches `oldValue` |
| MOVE    | Moves the attribute with the specified `from` to the specified `path`; does nothing if `from` doesn’t exist                                                                        |
| COPY    | Copies the attribute at the specified `from` to the specified `path`; does nothing if `from` doesn’t exist                                                                         |

### PreviewConfigRequest

`PreviewConfigRequest` is the request to preview the configuration a collector would receive. Fleet Management builds the configuration from the collector’s stored local and remote attributes. Unlike a collector’s own `GetConfig` request, a preview doesn’t register the collector, record a heartbeat, or reactivate an inactive collector. If the collector is disabled, the preview returns the configuration a disabled collector receives: a base configuration with no pipelines for Alloy, or an empty configuration for an OpenTelemetry Collector.

The request fails in the following cases:

- **`404` `not_found`:** The collector doesn’t exist.
- **`400` `failed_precondition`:** A matching pipeline references an export that can’t be resolved.

Expand table

| Field | Type   | Label    | Description                                      |
|-------|--------|----------|--------------------------------------------------|
| id    | string | required | ID of the collector to preview configuration for |

### PreviewConfigResponse

`PreviewConfigResponse` is the response to a `PreviewConfigRequest`.

Expand table

| Field   | Type   | Label | Description                                    |
|---------|--------|-------|------------------------------------------------|
| content | string |       | Full configuration the collector would receive |
| hash    | string |       | Hash of the configuration content              |

### UpdateCollectorRequest

`UpdateCollectorRequest` is the request to update an existing collector. It updates the collector with the exact values provided in the request. If the `enabled` field isn’t provided, the collector’s existing state persists. All other updates aren’t selective, and any fields that aren’t provided are removed. Fleet Management ignores any `local_attributes` in this request.

The request also replaces `collector_type`. If you leave it unset, Fleet Management sets the type to `COLLECTOR_TYPE_ALLOY`, even if the collector was an OpenTelemetry Collector. To update an OpenTelemetry Collector, set `collector_type` to `COLLECTOR_TYPE_OTEL`.

The request fails in the following cases:

- **`404` `not_found`:** The collector doesn’t exist.
- **`400` `invalid_argument`:** The collector fails the same checks as in a [`CreateCollectorRequest`](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/collector-api-v2/#createcollectorrequest).

Expand table

| Field     | Type      | Label    | Description                                     |
|-----------|-----------|----------|-------------------------------------------------|
| collector | Collector | required | Collector to be updated; `id` must not be empty |

## Examples

The examples in this section use `curl` with basic authentication. Replace `user:pass` with your Fleet Management instance ID and access policy token, and replace the base URL with the one from your **API** tab.

The following JSON files contain sample payloads about a collector, `karasu`:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
--- create-collector.json ---
{
    "collector": {
        "id": "karasu",
        "remote_attributes": {"myremoteattr": "myremoteval"},
        "name": "raven",
        "enabled": true,
        "collector_type": "COLLECTOR_TYPE_ALLOY"
    }
}

--- update-collector.json ---
{
    "collector": {
        "id": "karasu",
        "remote_attributes": {"myremoteattr": "mynewremoteval"},
        "name": "raven"
    }
}

--- get-collector.json ---
{
    "id": "karasu"
}

--- delete-collector.json ---
{
    "id": "karasu"
}
```

You can use these payloads to make the following requests. `CreateCollector` and `UpdateCollector` return the collector as it’s stored in Fleet Management:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
$ curl -q \
    -d @create-collector.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/CreateCollector
{"id":"karasu","localAttributes":{"collector.ID":"karasu"},"remoteAttributes":{"myremoteattr":"myremoteval"},"createdAt":"2026-09-02T14:59:13Z","updatedAt":"2026-09-02T14:59:13Z","name":"raven","enabled":true,"collectorType":"COLLECTOR_TYPE_ALLOY"}%

$ curl -q \
    -d @update-collector.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/UpdateCollector
{"id":"karasu","localAttributes":{"collector.ID":"karasu"},"remoteAttributes":{"myremoteattr":"mynewremoteval"},"createdAt":"2026-09-02T14:59:13Z","updatedAt":"2026-09-02T16:18:38Z","name":"raven","enabled":true,"collectorType":"COLLECTOR_TYPE_ALLOY"}%

$ curl -q \
    -d @get-collector.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/GetCollector
{"id":"karasu","localAttributes":{"collector.ID":"karasu"},"remoteAttributes":{"myremoteattr":"mynewremoteval"},"createdAt":"2026-09-02T14:59:13Z","updatedAt":"2026-09-02T16:18:38Z","name":"raven","enabled":true,"collectorType":"COLLECTOR_TYPE_ALLOY"}%

$ curl -q \
    -d @delete-collector.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/DeleteCollector
{}%
```

### List collectors

The following JSON file contains a sample `ListCollectorsRequest` payload. It requests the 2 most recently updated active Grafana Alloy collectors running on Linux that are in a `warning` or `error` state, and includes each collector’s state in the response:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
--- list-collectors.json ---
{
    "page_size": 2,
    "sort_by": "SORT_BY_LAST_MODIFIED",
    "sort_descending": true,
    "include_state": true,
    "filter": {
        "matchers": ["collector.os=linux"],
        "statuses": ["warning", "error"],
        "collector_type": "COLLECTOR_TYPE_ALLOY",
        "activity_states": ["active"]
    }
}
```

You can use this payload to make the following request:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
curl -q \
    -d @list-collectors.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/ListCollectors
```

The output resembles the following:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
{
  "collectors": [
    {
      "id": "kuro",
      "localAttributes": {
        "collector.ID": "kuro",
        "collector.os": "linux",
        "collector.version": "v1.12.0"
      },
      "createdAt": "2026-09-01T10:12:44Z",
      "updatedAt": "2026-09-03T08:21:05Z",
      "enabled": true,
      "collectorType": "COLLECTOR_TYPE_ALLOY",
      "state": {
        "status": "error",
        "lastSeen": "2026-09-03T08:20:58Z",
        "remoteConfigStatus": {
          "status": "RemoteConfigStatuses_FAILED",
          "errorMessage": "... error details ..."
        },
        "capabilities": "8191"
      }
    },
    {
      "id": "hayabusa",
      "localAttributes": {
        "collector.ID": "hayabusa",
        "collector.os": "linux",
        "collector.version": "v1.11.3"
      },
      "createdAt": "2026-08-28T15:40:02Z",
      "updatedAt": "2026-09-02T19:03:37Z",
      "enabled": true,
      "collectorType": "COLLECTOR_TYPE_ALLOY",
      "state": {
        "status": "warning",
        "lastSeen": "2026-09-02T19:03:30Z",
        "remoteConfigStatus": {
          "status": "RemoteConfigStatuses_APPLIED"
        },
        "capabilities": "8191"
      }
    }
  ],
  "nextPageToken": "<NEXT_PAGE_TOKEN>"
}
```

The response returns the `capabilities` value as a JSON string.

To fetch the next page, send the same payload with `page_token` set to the `nextPageToken` value from the response, where *`<NEXT_PAGE_TOKEN>`* is the token returned by the previous request:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
jq --arg token "<NEXT_PAGE_TOKEN>" '.page_token = $token' list-collectors.json > list-collectors-next.json
```

When the response doesn’t contain `nextPageToken`, you’ve reached the last page.

### Count collectors

The `CountCollectors` request takes the same filter as `ListCollectors`. The following request counts all collectors in an `error` state:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
curl -q \
    -d '{"filter": {"statuses": ["error"]}}' \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/CountCollectors
{"count":12}%
```

To count all collectors, send an empty payload, `{}`.

### Preview a collector’s configuration

The `PreviewConfig` request returns the configuration Fleet Management would send to a collector, based on the attributes it has stored. Use it to check the effect of remote attribute or pipeline changes before the collector picks them up:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
curl -q \
    -d '{"id": "karasu"}' \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/PreviewConfig
```

The output resembles the following, where `content` contains the full configuration:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
{"content":"declare \"my_pipeline\" {\n  ...\n}\n","hash":"<CONFIG_HASH>"}
```

### Bulk update collectors

The following JSON file contains a sample `BulkUpdateCollectorsRequest` payload that updates the remote attributes of three collectors, `karasu`, `kuro`, and `hayabusa`, in a single request:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
--- bulk-update-collectors.json ---
{
    "ids": ["karasu", "kuro", "hayabusa"],
    "ops": [
        {
            "op": "ADD",
            "path": "remoteAttributes.env",
            "value": "production"
        },
        {
            "op": "REPLACE",
            "path": "remoteAttributes.team",
            "oldValue": "platform",
            "value": "observability"
        },
        {
            "op": "MOVE",
            "from": "remoteAttributes.region",
            "path": "remoteAttributes.cloud_region"
        },
        {
            "op": "REMOVE",
            "path": "remoteAttributes.deprecated"
        }
    ]
}
```

Fleet Management applies the operations in order to each collector:

1. `ADD` sets `env` to `production`, creating the attribute or overwriting its current value.
2. `REPLACE` changes `team` to `observability`, but only on collectors where `team` is currently `platform`.
3. `MOVE` renames the `region` attribute to `cloud_region` and keeps its value.
4. `REMOVE` deletes the `deprecated` attribute.

Operations that don’t match a collector, for example a `REPLACE` where the current value differs from `oldValue`, leave that collector unchanged and don’t cause the request to fail.

You can use this payload to make the following request:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
$ curl -q \
    -d @bulk-update-collectors.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/BulkUpdateCollectors
{}%
```

To confirm the changes, make a `GetCollector` request for one of the collectors, or a `ListCollectors` request with a matcher on the new attribute:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
$ curl -q \
    -d '{"filter": {"matchers": ["env=production"]}}' \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/ListCollectors
```

### Bulk update collectors by filter

Before you update by filter, use `ListCollectors` with the same filter to review the matching collectors. Then use `CountCollectors` to get the number of matches. The following request counts the active collectors with `env=staging`:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
$ curl -q \
    -d '{"filter": {"matchers": ["env=staging"], "activity_states": ["active"]}}' \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/CountCollectors
{"count":42}%
```

The following JSON file contains a sample `BulkUpdateCollectorsByFilterRequest` payload. It sets `tier` to `gold` on the same collectors, except `kuro`, and requires the request to act on exactly 41 collectors:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
--- bulk-update-by-filter.json ---
{
    "filter": {
        "matchers": ["env=staging"],
        "activity_states": ["active"]
    },
    "ops": [
        {
            "op": "ADD",
            "path": "remoteAttributes.tier",
            "value": "gold"
        }
    ],
    "exclude_ids": ["kuro"],
    "expected_count": 41
}
```

You can use this payload to make the following request:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
$ curl -q \
    -d @bulk-update-by-filter.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/BulkUpdateCollectorsByFilter
{"updatedCount":41}%
```

If collectors register or change between the count and the update so that the filter no longer matches exactly 41 collectors after the exclusion, the request fails with a `400` `failed_precondition` error and no collectors are updated. Review the matching collectors with `ListCollectors` before you count again and retry.

### Bulk delete collectors

The `BulkDeleteCollectors` request deletes multiple collectors by ID in a single request. If any collector in the list doesn’t exist, the request fails with a `404` `not_found` error and no collectors are deleted:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
$ curl -q \
    -d '{"ids": ["karasu", "kuro", "hayabusa"]}' \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/BulkDeleteCollectors
{}%
```

### Bulk delete collectors by filter

The `BulkDeleteCollectorsByFilter` request deletes every collector that matches a filter. The following request deletes all inactive collectors, and requires the count from a previous `CountCollectors` request with the same filter to still be accurate:

shell ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```shell
$ curl -q \
    -d '{"filter": {"activity_states": ["inactive"]}, "expected_count": 17}' \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v2.CollectorService/BulkDeleteCollectorsByFilter
{"deletedCount":17}%
```

A by-filter request must set at least one filter field.

## Next steps

- Learn about collector health in [Collector status](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/manage-fleet/collectors/collector-status/).
- Manage configuration pipelines with the [Pipeline HTTP API](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/pipeline-api/).
- Find your stack’s rate limits with the [Tenant HTTP API](https://grafana.com/docs/grafana-cloud/send-data/fleet-management/api-reference/tenant-api/).
- Read the full [Collector API v2 `.proto` file](https://github.com/grafana/fleet-management-api/blob/main/api/collector/v2/collector.proto).
