0
votes

Is there an API exposed in MarkLogic to get the list of all the long running queries in a particular app server for a stipulated period of time, like if I want all the queries that took more than 5 seconds in the last 12 hours, can I use an API or a call to make this happen?

I am using the following XQuery from a module invoked by a scheduled job to generate the result currently but it does not suffice all of my requirements

xquery version "1.0-ml";
import module namespace res="http://marklogic.com/manage/resource" at "/MarkLogic/manage/endpoints/resource.xqy";
import module namespace dmod = "http://marklogic.com/manage/database" at "/MarkLogic/manage/models/database-model.xqy";
import module namespace gmod="http://marklogic.com/manage/group"  at "/MarkLogic/manage/models/group-model.xqy";
import module namespace hmod="http://marklogic.com/manage/host" at "/MarkLogic/manage/models/host-model.xqy";
import module namespace rmod = "http://marklogic.com/manage/request" at "/MarkLogic/manage/models/request-model.xqy";
import module namespace smod="http://marklogic.com/manage/server"   at "/MarkLogic/manage/models/server-model.xqy";
declare namespace r ="http://marklogic.com/manage/requests";

let $results := rmod:get-list-default-view($res:context,gmod:get-id($res:context),hmod:get-id($res:context),smod:get-id($res:context),rmod:get-seconds-min($res:context))
return $results
1

1 Answers

0
votes

I would recommend to take a look at Troubleshooting queries and see if it helps, though it's only for current queries.

Metering history would give you overall info, but for per-query stats, you might need to log that information somehow and then extract it.