Pipeline attribute injection
Pipelines in Grafana Fleet Management can inject variable collector attribute values into their configuration. This powerful feature enables you to create dynamic configurations that adapt to each collector’s characteristics, reducing the need for multiple similar pipelines.
How it works
When a collector registers with Fleet Management, it can have various attributes assigned to it, such as environment type, department, or location.
These attributes can be injected into configuration pipelines using the syntax argument.attributes.value["ATTRIBUTE_KEY"]
.
This feature allows you to:
- Create a single pipeline that works across different environments.
- Dynamically set labels based on collector attributes.
- Reduce the number of pipelines needed to manage your fleet.
- Make configurations more maintainable and scalable.
Example: Label metrics with collector attributes
In this example, we create a pipeline that adds labels to metrics based on collector attributes. Labeling helps you organize and filter metrics in Grafana Cloud.
Consider a fleet of collectors that each have these attributes:
env
: The environment such asTEST
,STAGING
,PROD
.department
: The internal department name such asBILLING
,ENGINEERING
,WEBAPPS
.collector.ID
: A unique identifier for each collector.
The following pipeline demonstrates how to inject these attributes as labels:
This configuration:
- Discovers Kubernetes pods using the hostname.
- Adds three labels to the metrics:
env
: Set to the collector’s environment attribute.department
: Set to the collector’s department attribute.collector_id
: Set to the collector’s unique ID.
- Scrapes the metrics and forwards them to Grafana Cloud.
Note
The
collector.ID
attribute is automatically assigned to each collector. You can modify the value of this attribute by overriding the value of theid
argument in the collector’sremotecfg
block, but you cannot edit the attribute key or modify the key-value pair from the Fleet Management UI. This unique ID is useful for tracking metrics back to specific collectors in your fleet.