Show number of users who performed an action in a single day (rather than total number of times an action was performed in a single day)

(Clint Gossett) #1

I currently am using Timelion to show the total number of times a specific action was performed each day by users within our application. The overall objective is to measure user engagement across our entire user base.

The metric above is not very useful, as if a single user performs an action 500 times in one day, it skews the results.

What I would like to show is the total number of users who performed a specific action each day.

In effect the user who performed the action 500 times would be counted as 1 and a user who performed the action 3 times would be counted as 1, each day would be represented on the graph by a count of unique users.

Here's the code I'm using for the first query:

.es(q=activityType:CLIENT_LOGIN, index='audit_logs_*', timefield='createdOn').bars().label('Client Logins').color("red")

Note: Users are identified by the userName: field within each document.

Can this be done using a Timelion query?

(Mark Walkom) #2

You want to use a cardinality aggregation on the user field, and keep that activityType filter in there :slight_smile:

1 Like
(Clint Gossett) #3

That worked! Thank you!

.es(q=activityType.keyword:CLIENT_LOGIN, index='audit_logs_*', timefield='createdOn', metric=cardinality:userName.keyword).bars().label('Client Logins').color("red")

New code.

1 Like
(system) closed #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.