# How to Calculate Unique Count of Users in Timelion

**URL:** <https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [October 7, 2017, 11:15am UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112 "2017-10-07T11:15:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [October 7, 2017, 11:15am UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/1 "2017-10-07T11:15:26Z")

</div>

Hi Guyz,

I have bunch of logs are coming in kibana. I want to check unique users hit in timelion only.  
i have alphanumeric value is coming under 'user' fields and have some segments in another fields then i want to check the trends how many user falls into those segment category ?

how can i check unique hits per user over time on timelion in segmented value ? Please suggest expression regarding timelion for unique hits.

---

<div class="post-metadata">

**Author:** ![Stacey\_Gammon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stacey_gammon/32/14025_2.png) [@Stacey\_Gammon](https://discuss.elastic.co/u/Stacey_Gammon)\
**Post date:** [October 10, 2017, 7:06pm UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/2 "2017-10-10T19:06:45Z")

</div>

You can view unique counts via `cardinality` metric, e.g. `.es(metric=cardinality:user_id)`

---

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [October 10, 2017, 7:27pm UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/3 "2017-10-10T19:27:24Z")

</div>

> [@yash\_mangla](#):
>
> on

Hi @Stacey_Gammon,

appreciated your quick reply and many thanks to point out to me in right direction.  
I have another question within same context.

i know how can i break the continuous series into segment over normal bar charts or line chart in kibana. but I want to do same in case of timelion as well.

> `Is there any way in timelion where we can Split those unique counts over a value segment of particular field.`

---

<div class="post-metadata">

**Author:** ![Stacey\_Gammon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stacey_gammon/32/14025_2.png) [@Stacey\_Gammon](https://discuss.elastic.co/u/Stacey_Gammon)\
**Post date:** [October 11, 2017, 3:42pm UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/4 "2017-10-11T15:42:51Z")

</div>

Should be able to do it with `split=field:x`.

Here is some sample data I am playing with:

![00 AM](https://us1.discourse-cdn.com/elastic/original/3X/c/f/cf1a7c8bd2a68828f3ed9599e1d52e4b2ec2f63e.png)

So if I'm understanding your desire correctly, you'd like to do something like track the queries but only count them once per unique user? So the count for query `cats` on the 27th would be 2, not 3, because bob's query would only be counted once.

I think you should be able to use something like this `.es(interval=2h, index=search*, timefield=timestamp, split=query.keyword:3, metric=cardinality:user.keyword)`

![42 AM](https://us1.discourse-cdn.com/elastic/original/3X/e/d/ed7b516e0513818c44e9a7c258812062b70bc242.png)

The chart on the left is missing the cardinality metric, while the chart on the right has it added. You can see that on the 27th, the `cats` query count is only 2.

Does this help?

---

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [October 23, 2017, 6:30pm UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/5 "2017-10-23T18:30:14Z")

</div>

Thanks @Stacey_Gammon this is help me a lot. little bit query i also have.

> For above query, Is it possible to set some static threshold value over these all segmented values on Time-lion graph ?

---

<div class="post-metadata">

**Author:** ![Stacey\_Gammon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stacey_gammon/32/14025_2.png) [@Stacey\_Gammon](https://discuss.elastic.co/u/Stacey_Gammon)\
**Post date:** [November 10, 2017, 1:54pm UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/6 "2017-11-10T13:54:17Z")

</div>

@yash_mangla, you can use the `.static` command:

 ![40 AM](https://us1.discourse-cdn.com/elastic/original/3X/0/8/08b96c44906bea7d746772d9cd14e4f0ddc4591c.png)

---

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [November 13, 2017, 5:32am UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/7 "2017-11-13T05:32:07Z")

</div>

Thanks @Stacey_Gammon,

That's what i was looking for. Thanks for sharing....

---

<div class="post-metadata">

**Author:** ![yash\_mangla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_mangla/32/25889_2.png) [@yash\_mangla](https://discuss.elastic.co/u/yash_mangla)\
**Post date:** [November 15, 2017, 7:32am UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/8 "2017-11-15T07:32:16Z")

</div>

Hi @Stacey_Gammon,

if we don't want label for threshold just want line can we do that ? because this line anyway self-explanatory and with label it's not looking good.

![image](https://us1.discourse-cdn.com/elastic/original/3X/6/7/673b5555f3c0606bd62a24efe0a78613eb81c003.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 13, 2017, 7:32am UTC](https://discuss.elastic.co/t/how-to-calculate-unique-count-of-users-in-timelion/103112/9 "2017-12-13T07:32:26Z")

</div>

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