---
title: "Custom components | Grafana Agent documentation"
description: "Learn about custom components"
---

# 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](../../reference/config-blocks/declare/). 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](../../reference/config-blocks/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](../../reference/config-blocks/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](../modules/).

## Example

This example creates a new custom component called `add`, which exports the sum of two arguments:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```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
```
