TimeLion cardinality with filter

Hi, I need to provide a unqiue count of userId for a given referer domain.

I tried:
.es('refererDomain:instyle.com AND metric:cardinality=userId.raw')

But it returns zero results. How do I do this? Many thanks.

1 Like

There is no TimeLion tag so please pass this on to @rashidkpc many thanks...

@bhatch perhaps you know?

Here is the list of options for .es(). Each option is separated by a comma.

Try using this format. We have to separate the query from the metric.

.es(q='refererDomain:instyle.com', metric='cardinality=userId.raw')

This kind of query could be done in Kibana itself though. Where TimeLion gets cool is how you can divide the results of two queries. That is something you can't do in Kibana.

.es(q='refererDomain:instyle.com',metric='cardinality=userId.raw').divide(.es(metric='cardinality=userId.raw')).multiply(100).label('instyle.com').title('Percent of users who visited instyle.com')

(I think I got the syntax right, haven't tested it). Now we are taking the unique count of users who have a domain of instyle.com, and dividing it by the total unique count of users. We then multiply that by 100 to get a nice round number and then add a label and title to the graph. You can effectively chain things together forever.

Here is a list of all of the functions.