-
Notifications
You must be signed in to change notification settings - Fork 250
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
Dynamic pipelines - a new foreach
block
#1480
base: main
Are you sure you want to change the base?
Conversation
I really like the idea of it being component based. I am comparing to terraform's for_each, where you make a "template" resource and have an argument in there which tells it how to expand it into multiple components:
I really like the notion that this is a single component that would be "expanded" based on the evaluation of some list. It could be a built-in component or a previously imported dynamic component. I am not sure how naming of the expanded components would work, but we could figure something out. I'm also not sure if it is possible to reference a dynamically created subcomponent from elsewhere in the config. |
This PR has not had any activity in the past 30 days, so the |
It looks likely that we are going to go with the As a second step, we will need to figure out how to refer to the values that are currently iterated on. Should we actually have a By the way, apparently the Collector already has something like dynamic pipelines. There are observer extensions which you can hook up to a recover creator component. For example, you can have a k8s observer which crates a receiver for each discovered pod. |
dd602e6
to
378cb04
Compare
378cb04
to
cc02bfc
Compare
d8b2547
to
d1591b1
Compare
e8cd817
to
8217e86
Compare
b041704
to
421204a
Compare
💻 Deploy preview available: https://deploy-preview-alloy-1480-zb444pucvq-vp.a.run.app/docs/alloy/latest/ |
foreach
block
* summation1 only sends during run() * summation2 tracks the sum via metrics instead of an export
* add stability lvl to config blocks * fix import git test
* Add tests for types other than integers * Minor fixes to string_receiver * Add a foreach test for maps which contain maps
* Add docs for foreach * Apply suggestions from code review Co-authored-by: Clayton Cornell <[email protected]> * Add a shared experimental_feature snippet * Addressing PR feedback * Apply suggestions from code review Co-authored-by: William Dumont <[email protected]> --------- Co-authored-by: Clayton Cornell <[email protected]> Co-authored-by: William Dumont <[email protected]>
e16e3e3
to
417bd4d
Compare
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.
Fantastic work, gave it a first review and will go over it again. Added some comments on tests.
{{< /collapse >}} | ||
|
||
You can use a `foreach` to loop over each target and start a separate component pipeline for it. | ||
The following example configuration shows how a `prometheus.exporter.redis` instance is started for each Redis instance discoverd by `discovery.kubernetes`. |
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.
nit: typo in discoverd
) | ||
|
||
func TestCreateCustomComponents(t *testing.T) { | ||
config := `foreach "default" { |
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.
Do we have any tests for non arrayable value? Ie a single number collection = 1
or the behavior on collection = "foo"
? I assume we would not treat it as a char arrya but unsure the behavior.
case float64: | ||
// Dots are not valid characters in Alloy syntax identifiers. | ||
// For example, "foreach_3.14_1" should become "foreach_3_14_1". | ||
return strings.Replace(fmt.Sprintf("%f", v), ".", "_", -1) |
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.
Is this bypassing our normal attribute rules, I feel there are more rules there. IE we only support A-Z.
} | ||
|
||
func (fi *forEachChild) Equals(other runner.Task) bool { | ||
return fi.id == other.(*forEachChild).id |
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.
Do we need a check here? If other is non forEachChild this will panic.
) | ||
|
||
func TestForeach(t *testing.T) { | ||
directory := "./testdata/foreach" |
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.
I dont think I saw a test for iterating over an array of capsule values. collection = [prometheus.remote_write.d1,prometheus.remote_write.d2]
, now why would I do that, no idea but we should know what the behavior is.
PR Description
This is a proposal for starting up Alloy pipelines dynamically based on data in transit. For example, if a
discovery
component comes up with 10 targets, Alloy can start 10 sub-pipelines, each dealing with a different target.The PR consists of a a design doc in
docs/design/
and an experimental implementation. The user will have to have the "experimental" cmd flag turned on.Which issue(s) this PR fixes
Fixes #1443