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

Experimental Open source Community

pyroscope.enrich

Community: This component is developed, maintained, and supported by the Alloy user community. Grafana doesn’t offer commercial support for this component. To enable and use community components, you must set the --feature.community-components.enabled flag to true.

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 a label from incoming profiles against a label from discovered targets, and copies specified labels from the matched target to the profile.

Usage

Alloy
pyroscope.enrich "<LABEL>" {
  targets = <DISCOVERY_COMPONENT>.targets
  target_match_label = "<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_match_labelstringThe label from discovered targets to match against.yes
targetslist(Target)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
profiles_match_labelstringThe label from incoming profiles to match against discovered targets.no

If profiles_match_label isn’t provided, the component uses target_match_label for matching profile labels.

Blocks

pyroscope.enrich doesn’t support any blocks. 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.

Debug information

pyroscope.enrich doesn’t expose debug information.

Debug metrics

pyroscope.enrich doesn’t expose additional 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_match_label    = "pod_ip"
  profiles_match_label  = "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 value of profiles_match_label from the profile’s labels, or target_match_label if profiles_match_label isn’t specified.
  2. It matches this value against the target_match_label in discovered targets.
  3. When it finds a match, it copies the requested labels_to_copy from the discovered target to the profile. If labels_to_copy is empty, it copies all labels.
  4. The component forwards the profile, enriched or unchanged, to the configured receivers.

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.