# Kibana visualization for creating custom bar graph

**URL:** <https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954>\
**Category:** Kibana\
**Created:** [February 4, 2017, 6:44pm UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954 "2017-02-04T18:44:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GautamP](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@GautamP](https://discuss.elastic.co/u/GautamP)\
**Post date:** [February 4, 2017, 6:44pm UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/1 "2017-02-04T18:44:45Z")

</div>

Hi all,

I have a log file containing a series of jobs along with start and end time for each job. I have parsed the log file using logstash and converted the start and end times into timestamp fields. In order to calculate the time for each job, I created a scripted field named job\_time defined as:  
doc['end\_time'].value - doc['start\_time'].value

I need to create a bar graph with job\_name and job\_time as the axes. The vertical bar chart in Kibana's visualize tab only provides aggregate operations like count, sum, average as the Y-axis. I am unable to set job\_time as the Y-axis. Could you please help me out?

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [February 6, 2017, 1:10pm UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/2 "2017-02-06T13:10:23Z")

</div>

Hey @GautamP, is the job\_type not showing up in the y-axis Field dropdown after you select an aggregation?

---

<div class="post-metadata">

**Author:** ![GautamP](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@GautamP](https://discuss.elastic.co/u/GautamP)\
**Post date:** [February 6, 2017, 1:38pm UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/3 "2017-02-06T13:38:37Z")

</div>

Hey @Brandon_Kobel

The fields in the logstash index along with their data types are as follows:

```
job_start_time date
job_end_time date
job_name string

```

job\_time is a scripted field: (doc['job\_end\_time'].value - doc['job\_start\_time'].value) / 1000.0

> [@Brandon\_Kobel](#):
>
> Hey @GautamP, is the job\_type not showing up in the y-axis Field dropdown after you select an aggregation?

job\_name doesn't show up for any aggregation.

These are the only fields that are availabe:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/9/9a517b6f8fb3a310b3453c76c2b31afa620032c6.png)

I would like to have job\_name on Y-axis and its corresponding job\_time on x-axis or vice versa. I don't think I need any aggregation for this but the visualize tab insists on selecting an aggregation

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [February 6, 2017, 2:05pm UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/4 "2017-02-06T14:05:57Z")

</div>

I think the closest that you're going to get is having the job\_name on the x-axis and the job\_time on the y-axis. However, you'll have to choose an aggregation to use for the y-axis. It might be beneficial for us to take a step back, as I'm not sure if this is going to give you exactly what you're looking for.

So, you have jobs that are running that have a job\_name and a job\_time, are you looking to get an entire history of the jobs running and their time, or are you looking for an average/sum of the job\_time?

---

<div class="post-metadata">

**Author:** ![GautamP](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@GautamP](https://discuss.elastic.co/u/GautamP)\
**Post date:** [February 7, 2017, 4:33am UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/5 "2017-02-07T04:33:47Z")

</div>

@Brandon_Kobel  
Each job has a set of sub jobs, each of which may again have a set of sub jobs. I'm looking to get the entire history of jobs running such that I can drill down or roll up to different jobs on different levels to get the the corresponding job times on the various levels.

Here is my discussion with @Mark_Harwood on the same.

> [@Recursive nested documents in elasticsearch](https://discuss.elastic.co/t/recursive-nested-documents-in-elasticsearch/74048):
>
> Hi all, I have a log file containing a series of jobs (each job containing sub jobs recursively) along with start and end time for each job. The log file looks like this: Job Name Start time End time \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ A 01/31/2017 13:05:23 01/31/2017 20:49:14 -i 01/31/2017 13:05:37 01/31/2017 17:24:06 --a 01/31/2017 13:33:16 01/31/2017 13:59:46 ---1 …

My final intention is to obtain something like[JDiskReport](http://www.jgoodies.com/freeware/jdiskreport/) but for figuring out where time goes, not disk space.

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [February 7, 2017, 12:41pm UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/6 "2017-02-07T12:41:37Z")

</div>

@GautamP thank you for that explanation.

For your specific use-case, I'd recommend using an x-axis terms aggregation on job\_name and a y-axis sum aggregation on job\_time, this will give you a chart with the total time spent grouped by job.

---

<div class="post-metadata">

**Author:** ![GautamP](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@GautamP](https://discuss.elastic.co/u/GautamP)\
**Post date:** [February 9, 2017, 8:45am UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/7 "2017-02-09T08:45:44Z")

</div>

@Brandon_Kobel  
Thanks for the suggestion. It's working now.

---

<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:** [March 9, 2017, 8:45am UTC](https://discuss.elastic.co/t/kibana-visualization-for-creating-custom-bar-graph/73954/8 "2017-03-09T08:45:54Z")

</div>

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