Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.
SOLVED

AlteryxService query MongoDB

GoldenDesign04
8 - Asteroid

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.

2 REPLIES 2
dana_mcdonough
Alteryx
Alteryx

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.

GoldenDesign04
8 - Asteroid

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
}
})