Is there a way to do the equivalent of a map in workflows? #5331
Replies: 1 comment
-
|
Hi @knownasred! I'm Dosu and I’m helping the keep team. There isn’t a native “map” or aggregation operation in Keep workflows that lets you combine all elements of an array (like AlertDto objects) into a single variable for use in one action. The closest built-in feature is The Python provider can help with custom aggregation, but it receives AlertDto objects as string representations, so direct manipulation is limited unless you handle serialization yourself python provider code. A common workaround is to use a Python step to extract the fields you need from each alert, build a summary (like a list of dicts or a formatted string), and then pass that to your action for a single execution discussion. If you want to aggregate alert data, you’ll need to write Python code that parses the stringified AlertDto objects, extracts the relevant info, and combines it into your desired format. Then, reference the output variable in your action’s message. There’s no built-in YAML syntax for this, but it’s doable with a custom Python step. Let me know if you want an example of how to structure the Python code for this! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would love to have a way to combine inside of one variable each of the elements of the array generated by a
keepprovider alert search.Here's the current state of my setup, and I'm wondering of how to have a single execution of the console action (will be replaced by
discordwhen ready)Looking at the documentation, I cannot see a way to do it easily, and the python provider cannot consume the entire element due to it being wrapped in AlertDto:
Beta Was this translation helpful? Give feedback.
All reactions