# Visualization with Scripted Metric Aggregation

**URL:** <https://discuss.elastic.co/t/visualization-with-scripted-metric-aggregation/135728>\
**Category:** Kibana\
**Created:** [June 13, 2018, 1:07pm UTC](https://discuss.elastic.co/t/visualization-with-scripted-metric-aggregation/135728 "2018-06-13T13:07:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jvolpi](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jvolpi](https://discuss.elastic.co/u/jvolpi)\
**Post date:** [June 13, 2018, 1:07pm UTC](https://discuss.elastic.co/t/visualization-with-scripted-metric-aggregation/135728/1 "2018-06-13T13:07:52Z")

</div>

Hi everyone

Is there a way to create a visualization with the results of a scripted metric aggregation?.  
My scripted aggregation executes a custom logic, then returns a hashmap of ('timestamp', 'value'), grouped by another normal aggregation (based on a field value, not scripted).

Something like this:

"Field 1" : {  
"HashMap" : [  
{"timestamp" , "value"},  
{"timestamp" , "value"},  
{"timestamp" , "value"},  
...  
]  
},  
"Field 2" : {  
"HashMap" : [  
{"timestamp" , "value"},  
{"timestamp" , "value"},  
{"timestamp" , "value"},  
...  
]  
},  
...

My goal is to visualize this as a bar chart, where the X-Axis would be 'timestamp' (as a histogram with an interval) and the 'Field' aggregation (as a split series), and the Y-Axis would be the sum of 'value'.

Thanks in advance.  
Let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![christophilus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christophilus/32/42991_2.png) [@christophilus](https://discuss.elastic.co/u/christophilus)\
**Post date:** [June 13, 2018, 1:59pm UTC](https://discuss.elastic.co/t/visualization-with-scripted-metric-aggregation/135728/2 "2018-06-13T13:59:08Z")

</div>

Hi Julian, I don't think you'll be able to get exactly what you want, but the closest thing to what you want it is the time series visual builder:

[https://www.elastic.co/guide/en/kibana/current/time-series-visual-builder.html](https://www.elastic.co/guide/en/kibana/current/time-series-visual-builder.html)

With that, you could probably get pretty close by creating a table or a time series line chart.

---

<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:** [July 11, 2018, 1:59pm UTC](https://discuss.elastic.co/t/visualization-with-scripted-metric-aggregation/135728/3 "2018-07-11T13:59:11Z")

</div>

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