Skip to content

Commit cc7448f

Browse files
AndreZivianiclayton-cornelldehaansa
authored
feat: pyroscope.enrich component (#4797)
* feat: pyroscope.enrich component * chore: Improve docs Co-authored-by: Clayton Cornell <[email protected]> --------- Co-authored-by: Clayton Cornell <[email protected]> Co-authored-by: Sam DeHaan <[email protected]>
1 parent 44e923d commit cc7448f

File tree

11 files changed

+594
-0
lines changed

11 files changed

+594
-0
lines changed

.github/ISSUE_TEMPLATE/blank.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ body:
181181
- prometheus.scrape
182182
- prometheus.write.queue
183183
- pyroscope.ebpf
184+
- pyroscope.enrich
184185
- pyroscope.java
185186
- pyroscope.receive_http
186187
- pyroscope.relabel

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ body:
181181
- prometheus.scrape
182182
- prometheus.write.queue
183183
- pyroscope.ebpf
184+
- pyroscope.enrich
184185
- pyroscope.java
185186
- pyroscope.receive_http
186187
- pyroscope.relabel

.github/ISSUE_TEMPLATE/docs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ body:
184184
- prometheus.scrape
185185
- prometheus.write.queue
186186
- pyroscope.ebpf
187+
- pyroscope.enrich
187188
- pyroscope.java
188189
- pyroscope.receive_http
189190
- pyroscope.relabel

.github/ISSUE_TEMPLATE/feature_request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ body:
181181
- prometheus.scrape
182182
- prometheus.write.queue
183183
- pyroscope.ebpf
184+
- pyroscope.enrich
184185
- pyroscope.java
185186
- pyroscope.receive_http
186187
- pyroscope.relabel

.github/ISSUE_TEMPLATE/proposal.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ body:
181181
- prometheus.scrape
182182
- prometheus.write.queue
183183
- pyroscope.ebpf
184+
- pyroscope.enrich
184185
- pyroscope.java
185186
- pyroscope.receive_http
186187
- pyroscope.relabel

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ Main (unreleased)
1313
### Features
1414

1515
- A new `mimir.alerts.kubernetes` component which discovers `AlertmanagerConfig` Kubernetes resources and loads them into a Mimir instance. (@ptodev)
16+
1617
- Mark `stage.windowsevent` block in the `loki.process` component as GA. (@kgeckhart)
1718

19+
- (_Experimental_) Add `pyroscope.enrich` component to enrich profiles using labels from `discovery.*` components. (@AndreZiviani)
20+
1821
### Enhancements
1922

2023
- update promtail converter to use `file_match` block for `loki.source.file` instead of going through `local.file_match`. (@kalleep)
@@ -95,6 +98,7 @@ v1.12.0-rc.0
9598
- The `otelcol.processor.servicegraph` component now supports defining the maximum number of buckets for generated exponential histograms.
9699
- See the upstream [core][https://github.com/open-telemetry/opentelemetry-collector/blob/v0.139.0/CHANGELOG.md] and [contrib][https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.139.0/CHANGELOG.md] changelogs for more details.
97100

101+
98102
### Enhancements
99103

100104
- Add per-application rate limiting with the `strategy` attribute in the `faro.receiver` component, to prevent one application from consuming the rate limit quota of others. (@hhertout)

docs/sources/reference/compatibility/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ The following components, grouped by namespace, _consume_ Targets.
159159

160160
{{< collapse title="pyroscope" >}}
161161
- [pyroscope.ebpf](../components/pyroscope/pyroscope.ebpf)
162+
- [pyroscope.enrich](../components/pyroscope/pyroscope.enrich)
162163
- [pyroscope.java](../components/pyroscope/pyroscope.java)
163164
- [pyroscope.scrape](../components/pyroscope/pyroscope.scrape)
164165
{{< /collapse >}}
@@ -422,6 +423,7 @@ The following components, grouped by namespace, _export_ Pyroscope `ProfilesRece
422423
<!-- START GENERATED SECTION: EXPORTERS OF Pyroscope `ProfilesReceiver` -->
423424

424425
{{< collapse title="pyroscope" >}}
426+
- [pyroscope.enrich](../components/pyroscope/pyroscope.enrich)
425427
- [pyroscope.relabel](../components/pyroscope/pyroscope.relabel)
426428
- [pyroscope.write](../components/pyroscope/pyroscope.write)
427429
{{< /collapse >}}
@@ -437,6 +439,7 @@ The following components, grouped by namespace, _consume_ Pyroscope `ProfilesRec
437439

438440
{{< collapse title="pyroscope" >}}
439441
- [pyroscope.ebpf](../components/pyroscope/pyroscope.ebpf)
442+
- [pyroscope.enrich](../components/pyroscope/pyroscope.enrich)
440443
- [pyroscope.java](../components/pyroscope/pyroscope.java)
441444
- [pyroscope.receive_http](../components/pyroscope/pyroscope.receive_http)
442445
- [pyroscope.relabel](../components/pyroscope/pyroscope.relabel)
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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 -->

internal/component/all/all.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ import (
164164
_ "github.com/grafana/alloy/internal/component/prometheus/scrape" // Import prometheus.scrape
165165
_ "github.com/grafana/alloy/internal/component/prometheus/write/queue" // Import prometheus.write.queue
166166
_ "github.com/grafana/alloy/internal/component/pyroscope/ebpf" // Import pyroscope.ebpf
167+
_ "github.com/grafana/alloy/internal/component/pyroscope/enrich" // Import pyroscope.enrich
167168
_ "github.com/grafana/alloy/internal/component/pyroscope/java" // Import pyroscope.java
168169
_ "github.com/grafana/alloy/internal/component/pyroscope/receive_http" // Import pyroscope.receive_http
169170
_ "github.com/grafana/alloy/internal/component/pyroscope/relabel" // Import pyroscope.relabel

0 commit comments

Comments
 (0)