-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyroscope: Add relabel component for modifying and filtering profiles #2574
Merged
+984
−20
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9dea672
feat(pyroscope): add relabel component
marcsanmi 8241435
Add IncomProfile Labels field & address other minor PR suggestions
marcsanmi 6d37eb8
update docs & test race
marcsanmi 21fd697
Address PR suggestions
marcsanmi 142b681
Apply suggestions from code review
marcsanmi cf27661
Add public preview span & address docs suggestions
marcsanmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
docs/sources/reference/components/pyroscope/pyroscope.relabel.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
--- | ||
canonical: https://grafana.com/docs/alloy/latest/reference/components/pyroscope/pyroscope.relabel/ | ||
aliases: | ||
- ../pyroscope.relabel/ # /docs/alloy/latest/reference/components/pyroscope.relabel/ | ||
description: Learn about pyroscope.relabel | ||
title: pyroscope.relabel | ||
--- | ||
|
||
# pyroscope.relabel | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The `pyroscope.relabel` component rewrites the label set of each profile passed to its receiver by applying one or more relabeling `rule`s and forwards the results to the list of receivers in the component's arguments. | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If no rules are defined or applicable to some profiles, then those profiles are forwarded as-is to each receiver passed in the component's arguments. If no labels remain after the relabeling rules are applied, then the profile is dropped. | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The most common use of `pyroscope.relabel` is to filter profiles or standardize the label set that is passed to one or more downstream receivers. The `rule` blocks are applied to the label set of each profile in order of their appearance in the configuration file. | ||
|
||
## Usage | ||
|
||
```alloy | ||
pyroscope.relabel "process" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this label be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's better. Updated in cf27661. |
||
forward_to = RECEIVER_LIST | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
rule { | ||
... | ||
} | ||
|
||
... | ||
} | ||
``` | ||
|
||
## Arguments | ||
|
||
The following arguments are supported: | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
| Name | Type | Description | Default | Required | | ||
| ---- | ---- | ----------- | ------- | -------- | | ||
| `forward_to` | `list(pyroscope.Appendable)` | List of receivers to forward profiles to after relabeling | | yes | | ||
| `max_cache_size` | `number` | Maximum number of entries in the label cache | 10000 | no | | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Blocks | ||
|
||
The following blocks are supported inside the definition of `pyroscope.relabel`: | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Hierarchy | Name | Description | Required | ||
----------|----------|----------------------------------------------------|--------- | ||
rule | [rule][] | Relabeling rules to apply to received log entries. | no | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[rule]: #rule-block | ||
|
||
### rule block | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{{< docs/shared lookup="reference/components/rule-block-logs.md" source="alloy" version="<ALLOY_VERSION>" >}} | ||
|
||
## Exported fields | ||
|
||
The following fields are exported and can be referenced by other components: | ||
|
||
Name | Type | Description | ||
-----|------|------------ | ||
`receiver` | `ProfilesReceiver` | A receiver that accepts profiles for relabeling. | ||
`rules` | `[]relabel.Config` | The list of relabeling rules. | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Component health | ||
|
||
`pyroscope.relabel` is reported as unhealthy if it is given an invalid configuration. | ||
|
||
## Debug metrics | ||
|
||
* `pyroscope_relabel_profiles_dropped` (counter): Total number of profiles dropped by relabeling rules. | ||
* `pyroscope_relabel_profiles_processed` (counter): Total number of profiles processed. | ||
* `pyroscope_relabel_profiles_written` (counter): Total number of profiles forwarded. | ||
* `pyroscope_relabel_cache_misses` (counter): Total number of cache misses. | ||
* `pyroscope_relabel_cache_hits` (counter): Total number of cache hits. | ||
* `pyroscope_relabel_cache_size` (gauge): Total size of relabel cache. | ||
marcsanmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Example | ||
|
||
```alloy | ||
simonswine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pyroscope.relabel "process" { | ||
forward_to = [pyroscope.write.backend.receiver] | ||
|
||
# Rules are applied in order | ||
rule { | ||
source_labels = ["env"] | ||
target_label = "environment" | ||
action = "replace" | ||
regex = "(.)" | ||
replacement = "$1" | ||
} | ||
|
||
rule { | ||
action = "labeldrop" | ||
regex = "env" | ||
} | ||
} | ||
``` | ||
|
||
<!-- START GENERATED COMPATIBLE COMPONENTS --> | ||
## Compatible components | ||
|
||
`pyroscope.relabel` can accept arguments from the following components: | ||
|
||
- Components that export [Pyroscope `ProfilesReceiver`](../../../compatibility/#pyroscope-profilesreceiver-exporters) | ||
|
||
`pyroscope.relabel` has exports that can be consumed by the following components: | ||
|
||
- Components that consume [Pyroscope `ProfilesReceiver`](../../../compatibility/#pyroscope-profilesreceiver-consumers) | ||
|
||
{{< admonition type="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. | ||
{{< /admonition >}} | ||
|
||
<!-- END GENERATED COMPATIBLE COMPONENTS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package relabel | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
type metrics struct { | ||
profilesProcessed prometheus.Counter | ||
profilesOutgoing prometheus.Counter | ||
profilesDropped prometheus.Counter | ||
cacheHits prometheus.Counter | ||
cacheMisses prometheus.Counter | ||
cacheSize prometheus.Gauge | ||
} | ||
|
||
func newMetrics(reg prometheus.Registerer) *metrics { | ||
m := &metrics{ | ||
profilesProcessed: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "pyroscope_relabel_profiles_processed", | ||
Help: "Total number of profiles processed", | ||
}), | ||
profilesOutgoing: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "pyroscope_relabel_profiles_written", | ||
Help: "Total number of profiles forwarded", | ||
}), | ||
profilesDropped: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "pyroscope_relabel_profiles_dropped", | ||
Help: "Total number of profiles dropped by relabeling rules", | ||
}), | ||
cacheHits: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "pyroscope_relabel_cache_hits", | ||
Help: "Total number of cache hits", | ||
}), | ||
cacheMisses: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Name: "pyroscope_relabel_cache_misses", | ||
Help: "Total number of cache misses", | ||
}), | ||
cacheSize: prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Name: "pyroscope_relabel_cache_size", | ||
Help: "Total size of relabel cache", | ||
}), | ||
} | ||
|
||
reg.MustRegister( | ||
m.profilesProcessed, | ||
m.profilesOutgoing, | ||
m.profilesDropped, | ||
m.cacheHits, | ||
m.cacheMisses, | ||
m.cacheSize, | ||
) | ||
|
||
return m | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What stage are we releasing this as.. GA? Preview? Experimental?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the "Public Preview" span in cf27661, thanks.