Couchbase completed_queries containing N1QL queries of bucket without indexes

Hello, I have built a dashboard for checking completed queries using the admin/completed_queries REST API. The reason for not using the N1QL query dashboard is because we are using Couchbase 5.1.1. Community Edition so we don’t have the query monitoring dashboard yet, and also we would like to keep the data in our monitoring stack so we can do some analysis for specific time periods.

To get all queries, I used a http poller that polls the REST API every minute and filter those than happened in the past 1 minute. I have set completed-threshold to be 0 and completed-limit to be 4000 on admin/settings API

However, I noticed we have been getting a lot of strange queries. For example, we get queries like select count(*) cnt from test-bucket when we visit the Couchbase UI, which I assumes its how Couchbase UI is getting the item counts to be displayed. I confirmed it to be our UI user as the user who made the query is our Couchbase UI user, and there would be 1 count query for each bucket. But where it doesn’t make sense is my test-bucket doesn’t have an index. How is Couchbase querying it without index?

Example of one such query without index returned by the API:
“elapsedTime”: “20.024177ms”,
“errorCount”: 0,
“phaseOperators”: {
“authorize”: 1,
“count”: 1
},
“requestId”: “818e6bc7-119e-479a-b0dc-1cf5eea80a31”,
“requestTime”: “2020-06-04 17:23:54.161611806 +0900 JST”,
“resultCount”: 1,
“resultSize”: 38,
“scanConsistency”: “unbounded”,
“serviceTime”: “20.003676ms”,
“state”: “completed”,
“statement”: "select count(*) cnt from test-bucket",
“users”: “ui_user”

select count(*) cnt from test-bucket
This is special query count all on whole bucket. It uses bucket stats from KV. Check Page 197 (Use Case 1) http://blog.couchbase.com/wp-content/uploads/2017/03/N1QL-A-Practical-Guide-v2.pdf

You can filter them using users, userAgent, requestId(later releases UI queries are prefixed INTERNAL)

Hi @vsr1, thanks for your detailed reply. I will filter by users in that case.

Cheers,
Wen Tat