Menu
Grafana Cloud

Note

Fleet Management is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available. For bug reports or questions, fill out our feedback form.

The Collector HTTP API

The Grafana Fleet Management Collector API offers straightforward CRUD operations on individual collectors as well as bulk deletes and updates.

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 > Collector > 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 the following URL, where <CLUSTER_NAME> is the production cluster of your stack:
https://fleet-management-<CLUSTER_NAME>.grafana.net/collector.v1.CollectorService/

CollectorService

CollectorService is the service that is used to register, update, and provide remote configuration for collectors.

Method NameRequest TypeResponse TypeDescription
GetConfigGetConfigRequestGetConfigResponseReturns the collector’s configuration
RegisterCollectorRegisterCollectorRequestRegisterCollectorResponseRegisters the collector with the given ID and attributes and updates the collector’s attributes if the collector is already registered and the attributes are different
GetCollectorGetCollectorRequestCollectorReturns information about the collector
ListCollectorsListCollectorsRequestCollectorsReturns information about all collectors
CreateCollectorCreateCollectorRequestCollectorCreates a new collector
UpdateCollectorUpdateCollectorRequestCollectorUpdates an existing collector
BulkUpdateCollectorsBulkUpdateCollectorsRequestBulkUpdateCollectorsResponseUpdates multiple collectors
DeleteCollectorDeleteCollectorRequestDeleteCollectorResponseDeletes an existing collector
BulkDeleteCollectorsBulkDeleteCollectorRequestBulkDeleteCollectorResponseDeletes multiple collectors
ListCollectorAttributesListCollectorAttributesRequestListCollectorAttributesResponseReturns all attributes that are used for all collectors

Endpoints

BulkDeleteCollectorsRequest

BulkDeleteCollectorsRequest is a request to delete multiple collectors. If any collectors do not exist, the request fails and no collectors are deleted.

FieldTypeLabelDescription
idlist(string)requiredIDs of collectors to delete

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.

BulkUpdateCollectorsRequest

BulkUpdateCollectorsRequest is a request to update multiple Collectors’ attribute_overrides in a single request. The update is applied in a single transaction, so any errors cause the entire request to fail and no Collectors are updated. A BulkUpdateCollectorsRequest can be used to add, remove, replace, move, or copy attribute overrides for the specified Collectors.

FieldTypeLabelDescription
idslist(string)requiredID of the Collector to update
opslist(Operation)requiredOperations applied to collectors in the order they are provided

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 Alloy collector. The ID is used to uniquely identify the collector, and the attributes and attribute_overrides are used to determine which pipelines to include in the collector’s configuration. Attribute overrides are also known as custom attributes. These 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.

FieldTypeLabelDescription
idstringrequiredID of the collector
attribute_overridesmap(string)optionalAttribute overrides for the collector
created_atgoogle.protobuf.TimestampoptionalTimestamp that the collector was created
updated_atgoogle.protobuf.TimestampoptionalTimestamp that the collector was last updated
namestringoptionalName of the collector used for display purposes only
attributesmap(string)optionalLast set of attributes received from the collector in a RegisterCollectorRequest
enabledbooloptionalWhether the collector is enabled or not

Collectors

Collectors represents a list of collectors.

FieldTypeLabelDescription
collectorslist(Collector)List of collectors

CreateCollectorRequest

CreateCollectorRequest is the request to create a new collector.

FieldTypeLabelDescription
collectorCollectorNew collector

DeleteCollectorRequest

DeleteCollectorRequest is the request to delete an existing collector.

FieldTypeLabelDescription
idstringrequiredID 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.

FieldTypeLabelDescription
idstringrequiredID of the collector to retrieve

GetConfigRequest

GetConfigRequest is the request message to get a collector’s configuration. The collector’s ID and any supplied attributes are used to determine which pipelines to include in the configuration. Attributes are key-value pairs. The collector’s attributes, also known as system attributes, are combined with any attribute overrides, also known as custom attributes, to determine the final configuration.

FieldTypeLabelDescription
idstringrequiredID of the collector the configuration is for
attributesmap(string)optionalSystem and custom attributes of the collector
hashstringoptionalDetermines if the configuration has changed

GetConfigResponse

GetConfigResponse is the server-to-collector response message that contains the collector’s configuration.

FieldTypeLabelDescription
contentstringFull configuration for the collector
hashstringDetermines if the configuration has changed and avoids sending the full configuration if it has not changed
not_modifiedboolSet to true if the configuration has not changed, indicating the client should not update its configuration

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 a map of all attributes and all their values that are used for all collectors.

FieldTypeLabelDescription
attributesmap(string)All attributes and values for all collectors

ListCollectorAttributesResponse.AttributesEntry

FieldType
keystring
valueAttributes
Attributes
FieldTypeLabelDescription
valueslist(Value)All values for a single attribute
Value
FieldTypeLabelDescription
valuestringSingle value for an attribute

ListCollectorsRequest

ListCollectorsRequest is the request to list collectors according to any specified matchers. If no matchers are specified, all collectors are returned.

FieldTypeLabelDescription
matcherslist(string)Matchers used to filter the list of collectors

Operation

Operation is a single operation to apply to a collector’s attribute overrides.

FieldTypeLabelDescription
opOperation.OpTyperequiredOperation to perform
pathstringrequiredPath for the operation formatted as a JSON path
fromstringoptionalUsed by the move and copy operations to specify the source path to move or copy the value from
valuestringoptionalValue for add and replace operations, as well as selective removal
oldValuestringoptionalOld value to match against for a selective replace

Operation.OpType

ValueDescription
ADDAdds a new attribute or replaces one with the specified path
REMOVERemoves the attribute at the specified path
REPLACEReplaces the existing value of the attribute at the specified path but does not create one if none exists
MOVEMoves the attribute with the specified from to the specified path
COPYCopies the attribute at the specified from to the specified path

RegisterCollectorRequest

RegisterCollectorRequest is used to register a collector with the Fleet Management service, or update the collector’s attributes if the collector is already registered. This request is intended only to be used by the collector itself. It is sent on startup or when the collector’s local configuration changes.

FieldTypeLabelDescription
idstringrequiredID of the collector
attributesmap(string)optionalAttributes of the collector to register
namestringoptionalName of the collector

RegisterCollectorResponse

The response to a RegisterCollectorRequest. This message is empty and the results of the registration are defined by the HTTP status code of the response.

UpdateCollectorRequest

UpdateCollectorRequest is the request to update an existing collector. It updates the collector with the exact values provided in the request. Updates are not selective, and any fields that are not provided are removed. For example, if the enabled field is not provided, enabled is treated as false.

FieldTypeLabelDescription
collectorCollectorCollector to be updated

Examples

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

json
--- create-collector.json ---
{
    "collector": {
        "id": "karasu",
        "attribute_overrides": {"mycustomattr": "mycustomval"},
        "name": "raven",
        "enabled": true
    }
}

--- update-collector.json ---
{
    "collector": {
        "id": "karasu",
        "attribute_overrides": {"mycustomattr": "mynewcustomval"},
        "enabled": true
    }
}

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


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

You can use these payloads to make the following requests:

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.v1.CollectorService/CreateCollector
{}%

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

$ curl -q \
    -d @get-collector.json \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v1.CollectorService/GetCollector
{"id":"karasu","attributeOverrides":{"mycustomattr":"mynewcustomval"},"createdAt":"2024-09-02T14:59:13Z","updatedAt":"2024-09-02T16:18:38Z","enabled":true}%

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

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

$ curl -q \
    -d '{"matchers": ["collector.os=linux"]}' \
    -u "user:pass" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-prod-001.grafana.net/collector.v1.CollectorService/ListCollectors
{}%