Grafana Cloud

The Pipeline HTTP API v2

The Grafana Fleet Management Pipeline API v2 allows you to perform CRUD operations on configuration pipelines. It also lets you list, count, and delete pipelines in bulk using filters, and page through large result sets.

For a full definition of the Pipeline API v2, refer to the .proto file.

Differences from v1

When you migrate from the Pipeline API v1, the following changes affect the requests you send and the responses you receive:

  • Pagination: ListPipelines, ListPipelinesRevisions, and ListPipelineRevisions return results one page at a time. Use the next_page_token from a response to request the next page.
  • Filtering and sorting: ListPipelines filters by pipeline name, enabled state, and metadata type, and sorts by name or last modified time. It no longer filters by local_attributes, remote_attributes, or config_type. To find the pipelines that match a set of collector attributes, use GetMatchingPipelines.
  • Revision order and filters: The revision RPCs return revisions newest first and accept filters for operation, author, and creation time.
  • New RPCs: CountPipelines, BulkDeletePipelinesByFilter, and GetMatchingPipelines are only available in v2.
  • Stricter validation: BulkDeletePipelines.ids, BulkDeletePipelinesByFilter.exclude_ids, ListPipelineRevisions.id, ListPipelinesRevisionsFilter.pipeline_id, and GetPipelineRevision.revision_id must be digit-only strings.

Find the base URL

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

  1. In your Grafana Cloud stack, click Connections > 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. To call the Pipeline API v2, replace pipeline.v1 with pipeline.v2 in the URL.

    Flat format, where <CLUSTER_NAME> is the production cluster of your stack:

    https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/

    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:

    https://fleet-management-<CLUSTER_NAME>.<CSP>-<CSP_REGION>-<COUNTER>.grafana.net/pipeline.v2.PipelineService/

    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.

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:

Rate limit

You can make a request to the Fleet Management Tenant API to find out the requests-per-second limits applied to your stack.

Requests to the Pipeline API v2 are included in the requests_per_second:api limit reported by the Tenant API and are limited to 3 requests per second by default. Requests to the Pipeline API v1 and v2 share this limit.

PipelineService

The PipelineService defines the RPCs for managing pipelines.

Method NameRequest TypeResponse TypeDescription
GetPipelineGetPipelineRequestPipelineReturns a pipeline by ID
GetPipelineIDGetPipelineIDRequestGetPipelineIDResponseReturns a pipeline ID by name
ListPipelinesListPipelinesRequestListPipelinesResponseReturns a page of pipelines
CountPipelinesCountPipelinesRequestCountPipelinesResponseReturns the number of pipelines matching a filter
GetMatchingPipelinesGetMatchingPipelinesRequestGetMatchingPipelinesResponseReturns the pipelines whose matchers match a set of attributes
CreatePipelineCreatePipelineRequestPipelineCreates a new pipeline and returns it
UpdatePipelineUpdatePipelineRequestPipelineUpdates an existing pipeline and returns it
UpsertPipelineUpsertPipelineRequestPipelineCreates a new pipeline or updates an existing one and returns it
DeletePipelineDeletePipelineRequestDeletePipelineResponseDeletes a pipeline by ID
BulkDeletePipelinesBulkDeletePipelinesRequestBulkDeletePipelinesResponseDeletes multiple pipelines by their IDs
BulkDeletePipelinesByFilterBulkDeletePipelinesByFilterRequestBulkDeletePipelinesByFilterResponseDeletes every pipeline matching a filter
SyncPipelinesSyncPipelinesRequestSyncPipelinesResponseCreates, updates, and deletes multiple pipelines from a common source
ListPipelinesRevisionsListPipelinesRevisionsRequestListPipelinesRevisionsResponseReturns a page of pipeline revisions across all pipelines
ListPipelineRevisionsListPipelineRevisionsRequestListPipelineRevisionsResponseReturns a page of pipeline revisions for a single pipeline by ID
GetPipelineRevisionGetPipelineRevisionRequestPipelineRevisionReturns a pipeline revision by revision ID

Endpoints

This section describes the request and response messages of the PipelineService RPCs and the types they use.

Note

Protobuf field names are defined in snake_case. Responses use camelCase field names. Both snake_case and camelCase field names are accepted in requests.

CreatePipelineRequest

CreatePipelineRequest is the request to create a new pipeline. Don’t set pipeline.id; Fleet Management assigns the ID when it creates the pipeline. If a pipeline with the same name already exists, the request returns a 409 ALREADY EXISTS error. If no config_type is specified in this request, CONFIG_TYPE_ALLOY is assigned by default.

FieldTypeLabelDescription
pipelinePipelinerequiredThe pipeline to create
validate_onlybooloptionalIf set, validates the request and previews the response, but doesn’t create the actual resource

DeletePipelineRequest

DeletePipelineRequest is the request to delete a pipeline by its ID. Requests with an id that isn’t a digit-only string fail with a 400 BAD REQUEST validation error.

FieldTypeLabelDescription
idstringrequiredID of the pipeline to delete; must be a string of digits (unsigned integer)

DeletePipelineResponse

DeletePipelineResponse is the response to deleting a pipeline. This message is empty and the results of the deletion are defined by the HTTP status code of the response.

BulkDeletePipelinesRequest

BulkDeletePipelinesRequest is the request to delete multiple pipelines by their IDs.

The operation is atomic: either all pipelines are deleted or none are. If any pipeline in the list doesn’t exist, the entire operation fails with a 404 NOT FOUND error and no pipelines are deleted. Requests with duplicate IDs, or with an ID that isn’t a digit-only string, fail with a 400 BAD REQUEST validation error.

FieldTypeLabelDescription
idslist(string)requiredThe IDs of the pipelines to delete; must be non-empty, unique, and strings of digits (unsigned integers)

BulkDeletePipelinesResponse

BulkDeletePipelinesResponse is the response to deleting multiple pipelines. This message is empty and the results of the deletion are defined by the HTTP status code of the response.

BulkDeletePipelinesByFilterRequest

BulkDeletePipelinesByFilterRequest is the request to delete every pipeline matching a filter. To preview which pipelines the request deletes, send a ListPipelinesRequest with the same filter.

The filter must set enabled, metadata_type, or a non-empty name. Requests that don’t set one fail with a 400 BAD REQUEST validation error.

Fleet Management selects the matching pipelines before it deletes them. It skips pipelines that another request deletes in the meantime, and still deletes pipelines that another request changes in the meantime. Skipped pipelines don’t count toward deleted_count, so deleted_count can be smaller than the number of matching pipelines you didn’t exclude.

To guard against unexpected changes, set expected_count to the number of pipelines you expect the request to delete: the count that CountPipelines returns for the same filter, minus the matching pipelines in exclude_ids. Fleet Management compares expected_count with the number of matching pipelines after it removes the exclude_ids. If the numbers differ, the request fails with a 400 FAILED PRECONDITION error and deletes no pipelines.

FieldTypeLabelDescription
filterListPipelinesFilterrequiredPipelines matching this filter are deleted
exclude_idslist(string)optionalIDs of matching pipelines to leave untouched; must be unique strings of digits (unsigned integers); IDs that don’t match the filter have no effect
expected_countint32optionalNon-negative count that must match the number of pipelines selected after exclude_ids are removed; 0 is allowed

BulkDeletePipelinesByFilterResponse

BulkDeletePipelinesByFilterResponse is the response to deleting pipelines by filter.

FieldTypeLabelDescription
deleted_countint32Number of pipelines deleted

GetPipelineRequest

GetPipelineRequest is the request to retrieve a pipeline by its ID.

FieldTypeLabelDescription
idstringrequiredID of the pipeline to get

GetPipelineIDRequest

GetPipelineIDRequest is the request to retrieve a pipeline ID by its name.

FieldTypeLabelDescription
namestringrequiredName of the pipeline to get the ID for

GetPipelineIDResponse

GetPipelineIDResponse is the response to retrieving a pipeline ID.

FieldTypeLabelDescription
idstringID of the pipeline

ListPipelinesRequest

ListPipelinesRequest is the request to get a page of pipelines, including their contents and matchers. You can filter the returned pipelines by name, enabled state, and metadata type, and sort them by name or last modified time.

To get 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. Requests with an invalid page_token fail with a 400 BAD REQUEST error.

FieldTypeLabelDescription
page_tokenstringoptionalToken for the page to return; when empty, the first page is returned
page_sizeint32optionalMaximum number of pipelines to return; defaults to 100 when unset or non-positive; capped at 500
sort_byListPipelinesRequest.SortByoptionalField to sort results by; defaults to SORT_BY_NAME
sort_descendingbooloptionalIf set, sorts results in descending order
filterListPipelinesFilteroptionalFilters to apply to the results

ListPipelinesRequest.SortBy

ValueDescription
SORT_BY_UNSPECIFIEDDefault; sorts by name
SORT_BY_NAMESorts by pipeline name
SORT_BY_LAST_MODIFIEDSorts by the time the pipeline was last updated, then by name for equal timestamps

ListPipelinesFilter

ListPipelinesFilter narrows down the pipelines returned by ListPipelinesRequest, counted by CountPipelinesRequest, and deleted by BulkDeletePipelinesByFilterRequest. When you set more than one field, a pipeline must match all of them.

FieldTypeLabelDescription
namestringoptionalReturns pipelines whose name contains this value (case-insensitive); 100 character limit
enabledbooloptionalReturns pipelines with this enabled state; when unset, returns both enabled and disabled pipelines
metadata_typestringoptionalReturns pipelines whose metadata type exactly matches this value (case-sensitive); pipelines without a string metadata type never match; an empty string matches only an explicit empty type; 100 character limit

ListPipelinesResponse

ListPipelinesResponse is the response to listing pipelines.

FieldTypeLabelDescription
pipelineslist(Pipeline)List of pipelines for the current page
next_page_tokenstringToken for the next page; empty when there are no more results

CountPipelinesRequest

CountPipelinesRequest is the request to count the pipelines matching a filter. It accepts the same filter as ListPipelinesRequest.

FieldTypeLabelDescription
filterListPipelinesFilteroptionalFilters to apply when counting; when unset, counts all pipelines

CountPipelinesResponse

CountPipelinesResponse is the response to counting pipelines.

FieldTypeLabelDescription
countint32Total number of pipelines matching the filter

GetMatchingPipelinesRequest

GetMatchingPipelinesRequest is the request to retrieve the pipelines whose matchers match a set of collector attributes. Fleet Management matches pipelines against the attributes in the request and doesn’t look up a stored collector. The collector_id is applied as the collector.ID attribute and replaces any collector.ID key in the supplied attributes. If a key exists in both local_attributes and remote_attributes, the remote attribute takes precedence. The response doesn’t guarantee an order of pipelines.

FieldTypeLabelDescription
collector_idstringrequiredID of the collector to match pipelines for
local_attributesmap(string)optionalLocal attributes to match against; maximum of 25 attributes, 100 character limit per key, 150 per value
remote_attributesmap(string)optionalRemote attributes to match against; maximum of 100 attributes, 100 character limit per key, 150 per value
config_typeConfigTypeoptionalReturns only pipelines of this config type; when unset or CONFIG_TYPE_UNSPECIFIED, returns pipelines of all config types
enabledbooloptionalReturns pipelines with this enabled state; when unset, returns both enabled and disabled pipelines

GetMatchingPipelinesResponse

GetMatchingPipelinesResponse is the response to retrieving matching pipelines.

FieldTypeLabelDescription
pipelineslist(Pipeline)List of pipelines whose matchers match the supplied attributes

ConfigType

Represents the type of config used by a pipeline. If the ConfigType is left unspecified in a create, update, upsert, or sync request, Fleet Management assigns CONFIG_TYPE_ALLOY. To keep an OpenTelemetry Collector pipeline, set CONFIG_TYPE_OTEL every time you update it.

ValueDescription
CONFIG_TYPE_UNSPECIFIEDDefault; don’t set manually
CONFIG_TYPE_ALLOYAlloy configuration
CONFIG_TYPE_OTELOpenTelemetry configuration

Pipeline

A Pipeline is a self-contained piece of configuration that can be assigned to collectors based on matchers.

FieldTypeLabelDescription
namestringrequiredName of the pipeline which is the unique identifier for the pipeline; must be a valid Alloy identifier; 100 character limit
contentsstringrequiredConfiguration contents of the pipeline to be used by collectors; can’t be empty
matcherslist(string)Used to match against collectors and assign pipelines to them; follows the syntax of Prometheus Alertmanager matchers; maximum of 15 matchers; 200 character limit per matcher; matcher keys can’t be empty
created_atgoogle.protobuf.TimestampoptionalTimestamp when the pipeline was created
updated_atgoogle.protobuf.TimestampoptionalTimestamp when the pipeline was last updated
enabledbooloptionalWhether the pipeline is enabled for collectors; defaults to true when unset in create, update, upsert, and sync requests
idstringoptionalServer-assigned ID of the pipeline
metadatagoogle.protobuf.StructoptionalAdditional information about the pipeline; if non-empty, must include a type field with a string value
sourcePipelineSourceoptionalSource of the pipeline
config_typeConfigTypeoptionalType of configuration (Grafana Alloy or OpenTelemetry Collector); defaults to CONFIG_TYPE_ALLOY when unspecified in create, update, upsert, and sync requests

PipelineSource

PipelineSource indicates the external source of a pipeline. Although the two fields type and namespace are optional, if type is specified, then namespace must also be specified. If type is set to SOURCE_TYPE_UNSPECIFIED, namespace must be an empty string. Requests that don’t follow these rules fail with a 400 BAD REQUEST validation error.

FieldTypeLabelDescription
typePipelineSource_SourceTypeoptionalSource of the pipeline
namespacestringoptionalNamespace of the pipeline

PipelineSource_SourceType

ValueDescription
SOURCE_TYPE_UNSPECIFIEDDefault value applied when source isn’t specified; don’t set this value manually
SOURCE_TYPE_GITThe pipeline originates from a Git workflow
SOURCE_TYPE_TERRAFORMThe pipeline originates from a Terraform workflow
SOURCE_TYPE_GRAFANAThe pipeline was created by an automated workflow in Grafana Cloud

UpdatePipelineRequest

UpdatePipelineRequest is the request to update an existing pipeline. Set pipeline.id to the ID of the pipeline to update. The pipeline supplied in this request replaces the existing configuration. Include all configuration fields you want to keep. If the pipeline doesn’t already exist, this request returns a 404 NOT FOUND error.

FieldTypeLabelDescription
pipelinePipelinerequiredContents of the pipeline to update
validate_onlybooloptionalIf set, validates the request and previews the response, but doesn’t update the actual resource

UpsertPipelineRequest

UpsertPipelineRequest is the request to create a new pipeline or update an existing one by name. Don’t set pipeline.id; Fleet Management uses pipeline.name to find the pipeline. If the pipeline already exists, Fleet Management replaces its configuration, as in an UpdatePipelineRequest. Include all configuration fields you want to keep.

FieldTypeLabelDescription
pipelinePipelinerequiredPipeline to create or update
validate_onlybooloptionalIf set, validates the request and previews the response, but doesn’t upsert the actual resource

ListPipelinesRevisionsRequest

ListPipelinesRevisionsRequest is the request to get a page of revisions across all pipelines, excluding contents. The response lists revisions newest first.

To get the next page, send the same request with page_token set to the next_page_token from the previous response. If you change filter, omit page_token and start again from the first page. Requests with an invalid page_token fail with a 400 BAD REQUEST error.

FieldTypeLabelDescription
page_tokenstringoptionalToken for the page to return; when empty, the first page is returned
page_sizeint32optionalMaximum number of revisions to return; defaults to 100 when unset or non-positive; capped at 500
filterListPipelinesRevisionsFilteroptionalFilters to apply to the results

ListPipelinesRevisionsFilter

ListPipelinesRevisionsFilter narrows down the revisions returned by ListPipelinesRevisionsRequest. The pipeline_name filter matches the name stored in each revision; later renames don’t change earlier revisions. When you set more than one field, a revision must match all of them. If you set both created_after and created_before, created_before must be later than created_after.

FieldTypeLabelDescription
pipeline_namestringoptionalReturns revisions whose pipeline name contains this value (case-insensitive); 100 character limit
pipeline_idstringoptionalReturns revisions of the pipeline with this ID; must be a string of digits (unsigned integer)
operationPipelineRevision.OperationoptionalReturns revisions with this operation; can’t be UNSPECIFIED
authorstringoptionalReturns revisions whose author contains this value (case-insensitive); 256 character limit
created_aftergoogle.protobuf.TimestampoptionalReturns revisions created at or after this time
created_beforegoogle.protobuf.TimestampoptionalReturns revisions created before this time

ListPipelinesRevisionsResponse

ListPipelinesRevisionsResponse is the response to listing revisions across all pipelines. The pipeline snapshot in each revision doesn’t include the pipeline contents.

FieldTypeLabelDescription
pipeline_revisionslist(PipelineRevision)List of pipeline revisions for the current page
next_page_tokenstringToken for the next page; empty when there are no more results

ListPipelineRevisionsRequest

ListPipelineRevisionsRequest is the request to retrieve a page of pipeline revisions by pipeline ID. The response lists revisions newest first. An unknown pipeline ID returns an empty list.

To get the next page, send the same request with page_token set to the next_page_token from the previous response. If you change id or filter, omit page_token and start again from the first page. Requests with an invalid page_token fail with a 400 BAD REQUEST error.

FieldTypeLabelDescription
idstringrequiredID of the pipeline to get; must be a string of digits (unsigned integer)
page_tokenstringoptionalToken for the page to return; when empty, the first page is returned
page_sizeint32optionalMaximum number of revisions to return; defaults to 100 when unset or non-positive; capped at 500
filterListPipelineRevisionsFilteroptionalFilters to apply to the results

ListPipelineRevisionsFilter

ListPipelineRevisionsFilter narrows down the revisions returned by ListPipelineRevisionsRequest. It accepts the same fields as ListPipelinesRevisionsFilter, except pipeline_name and pipeline_id.

FieldTypeLabelDescription
operationPipelineRevision.OperationoptionalReturns revisions with this operation; can’t be UNSPECIFIED
authorstringoptionalReturns revisions whose author contains this value (case-insensitive); 256 character limit
created_aftergoogle.protobuf.TimestampoptionalReturns revisions created at or after this time
created_beforegoogle.protobuf.TimestampoptionalReturns revisions created before this time

ListPipelineRevisionsResponse

ListPipelineRevisionsResponse is the response to listing the revisions of a single pipeline.

FieldTypeLabelDescription
pipeline_revisionslist(PipelineRevision)List of pipeline revisions for the current page
next_page_tokenstringToken for the next page; empty when there are no more results

GetPipelineRevisionRequest

GetPipelineRevisionRequest is the request to retrieve a pipeline revision by revision ID. If the revision doesn’t exist, the request returns a 404 NOT FOUND error.

FieldTypeLabelDescription
revision_idstringrequiredID of the pipeline revision to get; must be a string of digits (unsigned integer)

PipelineRevision

A PipelineRevision represents a point in time for a Pipeline. Revisions created without author context or before author tracking was available omit the author field.

FieldTypeLabelDescription
revision_idstringrequiredServer-assigned ID of the pipeline revision
snapshotPipelinerequiredThe pipeline at the point in time of the revision; metadata is always empty, and source, created_at, and updated_at are omitted
created_atgoogle.protobuf.TimestamprequiredTimestamp when the pipeline revision was created
operationPipelineRevision.OperationrequiredThe operation that was performed on the pipeline which created the revision
authorstringoptionalThe user associated with the request that created the revision, when available

PipelineRevision.Operation

ValueDescription
UNSPECIFIEDUnknown revision operation
INSERTThe pipeline was created at the time of this revision
UPDATEThe pipeline was updated at the time of this revision
DELETEThe pipeline was deleted at the time of this revision

SyncPipelinesRequest

SyncPipelinesRequest is the request to bulk update pipelines from a common source. Fleet Management creates pipelines that don’t exist and updates existing pipelines as it does for an UpsertPipelineRequest. Fleet Management deletes pipelines that have the same source type and namespace as the request’s source but aren’t in the request’s pipelines. It leaves pipelines with a different source or no source unchanged. The source must set a type other than SOURCE_TYPE_UNSPECIFIED and a non-empty namespace.

FieldTypeLabelDescription
sourcePipelineSourcerequiredSource of the pipeline(s)
pipelineslist(Pipeline)requiredList of pipelines

SyncPipelinesResponse

SyncPipelinesResponse is the response to bulk updating pipelines. This message is empty and the results of the sync are defined by the HTTP status code of the response. An HTTP status code of 400 indicates a validation error in the source field of the request or in one or more of the pipelines.

Examples

This section shows example requests and responses for the Pipeline API v2. For examples of SyncPipelines requests, refer to Sync configuration pipelines from a Git repository.

The examples use the following placeholders:

  • <INSTANCE_ID>: Your Grafana Cloud instance ID, which you can find on the API tab in the Fleet Management interface. The API uses it as the Basic Auth username.
  • <ACCESS_POLICY_TOKEN>: Your Grafana Cloud access policy token, which the API uses as the Basic Auth password.
  • <CLUSTER_NAME>: The production cluster of your stack, as described in the Find the base URL section. If your base URL uses the nested format, replace the whole host with the one from your base URL.
  • <PIPELINE_NAME>: The name of the pipeline to create or update.

Pipeline API requests and responses require proper escaping of the pipeline contents. For this reason, some use of jq is helpful. In this example, the contents of the pipeline are saved in a file named config.alloy:

Alloy
--- config.alloy ---
prometheus.exporter.self "alloy" { }

prometheus.scrape "alloy" {
  targets    = prometheus.exporter.self.alloy.targets
  forward_to = [prometheus.remote_write.grafanacloud.receiver]

  scrape_interval = "60s"
}

prometheus.remote_write "grafanacloud" {
  // Must match the uniquely-identifiable ID set up in the remotecfg block.
  external_labels = {"collector_id" = constants.hostname}

  endpoint {
    url = <SERVICE_URL>

    basic_auth {
      username      = <USERNAME>
      password_file = <PASSWORD_FILE>
    }
  }
}

In this file, <SERVICE_URL> is the remote write endpoint, <USERNAME> is the username for that endpoint, and <PASSWORD_FILE> is the path to a file that contains its password.

To build a payload for the CreatePipeline and UpsertPipeline requests with properly escaped content, the following command is a good starting point. It redirects the content to a create-pipeline.json file for easier handling:

shell
jq --arg contents "$(cat config.alloy)" \
   --arg name "<PIPELINE_NAME>" \
   --argjson matchers '["collector.os=linux", "team!=team-a"]' \
   --argjson enabled true \
   '.pipeline = {name: $name, contents: $contents, matchers: $matchers, enabled: $enabled}' \
   <<< '{}' > create-pipeline.json

To create the pipeline, send the payload in a CreatePipeline request:

shell
curl -q \
    -d @create-pipeline.json \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/CreatePipeline

The response shows what Fleet Management created, including the unique ID of the pipeline:

JSON
{
  "name": "myname",
  "contents": " ... pipeline contents ...",
  "matchers": [
    "collector.os=\"linux\"",
    "team!=\"team-a\""
  ],
  "enabled": true,
  "id": "22234",
  "metadata": {},
  "configType": "CONFIG_TYPE_ALLOY"
}

The ListPipelines request returns one page of pipelines. In this example, the request asks for enabled pipelines whose name contains pipeline, two at a time:

shell
curl -q \
    -d '{"page_size": 2, "filter": {"name": "pipeline", "enabled": true}}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/ListPipelines

The response includes a nextPageToken because more pipelines match the filter:

JSON
{
  "pipelines": [
    {
      "name": "pipeline_1",
      "contents": " ... pipeline contents ...",
      "matchers": [
        "team=\"team-a\""
      ],
      "createdAt": "2024-09-02T12:31:47Z",
      "updatedAt": "2024-09-02T14:08:10Z",
      "enabled": true,
      "id": "22231",
      "metadata": {},
      "configType": "CONFIG_TYPE_ALLOY"
    },
    {
      "name": "pipeline_2",
      "contents": " ... pipeline contents ...",
      "matchers": [
        "collector.os=\"darwin\""
      ],
      "createdAt": "2024-09-02T16:42:26Z",
      "updatedAt": "2024-09-02T16:42:26Z",
      "enabled": true,
      "id": "22235",
      "metadata": {},
      "configType": "CONFIG_TYPE_ALLOY"
    }
  ],
  "nextPageToken": "eyJwcmltYXJ5IjoicGlwZWxpbmVfMiJ9"
}

To get the next page, send the same request with page_token set to the nextPageToken from the previous response:

shell
curl -q \
    -d '{"page_size": 2, "filter": {"name": "pipeline", "enabled": true}, "page_token": "eyJwcmltYXJ5IjoicGlwZWxpbmVfMiJ9"}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/ListPipelines

The response for the last page omits nextPageToken:

JSON
{
  "pipelines": [
    {
      "name": "pipeline_3",
      "contents": " ... pipeline contents ...",
      "matchers": [
        "team=\"team-b\""
      ],
      "createdAt": "2024-09-03T08:15:02Z",
      "updatedAt": "2024-09-03T08:15:02Z",
      "enabled": true,
      "id": "22237",
      "metadata": {},
      "configType": "CONFIG_TYPE_ALLOY"
    }
  ]
}

The CountPipelines request accepts the same filter as ListPipelines and returns the number of matching pipelines:

shell
curl -q \
    -d '{"filter": {"name": "pipeline", "enabled": true}}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/CountPipelines

The response resembles the following:

JSON
{
  "count": 3
}

The GetMatchingPipelines request returns the pipelines that a collector with the given attributes receives. Use it to check which pipelines match a collector before you change its attributes:

shell
curl -q \
    -d '{"collector_id": "my-collector", "local_attributes": {"collector.os": "darwin"}, "remote_attributes": {"team": "team-b"}, "enabled": true}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/GetMatchingPipelines

The response resembles the following:

JSON
{
  "pipelines": [
    {
      "name": "pipeline_2",
      "contents": " ... pipeline contents ...",
      "matchers": [
        "collector.os=\"darwin\""
      ],
      "createdAt": "2024-09-02T16:42:26Z",
      "updatedAt": "2024-09-02T16:42:26Z",
      "enabled": true,
      "id": "22235",
      "metadata": {},
      "configType": "CONFIG_TYPE_ALLOY"
    },
    {
      "name": "pipeline_3",
      "contents": " ... pipeline contents ...",
      "matchers": [
        "team=\"team-b\""
      ],
      "createdAt": "2024-09-03T08:15:02Z",
      "updatedAt": "2024-09-03T08:15:02Z",
      "enabled": true,
      "id": "22237",
      "metadata": {},
      "configType": "CONFIG_TYPE_ALLOY"
    }
  ]
}

You can use a similar jq command to build an UpdatePipeline request redirected to update-pipeline.json, by adding the unique pipeline ID:

shell
jq --arg contents "$(cat config.alloy)" \
   --arg id "22234" \
   --arg name "<PIPELINE_NAME>" \
   --argjson matchers '["collector.os=linux", "team!=team-a"]' \
   --argjson enabled true \
   '.pipeline = {id: $id, name: $name, contents: $contents, matchers: $matchers, enabled: $enabled}' \
   <<< '{}' > update-pipeline.json

To update the pipeline, send the payload in an UpdatePipeline request:

shell
curl -q \
    -d @update-pipeline.json \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/UpdatePipeline

The response shows what Fleet Management updated:

JSON
{
  "name": "myname",
  "contents": " ... new pipeline contents ...",
  "matchers": [
    "collector.os=\"linux\"",
    "team!=\"team-a\""
  ],
  "enabled": true,
  "id": "22234",
  "metadata": {},
  "configType": "CONFIG_TYPE_ALLOY"
}

The GetPipeline and DeletePipeline requests require only an ID for accessing and removing a configuration. To get a pipeline, send a GetPipeline request with its ID:

shell
curl -q \
    -d '{"id": "22234"}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/GetPipeline

The response resembles the following:

JSON
{
  "name": "myname",
  "contents": "... pipeline contents ...",
  "matchers": [
    "collector.os=\"linux\"",
    "team!=\"team-a\""
  ],
  "createdAt": "2024-09-02T16:42:26Z",
  "updatedAt": "2024-09-02T16:42:26Z",
  "enabled": true,
  "id": "22234",
  "metadata": {},
  "configType": "CONFIG_TYPE_ALLOY"
}

To delete the pipeline, send a DeletePipeline request with its ID:

shell
curl -q \
    -d '{"id": "22234"}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/DeletePipeline

The response resembles the following:

JSON
{}

The BulkDeletePipelines endpoint allows you to delete multiple pipelines based on their IDs in a single request. This is useful when you need to clean up multiple pipelines at once. The operation is atomic. If any pipeline in the list doesn’t exist, the entire operation fails with a 404 NOT FOUND response and no pipelines are deleted. To delete three pipelines, send their IDs in a BulkDeletePipelines request:

shell
curl -q \
    -d '{"ids": ["22231", "22235", "22237"]}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/BulkDeletePipelines

The response is empty, and its 200 OK status means Fleet Management deleted all the pipelines:

JSON
{}

The BulkDeletePipelinesByFilter endpoint lets you delete every pipeline matching a filter without listing their IDs first. Before you delete, use ListPipelines with the same filter to review the matching pipelines, and CountPipelines to get the number of matches. Set expected_count to that number minus the pipelines you exclude. In this example, three disabled pipelines match the filter, and the request keeps one of them, 22240, by listing its ID in exclude_ids:

shell
curl -q \
    -d '{"filter": {"enabled": false}, "exclude_ids": ["22240"], "expected_count": 2}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/BulkDeletePipelinesByFilter

The response shows that Fleet Management deleted the two pipelines that weren’t excluded:

JSON
{
  "deletedCount": 2
}

If the number of matching pipelines changes before the request runs, the request fails and deletes nothing. In this example, a fourth pipeline matches the filter when the request runs:

shell
curl -q \
    -d '{"filter": {"enabled": false}, "expected_count": 3}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/BulkDeletePipelinesByFilter

The response is HTTP 400 with a failed_precondition error code.

The revision RPCs allow for revisiting the history of changes to pipeline objects for a user.

ListPipelinesRevisions lists all changes newest first alongside the operation that initiated them. For brevity, the response omits the configuration contents of the pipeline in each snapshot. You can filter the revisions by pipeline name or ID, operation, author, and creation time.

Similarly, ListPipelineRevisions allows for viewing the state of a single pipeline ID at every point in time it was changed, along with a snapshot that includes the pipeline contents. In both RPCs, the snapshot metadata is always empty. For details, refer to the PipelineRevision section.

In this example, the request asks for the two most recent revisions created by user_login:

shell
curl -q \
    -d '{"page_size": 2, "filter": {"author": "user_login"}}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/ListPipelinesRevisions

The response resembles the following:

JSON
{
  "pipelineRevisions": [
    {
      "revisionId": "4",
      "snapshot": {
        "name": "myname",
        "matchers": [
          "collector.os=\"linux\"",
          "team=\"team-a\""
        ],
        "enabled": true,
        "id": "1",
        "metadata": {},
        "configType": "CONFIG_TYPE_ALLOY"
      },
      "createdAt": "2025-02-14T09:38:55Z",
      "operation": "DELETE",
      "author": "user_login"
    },
    {
      "revisionId": "3",
      "snapshot": {
        "name": "myname",
        "matchers": [
          "collector.os=\"linux\"",
          "team=\"team-a\""
        ],
        "enabled": true,
        "id": "1",
        "metadata": {},
        "configType": "CONFIG_TYPE_ALLOY"
      },
      "createdAt": "2025-02-14T09:37:49Z",
      "operation": "UPDATE",
      "author": "user_login"
    }
  ],
  "nextPageToken": "eyJwcmltYXJ5IjoiMyJ9"
}

In this example, the request asks for the UPDATE revisions of the pipeline with ID 1:

shell
curl -q \
    -d '{"id": "1", "filter": {"operation": "UPDATE"}}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/ListPipelineRevisions

The response resembles the following:

JSON
{
  "pipelineRevisions": [
    {
      "revisionId": "3",
      "snapshot": {
        "name": "myname",
        "contents": "prometheus.exporter.self \"alloy\" { }\n\nprometheus.scrape \"alloy\" {\n\ttargets    = prometheus.exporter.self.alloy.targets\n\tforward_to = [prometheus.remote_write.grafanacloud.receiver]\n\n\tscrape_interval = \"60s\"\n}\n\nprometheus.remote_write \"grafanacloud\" {\n\t// Must match the uniquely-identifiable ID set up in the remotecfg block.\n\texternal_labels = {\"collector_id\" = constants.hostname}\n\n\tendpoint {\n\t\turl = \"http://localhost:8081\"\n\n\t\tbasic_auth {\n\t\t\tusername      = \"user\"\n\t\t\tpassword_file = \"/path/to/my/pass\"\n\t\t}\n\t}\n}",
        "matchers": [
          "collector.os=\"linux\"",
          "team=\"team-a\""
        ],
        "enabled": true,
        "id": "1",
        "metadata": {},
        "configType": "CONFIG_TYPE_ALLOY"
      },
      "createdAt": "2025-02-14T09:37:49Z",
      "operation": "UPDATE",
      "author": "user_login"
    }
  ]
}

The GetPipelineRevision request returns a single revision by its ID, including the contents of the pipeline at that point in time:

shell
curl -q \
    -d '{"revision_id": "4"}' \
    -u "<INSTANCE_ID>:<ACCESS_POLICY_TOKEN>" \
    --header "Content-Type: application/json" \
    -X POST https://fleet-management-<CLUSTER_NAME>.grafana.net/pipeline.v2.PipelineService/GetPipelineRevision

The response resembles the following:

JSON
{
  "revisionId": "4",
  "snapshot": {
    "name": "myname",
    "contents": "prometheus.exporter.self \"alloy\" { }\n\nprometheus.scrape \"alloy\" {\n\ttargets    = prometheus.exporter.self.alloy.targets\n\tforward_to = [prometheus.remote_write.grafanacloud.receiver]\n\n\tscrape_interval = \"60s\"\n}\n\nprometheus.remote_write \"grafanacloud\" {\n\t// Must match the uniquely-identifiable ID set up in the remotecfg block.\n\texternal_labels = {\"collector_id\" = constants.hostname}\n\n\tendpoint {\n\t\turl = \"http://localhost:8081\"\n\n\t\tbasic_auth {\n\t\t\tusername      = \"user\"\n\t\t\tpassword_file = \"/path/to/my/pass\"\n\t\t}\n\t}\n}",
    "matchers": [
      "collector.os=\"linux\"",
      "team=\"team-a\""
    ],
    "enabled": true,
    "id": "1",
    "metadata": {},
    "configType": "CONFIG_TYPE_ALLOY"
  },
  "createdAt": "2025-02-14T09:38:55Z",
  "operation": "DELETE",
  "author": "user_login"
}