Query Monitor using REST API

query

#1

I want to monitor the Couchbase query e.g. which query is slowest and it’s performing on which bucket.
I want to categorise the queries in the following format and I want the REST API for that or cbstat is also fine.
N1QL/queries > 250 ms
N1QL/queries > 500 ms
N1QL/queries > 1000 ms
N1QL/queries > 5000 ms
I am using couchbase 5.1 Enterprised version. It provides Query Monitoring through UI. But I haven’t found the same thing using REST API.


#2

All queries can be issued through REST API. Chekout


https://blog.couchbase.com/optimize-n1ql-performance-using-request-profiling/

cc @Marco_Greco


#3

Note that you can monitor via UI (as you have found), via the system keyspaces (this is what the UI does), using either the command line interface or the SDKs, or the REST API.
One word of advice - the REST API reports the requests that have been executed by the individual node you are connecting to, so you have to go and query every single node individually.
The system keyspaces (which you can query with a simple SELECT statement) do all of that work for you already.

Also, as @vsr1 points out, you can profile individual requests down to operator level and determine what query component is being the bottleneck. This is covered in detail on the second blog link above.