Menu
Grafana Cloud
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:
alloy
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
Was this page helpful?
Related documentation
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video
Getting started with the Grafana LGTM Stack
In this webinar, we’ll demo how to get started using the LGTM Stack: Loki for logs, Grafana for visualization, Tempo for traces, and Mimir for metrics.
Video
Intro to Kubernetes monitoring in Grafana Cloud
In this webinar you’ll learn how Grafana offers developers and SREs a simple and quick-to-value solution for monitoring their Kubernetes infrastructure.
Video
Building advanced Grafana dashboards
In this webinar, we’ll demo how to build and format Grafana dashboards.