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.
Open source

declare block

declare is an optional configuration block used to define a new custom component. declare blocks must be given a label that determines the name of the custom component.


declare "COMPONENT_NAME" {


The declare block has no predefined schema for its arguments; the body of the declare block is used as the component definition. The body may contain:

The declare block may not contain any configuration blocks that are not listed above.

Exported fields

The declare block has no predefined schema for its exports; the fields exported by the declare block are determined by the export blocks found in its definition.


This example creates and uses a custom component that self-collects process metrics and forwards them to an argument specified by the user of the custom component:

declare "self_collect" {
  argument "metrics_output" {
    optional = false
    comment  = "Where to send collected metrics."

  prometheus.scrape "selfmonitor" {
    targets = [{
      __address__ = "",

    forward_to = [argument.metrics_output.value]

self_collect "example" {
  metrics_output = prometheus.remote_write.example.receiver

prometheus.remote_write "example" {
  endpoint {