Bucket Statistics: "haveTStamp" not working for me?

I’m trying to query bucket statistics with a GET request, and want to limit/expand the number of results for each metric using the “haveTStamp” parameter mentioned here.

However, that parameter doesn’t seem to limit nor expand the number of results based on the timestamp provided. Eg., when I provide a timestamp from 5 seconds ago, the HTTP query still shows the full range of metrics from the past minute (a total of 60). I’m expecting (from my understanding of the parameter) it to limit to only the last 5 entries in this instance.

An example query from above: http://localhost:8091/pools/default/buckets/Data/stats?haveTStamp=1615845246000. The number placed after haveTStamp doesn’t seem to matter. For example, I could do http://localhost:8091/pools/default/buckets/Data/stats?haveTStamp=1 or http://localhost:8091/pools/default/buckets/Data/stats?haveTStamp=99999999999999 and nothing changes.

I’m wondering if perhaps I’m using the wrong parameter, or perhaps a wrong format (the documentation indicates a UNIX style stamp in milliseconds, which is what I’ve used). Or perhaps it doesn’t behave the way I expect.

Thanks for any help. Couchbase version is 6.6.

Hi David,

I don’t do a lot of stats work but in 7.0 I think you will be able to do what you want. I will reach out to an expert on your behalf for 6.6.

Best

Jon Strabala

Hi David,

The use of the parameter haveTStamp is expected to be an exact timestamp of an existing datapoint provided by a previous REST API call.
I have been told the idea was the following: you pass the last timestamp that you’ve seen the last time and it gives you all the data points starting from what you passed.
So unfortunately you can “limit” to just five items you can only pick up where you left off.
I have provided a bash script for you to play with if you want to develop some further understanding, not I like to pretty print things so I use the utility jq

#!/bin/bash

# Make a request to get a default block of 60 items, use 'jq' this is how
# the stats call works, unless you have an actual tick to request from.

bucket=crondata
numstatswanted=5
aryidx=60
aryidx=$((aryidx-$numstatswanted))

echo "Bucket: $bucket"
echo "Username: $CB_USERNAME"
echo "Password: $CB_PASSWORD"
echo "want $numstatswanted samples"
echo
echo "Grab 60 items but extract the 55th timestamp"
a_ts=`curl -X GET -s -u admin:jtester http://localhost:8091/pools/default/buckets/$bucket/stats | jq .op.samples.timestamp[58]`
echo "55th timestamp is $a_ts"
echo
echo "Now pass $a_ts as the parameter to haveTStamp (will pretty print with jq)"
echo "    curl -X GET -s -u admin:jtester http://localhost:8091/pools/default/buckets/$bucket/stats?haveTStamp=$a_ts | jq ."
echo
curl -X GET -s -u admin:jtester http://localhost:8091/pools/default/buckets/$bucket/stats?haveTStamp=$a_ts | jq .

Hi, thanks that clarifies a lot. Appreciated!

It actually did not work for me, even with haveTStamp, it is listing the metrics from last minute. Also for me with zoom=minute, it is giving only 43 readings instead of 60