|
| 1 | +--- |
| 2 | +canonical: https://grafana.com/docs/alloy/latest/reference/components/pyroscope/pyroscope.enrich/ |
| 3 | +description: Learn about pyroscope.enrich |
| 4 | +labels: |
| 5 | + stage: experimental |
| 6 | + products: |
| 7 | + - oss |
| 8 | + tags: |
| 9 | + - text: Community |
| 10 | + tooltip: This component is developed, maintained, and supported by the Alloy user community. |
| 11 | +title: pyroscope.enrich |
| 12 | +--- |
| 13 | + |
| 14 | +# `pyroscope.enrich` |
| 15 | + |
| 16 | +{{< docs/shared lookup="stability/community.md" source="alloy" version="<ALLOY_VERSION>" >}} |
| 17 | + |
| 18 | +{{< docs/shared lookup="stability/experimental.md" source="alloy" version="<ALLOY_VERSION>" >}} |
| 19 | + |
| 20 | +`pyroscope.enrich` enriches profiles with additional labels from service discovery targets. |
| 21 | +It matches a label from incoming profiles against a label from discovered targets, and copies specified labels from the matched target to the profile. |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +```alloy |
| 26 | +pyroscope.enrich "<LABEL>" { |
| 27 | + targets = <DISCOVERY_COMPONENT>.targets |
| 28 | + target_match_label = "<LABEL>" |
| 29 | + forward_to = [<RECEIVER_LIST>] |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +## Arguments |
| 34 | + |
| 35 | +You can use the following arguments with `pyroscope.enrich`: |
| 36 | + |
| 37 | +| Name | Type | Description | Default | Required | |
| 38 | +| ---------------------- | ------------------------ | --------------------------------------------------------------------------------------------- | ------- | -------- | |
| 39 | +| `forward_to` | `list(ProfilesReceiver)` | List of receivers to send enriched profiles to. | | yes | |
| 40 | +| `target_match_label` | `string` | The label from discovered targets to match against. | | yes | |
| 41 | +| `targets` | `list(Target)` | List of targets from a discovery component. | | yes | |
| 42 | +| `labels_to_copy` | `list(string)` | List of labels to copy from discovered targets to profiles. If empty, all labels are copied. | | no | |
| 43 | +| `profiles_match_label` | `string` | The label from incoming profiles to match against discovered targets. | | no | |
| 44 | + |
| 45 | +If `profiles_match_label` isn't provided, the component uses `target_match_label` for matching profile labels. |
| 46 | + |
| 47 | +## Blocks |
| 48 | + |
| 49 | +`pyroscope.enrich` doesn't support any blocks. |
| 50 | +Configure this component with arguments. |
| 51 | + |
| 52 | +## Exported fields |
| 53 | + |
| 54 | +The following fields are exported and can be referenced by other components: |
| 55 | + |
| 56 | +| Name | Type | Description | |
| 57 | +| ---------- | -------------------- | ----------------------------------- | |
| 58 | +| `receiver` | `ProfilesReceiver` | The receiver for profiles. | |
| 59 | + |
| 60 | +## Component health |
| 61 | + |
| 62 | +`pyroscope.enrich` is only reported as unhealthy if given an invalid configuration. |
| 63 | + |
| 64 | +## Debug information |
| 65 | + |
| 66 | +`pyroscope.enrich` doesn't expose debug information. |
| 67 | + |
| 68 | +## Debug metrics |
| 69 | + |
| 70 | +`pyroscope.enrich` doesn't expose additional metrics. |
| 71 | + |
| 72 | +## Example |
| 73 | + |
| 74 | +This example enriches profiles received over HTTP with metadata from Kubernetes service discovery: |
| 75 | + |
| 76 | +```alloy |
| 77 | +// Discover Kubernetes pods |
| 78 | +discovery.kubernetes "pods" { |
| 79 | + role = "pod" |
| 80 | +} |
| 81 | +
|
| 82 | +// Add custom labels from Kubernetes metadata |
| 83 | +discovery.relabel "pods" { |
| 84 | + targets = discovery.kubernetes.pods.targets |
| 85 | + |
| 86 | + rule { |
| 87 | + source_labels = ["__meta_kubernetes_namespace"] |
| 88 | + target_label = "namespace" |
| 89 | + } |
| 90 | + |
| 91 | + rule { |
| 92 | + source_labels = ["__meta_kubernetes_pod_node_name"] |
| 93 | + target_label = "node" |
| 94 | + } |
| 95 | + |
| 96 | + rule { |
| 97 | + source_labels = ["__meta_kubernetes_pod_label_app"] |
| 98 | + target_label = "app" |
| 99 | + } |
| 100 | + |
| 101 | + rule { |
| 102 | + source_labels = ["__meta_kubernetes_pod_label_environment"] |
| 103 | + target_label = "environment" |
| 104 | + } |
| 105 | + |
| 106 | + rule { |
| 107 | + source_labels = ["__meta_kubernetes_pod_ip"] |
| 108 | + target_label = "pod_ip" |
| 109 | + } |
| 110 | +} |
| 111 | +
|
| 112 | +// Receive profiles over HTTP |
| 113 | +pyroscope.receive_http "default" { |
| 114 | + http { |
| 115 | + listen_address = "0.0.0.0" |
| 116 | + listen_port = 4040 |
| 117 | + } |
| 118 | + forward_to = [pyroscope.enrich.metadata.receiver] |
| 119 | +} |
| 120 | +
|
| 121 | +// Enrich profiles with Kubernetes metadata |
| 122 | +pyroscope.enrich "metadata" { |
| 123 | + targets = discovery.relabel.pods.output |
| 124 | + target_match_label = "pod_ip" |
| 125 | + profiles_match_label = "service_name" |
| 126 | + labels_to_copy = ["namespace", "node", "app", "environment"] |
| 127 | + forward_to = [pyroscope.write.default.receiver] |
| 128 | +} |
| 129 | +
|
| 130 | +// Write profiles to Pyroscope |
| 131 | +pyroscope.write "default" { |
| 132 | + endpoint { |
| 133 | + url = "http://pyroscope:4040" |
| 134 | + } |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +## Component behavior |
| 139 | + |
| 140 | +The component matches profiles to discovered targets and enriches them with additional labels: |
| 141 | + |
| 142 | +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. |
| 143 | +1. It matches this value against the `target_match_label` in discovered targets. |
| 144 | +1. 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. |
| 145 | +1. The component forwards the profile, enriched or unchanged, to the configured receivers. |
| 146 | + |
| 147 | +{{< admonition type="caution" >}} |
| 148 | +By default, `pyroscope.enrich` is ready as it starts, even if discovery doesn't find targets. |
| 149 | +If you send profiles to this component before the metadata synchronizes, the component passes them through as-is, without enrichment. |
| 150 | +This is most likely to impact `pyroscope.enrich` on startup for a short time before discovery components send a list of targets. |
| 151 | +{{< /admonition >}} |
| 152 | + |
| 153 | +<!-- START GENERATED COMPATIBLE COMPONENTS --> |
| 154 | + |
| 155 | +## Compatible components |
| 156 | + |
| 157 | +`pyroscope.enrich` can accept arguments from the following components: |
| 158 | + |
| 159 | +- Components that export [Targets](../../../compatibility/#targets-exporters) |
| 160 | +- Components that export [Pyroscope `ProfilesReceiver`](../../../compatibility/#pyroscope-profilesreceiver-exporters) |
| 161 | + |
| 162 | +`pyroscope.enrich` has exports that can be consumed by the following components: |
| 163 | + |
| 164 | +- Components that consume [Pyroscope `ProfilesReceiver`](../../../compatibility/#pyroscope-profilesreceiver-consumers) |
| 165 | + |
| 166 | +{{< admonition type="note" >}} |
| 167 | +Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. |
| 168 | +Refer to the linked documentation for more details. |
| 169 | +{{< /admonition >}} |
| 170 | + |
| 171 | +<!-- END GENERATED COMPATIBLE COMPONENTS --> |
0 commit comments