Need assistance for using for_each #2981
Replies: 2 comments 2 replies
-
Hey @anvithpotluri 👋 I think it might be easier if you share some sample input and desired output. Otherwise, my best guess is that you just need to use bloblang. For example, if you have this input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Try this mapping: root.values = this
root.timestamps = range(0, this.length()).map_each(i -> i * 10) Alternatively, The root.values = this
root.timestamps = this.fold({"timestamps": [], "index": 0}, v -> {"timestamps": v.tally.timestamps.append(10 * v.tally.index), "index": v.tally.index + 1}).timestamps |
Beta Was this translation helpful? Give feedback.
-
Here is my full Pipeline. the important fields from the input are metric, dataTS, and a valueArray. The first value in the valueArray needs to correspond to the dataTS and each value after corresponds to the dataTS + (index * 10). This is how I want to fill out my values and timestamps. EDIT: writing this out makes me realize the lack of need of a for loop. All I would need to do is make an array with the length of the values, and then have this array filled out with timestamps with each being 10 greater than the last.
|
Beta Was this translation helpful? Give feedback.
-
part of my code is below. I have grabbed an array of 100 values and want to iterate and add them to my timestamp and values arrays. I get the error: "expected array value" when I try this code. Am I doing something wrong with the foreach section?
Beta Was this translation helpful? Give feedback.
All reactions