0

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
grtjn
  • 20,254
  • 1
  • 24
  • 35
Amit Gope
  • 120
  • 1
  • 10

1 Answers1

0

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.

asusu
  • 321
  • 1
  • 5
  • The above query only gives inflight call records, lets assume my query was supposed to run once daily and I want the list of all the queries that ran for more than 1 minute in the last 24 hours, this won't help. – Amit Gope Jun 07 '18 at 10:56