Caution
Grafana Alloy is the new name for our distribution of the OTel collector. Grafana Agent has been deprecated and is in Long-Term Support (LTS) through October 31, 2025. Grafana Agent will reach an End-of-Life (EOL) on November 1, 2025. Read more about why we recommend migrating to Grafana Alloy.
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Custom components
Custom components are a way to create new components from a pipeline of built-in and other custom components.
A custom component is composed of:
- Arguments: Settings that configure the custom component.
- Exports: Values that a custom component exposes to its consumers.
- Components: Built-in and custom components that are run as part of the custom component.
Creating custom components
You can create a new custom component using the declare
configuration block.
The label of the block determines the name of the custom component.
The following custom configuration blocks can be used inside a declare
block:
- argument: Create a new named argument, whose current value can be referenced using the expression
argument.NAME.value
. Argument values are determined by the user of a custom component. - export: Expose a new named value to custom component users.
Custom components are useful for reusing a common pipeline multiple times. To learn how to share custom components across multiple files, refer to Modules.
Example
This example creates a new custom component called add
, which exports the sum of two arguments:
declare "add" {
argument "a" { }
argument "b" { }
export "sum" {
value = argument.a.value + argument.b.value
}
}
add "example" {
a = 15
b = 17
}
// add.example.sum == 32