I am currently working on a project for my school. The goal is to analyze logsfiles that are generated by salt-stack. I have already setup a MongoDB and the MONGO_FUTURE_RETURN Returner in salt-stack. I want to analyze the logfiles via a python script. Eveything is connected and basic queries such as db.saltReturns.find() work fine.
Since I do not want to rewrite the retuner and my programm needs to access different objects I need something like "Object.Everything.nestedObject".
To clarify what I mean I have attached a snippet of data and will show you what I would want to access.
I have already tried to use $, $each and $[] - none of them solved my problem.
"fun_args" : [ ],
"jid" : "20190423135733454092",
"return" : {
"cmd_|-sssd-ldap-cmd-pam-auth-update-bugfix_|-/usr/local/bin/bugfix-682662-sh_|-wait" : {
"comment" : "No changes detected",
"start_time" : "13:58:22.852410",
"result" : true,
"duration" : 0.016,
"__run_num__" : 26,
"__sls__" : "sssd-ldap.install",
"changes" : {
}
},
"pkg_|-salt-minion-required-packages_|-salt-minion-required-packages_|-installed" : {
"comment" : "All specified packages are already installed",
"name" : "python-concurrent.futures",
"start_time" : "13:58:18.915102",
"result" : true,
"duration" : 24.703,
"__run_num__" : 5,
"__sls__" : "salt-minion.install",
"changes" : {
},
"__id__" : "salt-minion-required-packages"
}
...
}
In my script I would like to access:
"full_ret.return.[all].comment"
All I need is a positional operator that can replace the [all]
placeholder.
I have searched many forums and documentations but could not find a wildcard operator for mongoDB queries. Sadly this seems to be a feature that will not be implemented.