This is documentation for the next version of Grafana Alloy Documentation. For the latest stable release, go to the latest version.

Experimental Open source
Last reviewed: October 1, 2026

pyroscope.enrich

EXPERIMENTAL: This is an experimental component. Experimental components are subject to frequent breaking changes, and may be removed with no equivalent replacement. To enable and use an experimental component, you must set the stability.level flag to experimental.

pyroscope.enrich enriches profiles with additional labels from service discovery targets. It matches labels from incoming profiles against labels from discovered targets, and copies specified labels from the matched target to the profile. If no target matches, the component forwards the profile unchanged.

Use the target_to_profile_match argument to specify which target labels correspond to which profile labels. The map keys are target label names and the values are the corresponding profile label names. All labels in the map must match for enrichment to occur.

You can specify multiple pyroscope.enrich components by giving them different labels.

Usage

Alloy
pyroscope.enrich "<LABEL>" {
  targets = <DISCOVERY_COMPONENT>.targets

  target_to_profile_match = {
    "<TARGET_LABEL_1>" = "<PROFILE_LABEL_1>",
    "<TARGET_LABEL_2>" = "<PROFILE_LABEL_2>",
  }

  labels_to_copy = ["<LABEL>", ...]

  forward_to = [<RECEIVER_LIST>]
}

Arguments

You can use the following arguments with pyroscope.enrich:

NameTypeDescriptionDefaultRequired
forward_tolist(ProfilesReceiver)List of receivers to send enriched profiles to.yes
target_to_profile_matchmap(string)Map of target label names to profile label names. All entries must match for enrichment.yes
targetslist(map(string))List of targets from a discovery component.yes
labels_to_copylist(string)List of labels to copy from discovered targets to profiles. If empty, all labels are copied.no

The target_to_profile_match map must contain at least one entry. The keys and values can’t be empty strings.

Blocks

pyroscope.enrich doesn’t support any blocks. You can configure this component with arguments.

Exported fields

The following fields are exported and can be referenced by other components:

NameTypeDescription
receiverProfilesReceiverThe receiver for profiles.

Component health

pyroscope.enrich is only reported as unhealthy if given an invalid configuration. In those cases, exported fields retain their last healthy values.

Debug information

pyroscope.enrich doesn’t expose any component-specific debug information.

Debug metrics

pyroscope.enrich doesn’t expose any component-specific debug metrics.

Example

This example enriches profiles received over HTTP with metadata from Kubernetes service discovery:

Alloy
// Discover Kubernetes pods
discovery.kubernetes "pods" {
  role = "pod"
}

// Add custom labels from Kubernetes metadata
discovery.relabel "pods" {
  targets = discovery.kubernetes.pods.targets

  rule {
    source_labels = ["__meta_kubernetes_namespace"]
    target_label  = "namespace"
  }

  rule {
    source_labels = ["__meta_kubernetes_pod_node_name"]
    target_label  = "node"
  }

  rule {
    source_labels = ["__meta_kubernetes_pod_label_app"]
    target_label  = "app"
  }

  rule {
    source_labels = ["__meta_kubernetes_pod_label_environment"]
    target_label  = "environment"
  }

  rule {
    source_labels = ["__meta_kubernetes_pod_ip"]
    target_label  = "pod_ip"
  }
}

// Receive profiles over HTTP
pyroscope.receive_http "default" {
  http {
    listen_address = "0.0.0.0"
    listen_port    = 4040
  }
  forward_to = [pyroscope.enrich.metadata.receiver]
}

// Enrich profiles with Kubernetes metadata
pyroscope.enrich "metadata" {
  targets = discovery.relabel.pods.output

  target_to_profile_match = {
    "pod_ip" = "service_name",
  }

  labels_to_copy = ["namespace", "node", "app", "environment"]
  forward_to     = [pyroscope.write.default.receiver]
}

// Write profiles to Pyroscope
pyroscope.write "default" {
  endpoint {
    url = "http://pyroscope:4040"
  }
}

Component behavior

The component matches profiles to discovered targets and enriches them with additional labels:

  1. For each profile, it looks up the profile labels specified by target_to_profile_match.
  2. It matches those values against the corresponding target labels. All label pairs must match the same target.
  3. If a match is found, it copies the requested labels_to_copy from the discovered target to the profile. If labels_to_copy is empty, all labels are copied.
  4. The component forwards the profile, enriched or unchanged, to the configured receivers.

The component handles the following cases:

  • If no target matches a profile, the component forwards the profile unchanged.
  • If a profile is missing any of the labels in target_to_profile_match, or any of those labels has an empty value, the component forwards the profile unchanged.
  • If a target is missing any of the matching labels, or any of them has an empty value, the component ignores that target.
  • If multiple targets have the same values for all matching labels, the component uses the last of those targets in the targets list. The discovery component determines the order of targets, and the order can change between updates. To get predictable results, make sure the matching labels identify a single target.

Caution

By default, pyroscope.enrich is ready as it starts, even if discovery doesn’t find targets. If you send profiles to this component before the metadata synchronizes, the component passes them through as-is, without enrichment. This is most likely to impact pyroscope.enrich on startup for a short time before discovery components send a list of targets.

Compatible components

pyroscope.enrich can accept arguments from the following components:

pyroscope.enrich has exports that can be consumed by the following components:

Note

Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. Refer to the linked documentation for more details.