# Sending data to index through vega or by any other kibana feature

**URL:** <https://discuss.elastic.co/t/sending-data-to-index-through-vega-or-by-any-other-kibana-feature/370691>\
**Category:** Kibana\
**Tags:** vega, kibana-plugin-development\
**Created:** [November 18, 2024, 12:25pm UTC](https://discuss.elastic.co/t/sending-data-to-index-through-vega-or-by-any-other-kibana-feature/370691 "2024-11-18T12:25:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aman\_kumar4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aman_kumar4/32/137605_2.png) [@aman\_kumar4](https://discuss.elastic.co/u/aman_kumar4)\
**Post date:** [November 18, 2024, 12:25pm UTC](https://discuss.elastic.co/t/sending-data-to-index-through-vega-or-by-any-other-kibana-feature/370691/1 "2024-11-18T12:25:13Z")

</div>

I want to calculate that how much an user spent time on a particular dashboard  
i have created a timer through vega ( working)  
now want to send this timer data when user closes/leaves the dashboard so that I can use this data  
any idea ?

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [January 6, 2025, 12:35pm UTC](https://discuss.elastic.co/t/sending-data-to-index-through-vega-or-by-any-other-kibana-feature/370691/2 "2025-01-06T12:35:35Z")

</div>

Hi @aman_kumar4,

Can you explain what you mean by use the data? Are you looking to index the data into an Elasticsearch index?

I'm not aware of a way to do that in Vega. But it should be possible with a Kibana plugin. I did find [this guide](https://search-guard.com/blog/writing-kibana-plugins-3/) with an example covering how to index data in a Kibana plugin that you could porbably adapt.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![aman\_kumar4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aman_kumar4/32/137605_2.png) [@aman\_kumar4](https://discuss.elastic.co/u/aman_kumar4)\
**Post date:** [January 8, 2025, 8:54am UTC](https://discuss.elastic.co/t/sending-data-to-index-through-vega-or-by-any-other-kibana-feature/370691/3 "2025-01-08T08:54:49Z")

</div>

@carly.richmond thank you for your response  
I just need to calculate the dashboard usage in my cluster.  
for this I have created a counter timer through vega (custom visualisation), that starts automatically when we open the dashboard and then stops when we close the dashboard and then it will again start from zero if you open the dashboard again, so if any how I can store this timer data when closing the dashboard can help me to find for how much time a particular dashboard is used  
the main issue is Im not able to store/index this timer data ?

is their any other way to calculate the dashboard usage?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/f/ff48fc6baedbc916d00860d955a9c9d8b24c163f.png)

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [January 9, 2025, 11:49am UTC](https://discuss.elastic.co/t/sending-data-to-index-through-vega-or-by-any-other-kibana-feature/370691/4 "2025-01-09T11:49:59Z")

</div>

Thanks for confirming @aman_kumar4. The storage of the timer data from Vega is the piece that I'm not sure is possible.

It's not something I've done myself, but I would say you could create a [custom Kibana UI plugin](https://www.elastic.co/guide/en/kibana/current/external-plugin-development.html) to create the component and use simple JavaScript (`Date.now()` to subtract start and end times as per [this post](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now)).

Hope that helps!
