Describe the problem/error/question
I have a prometheus node which I run a query against to fetch the status of blackbox probes.
The result is a json file.
The next is an example of the json file:
[
{
"status": "success",
"data": {
"resultType": "vector",
"result": [
{
"metric": {
"__name__": "probe_success",
"hostname": "1.ngtech.home",
"instance": "1.ngtech.home",
"job": "blackbox-icmp",
"target_type": "blackbox-icmp"
},
"value": [
1734140895.644,
"0"
]
},
{
"metric": {
"__name__": "probe_success",
"hostname": "2.ngtech.home",
"instance": "2.ngtech.home",
"job": "blackbox-icmp",
"target_type": "blackbox-icmp"
},
"value": [
1734140895.644,
"0"
]
}
]
}
}
]
What is the error message (if any)?
I am trying to basically loop over the data which in a jq query I will filter with .[].data.result[].metric.hostname
Please share your workflow
The issue is that the workflow executes eventually the echo example command with all the objects as a single input value.
What I want to do is to loop over an array of hostnames and echo each and every one of them separately. I am unsure how to do that in n8n.
In a simple bash script I would use jq with a filter and raw output and then use xargs -I{} echo {}
to loop over the results.
I am new to n8n and unsure where to even find the documentation on this subject.
Information on your n8n setup
- **n8n version:docker.n8n.io/n8nio/n8:latest
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- **Running n8n via (Docker, npm, n8n cloud, desktop app):docker
- **Operating system:Rocky Linux 9.5