# Kibana vega plug-in last state of each log

**URL:** <https://discuss.elastic.co/t/kibana-vega-plug-in-last-state-of-each-log/128661>\
**Category:** Kibana\
**Created:** [April 19, 2018, 9:18am UTC](https://discuss.elastic.co/t/kibana-vega-plug-in-last-state-of-each-log/128661 "2018-04-19T09:18:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KibanaUse](https://avatars.discourse-cdn.com/v4/letter/k/e9c0ed/32.png) [@KibanaUse](https://discuss.elastic.co/u/KibanaUse)\
**Post date:** [April 19, 2018, 9:18am UTC](https://discuss.elastic.co/t/kibana-vega-plug-in-last-state-of-each-log/128661/1 "2018-04-19T09:18:08Z")

</div>

Hello,

I want to show the latest state diagram for my customers. I have the following data

"values":  
[  
{"customer": "A", "@timestamp": 1527018117012, "state": "red"},  
{„customer": "A", "@timestamp": 1523020495093, "state": "green"},  
{"customer": "B", "@timestamp": 1523019277575, "state": "green"},  
{"customer": "B", "@timestamp": 1523019247575, "state": "red"},  
{"customer": "B", "@timestamp": 1523019147575, "state": "green"},  
{"customer": "C", "@timestamp": 1523008092998, "state": "green"},  
{"customer": "C", "@timestamp": 1523017219635, "state": " yellow"}  
]

There should be only one state shown for each customer: the latest state according to the @timestamp. Currently my diagram shows all the states:

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

the current vega code is as following:

{  
"$schema": "[https://vega.github.io/schema/vega-lite/v2.json](https://vega.github.io/schema/vega-lite/v2.json)",  
"data": {  
"values": [...]

},  
"mark": "point",  
"encoding": {  
"y": {"field": "customer", "type": "nominal"},  
"x": {"field": "state", "type": "nominal"}  
}  
}

How can I make Vega to show not all state of the customers but only the last state on the diagram? (it should be like this:

 ![diagram](https://us1.discourse-cdn.com/elastic/original/3X/e/5/e526b89902a30aec53a927f37ce785e7a44cc473.png)  
)

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [April 20, 2018, 1:02pm UTC](https://discuss.elastic.co/t/kibana-vega-plug-in-last-state-of-each-log/128661/2 "2018-04-20T13:02:56Z")

</div>

I will check if this is possible with vega (it can do some data transformations on the client side). However better way to handle this would be to return correct data to kibana. If data is retrieved from elasticsearch something like top hit could be used to retrieve just the latest record for each user.

---

<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:** [May 18, 2018, 1:03pm UTC](https://discuss.elastic.co/t/kibana-vega-plug-in-last-state-of-each-log/128661/3 "2018-05-18T13:03:39Z")

</div>

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