AlteryxService query MongoDB
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am trying to query the MongoDB backend of Alteryx using Studio 3T to connect. The collection I am interested in is the AS_Queue, how can I grab the jobs completed in the last hour?
A bit of back story, I want to run a batch query from AWS to a database/lambda to check the DB for number of nodes running and length of jobs in queue to send out alerts if a node goes down (we have 3) or a job extends past a certain run time as an early alerting process.
Solved! Go to Solution.
- Labels:
- MongoDB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @GoldenDesign04 - check out this article for How to Efficiently Query MongoDB . Section f. "Query based on a relative date (objects created in the last X days, as an example)" should help you achieve what you're looking to accomplish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks Dana for the response. The issue unfortunately is even listed in that link. Alteryx database classifies all the date/time stamps as strings so the query in F won't work.
I did however get a query to work using Studio 3T (Mongdb query tool) and set a scheduled task to pull the date/time I was hoping.
today = new Date();
today.setHours(0, 0, 0, 0);
startOfDay = today.toISOString()
.slice(0, -5)
.replace(/T/g, match => match === 'T' ? ' ' : '');
end = new Date();
end.setHours(23, 59, 59, 999);
endOfDay = end.toISOString()
.slice(0, -5)
.replace(/T/g, match => match === 'T' ? ' ' : '');
db.getCollection("AS_Queue").find(
{
"CreationDateTime": {
$gt: startOfDay,
$lt: endOfDay
}
})
