Concurrent users

Is there a way to determine concurrent users to a website using NRQL?
e.g. hourly sessions x average session duration /3600 would be a typical calc

I can get hourly sessions using uniquecount but the session duration is more problematic.

I can see timestamp data in the pageviews table but unclear which NRQL function to use in order to make use of that data in order to define session duration.

Hi, further to the above, is there any way of using a Datediff function (or similar) ?

Hi @chris.godderidge: I have managed to get the session start and end timestamps using this:

SELECT uniques(session), min(timestamp), max(timestamp) from PageView since 1 day ago FACET session

But it is not represented as a table or chart and you will have to do the date calculations yourself as NRQL doesn’t have date functions.

Thanks for taking the time to help Stefan.

@chris.godderidge: You can calculate the length of each session in minutes as follows:

SELECT ((MAX(timestamp) - MIN(timestamp)) / 1000 / 60) AS 'Session Length (minutes)' 
FROM PageView SINCE 1 day ago FACET session LIMIT 100

Thanks for that @philweber, I knew I was close. I’ve tried setting this as an average but am failing, probably due to the return type of (MAX(timestamp) - MIN(timestamp). Here’s what I’m attempting.

SELECT average((MAX(timestamp) - MIN(timestamp)) / 1000 / 60) AS 'Session Length (minutes)' 

And this is the error:

Not supported: BinOp(type=divide, left=BinOp(type=divide, left=BinOp(type=subtract, left=Call(target=Id(name=MAX), args=[Id(name=timestamp)]), right=Call(target=Id(name=MIN), args=[Id(name=timestamp)])), right=Int(value=1000)), right=Int(value=60)) (at line 0 column 15)

@stefan_garnham As I learned recently to my regret, this doesn’t seem to be possible currently in Insights. Here’s the post I made about it in the previous thread:

We can submit an additional request for this if it’s something of interest!


If you could add a feature request I would appreciate it. I am surprised that the average of a calculated value cannot be resolved though.

Hey @stefan_garnham - I added that request for you!

1 Like