# Max value of index with scripted field in visualizasion

**URL:** <https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688>\
**Category:** Kibana\
**Created:** [January 11, 2021, 9:20am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688 "2021-01-11T09:20:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mamol27](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mamol27/32/82016_2.png) [@Mamol27](https://discuss.elastic.co/u/Mamol27)\
**Post date:** [January 11, 2021, 9:20am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/1 "2021-01-11T09:20:28Z")

</div>

Hello. I'm trying to make linear visualization with average workTime per document and max workTime throw all index. I have two dates: start and end process. So i created scripted field  
`doc['end_time'].value.toInstant().toEpochMilli() - doc['begin_time'].value.toInstant().toEpochMilli()`  
and made avg y-axes for this field.  
But i can't understand how to draw max value of index.  
I need chart like this:

 ![ksnip_20210111-121735](https://us1.discourse-cdn.com/elastic/original/3X/d/1/d1cc3af1ece2640b37798bce365b4ce06b847f81.png)

Can u help me to understand how to make it?

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [January 11, 2021, 12:01pm UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/2 "2021-01-11T12:01:20Z")

</div>

Hi,  
you can use TSVB for that case: create the first `average workTime` series as you have already did.  
then you create a new series for the maxworkTime and you have to overwrite the time interval settings to a value greater than the current time window (for example if you are looking for a 5 mins time interval, you can set the interval to 1 hour for example.

 ![Screenshot 2021-01-11 at 13.00.30](https://us1.discourse-cdn.com/elastic/original/3X/8/b/8be1f98f205854a0b718c487414f959c81182a17.png)

---

<div class="post-metadata">

**Author:** ![Mamol27](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mamol27/32/82016_2.png) [@Mamol27](https://discuss.elastic.co/u/Mamol27)\
**Post date:** [January 11, 2021, 2:50pm UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/3 "2021-01-11T14:50:13Z")

</div>

Hi,  
TSVB looks like I'm looking for, but it doesn't work. I can choose only count aggregation.

 ![ksnip_20210111-174339](https://us1.discourse-cdn.com/elastic/original/3X/0/7/0728af7b968e231a6a0633743fb799284c0fe260.png) ![ksnip_20210111-174342](https://us1.discourse-cdn.com/elastic/original/3X/7/4/74568703dfce47b43352aa1ed0bab5a3f1c1dee6.png) ![ksnip_20210111-175123](https://us1.discourse-cdn.com/elastic/original/3X/9/c/9cd97f1f6d1b687507ac35d444b53bedf13a38b6.png) ![ksnip_20210111-174639](https://us1.discourse-cdn.com/elastic/original/3X/9/f/9f9cc65dca6c8aaf4a4511ebdaa7a885f6289907.png)  
I can't select other aggregation, although I can choose these aggregations in a line visualization.  
Does TSVB support scripted fields to visualize?

---

<div class="post-metadata">

**Author:** ![Mamol27](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mamol27/32/82016_2.png) [@Mamol27](https://discuss.elastic.co/u/Mamol27)\
**Post date:** [January 13, 2021, 8:07am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/4 "2021-01-13T08:07:39Z")

</div>

Hi,  
Does TSVB support scripted fields to visualize? Or I need to create a new numeric field in the document and fill it.  
My scripted field in index has numeric type. And I can use it as filter in TSVB.

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [January 13, 2021, 9:08am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/5 "2021-01-13T09:08:55Z")

</div>

You are right, actually TSVB doesn't support scripted field: you can find the reason here:

> <https://github.com/elastic/kibana/pull/68332#issuecomment-678154430>

There possible workaround are:

- add that value at index time as you suggested
- use Vega to build the chart: it will allows you to create the query you are interested in and plot the line chart as you prefer

---

<div class="post-metadata">

**Author:** ![Mamol27](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mamol27/32/82016_2.png) [@Mamol27](https://discuss.elastic.co/u/Mamol27)\
**Post date:** [January 14, 2021, 8:07am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/6 "2021-01-14T08:07:34Z")

</div>

Hi!  
I tried to make TSVB visualization. When I set an interval more than windowed time I got one point, not a line.

 ![ksnip_20210114-110209](https://us1.discourse-cdn.com/elastic/original/3X/0/0/005f7e6546be18d413ff5b7e4700dbc947a05b5a.png)

This picture with 1 minute.

 ![ksnip_20210114-110211](https://us1.discourse-cdn.com/elastic/original/3X/4/f/4fb7e6f9c4ebcb6a6ee649620c2e43137f1780c7.png)  
How to make it line? And how to make a line continuous?

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [January 14, 2021, 9:13am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/7 "2021-01-14T09:13:39Z")

</div>

Can you show me the configuration for the red series? both the metrics panel and the options panel?  
thanks

---

<div class="post-metadata">

**Author:** ![Mamol27](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mamol27/32/82016_2.png) [@Mamol27](https://discuss.elastic.co/u/Mamol27)\
**Post date:** [January 14, 2021, 9:21am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/8 "2021-01-14T09:21:47Z")

</div>

Here is.

 ![ksnip_20210114-122032](https://us1.discourse-cdn.com/elastic/original/3X/e/5/e523f9c4408d34f8b18536ecee8ac8bcc3f382b9.png) ![ksnip_20210114-122034](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a5f639519d75d666d897d8dfa2e4864b97dd8010.png) ![ksnip_20210114-122035](https://us1.discourse-cdn.com/elastic/original/3X/b/7/b7f0040211c938591b9c555dcf453cfe0914068e.png) ![ksnip_20210114-122036](https://us1.discourse-cdn.com/elastic/original/3X/1/9/19dba0b9b2d2126cfa6fa16705e5d209da8710d4.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:** [February 11, 2021, 9:21am UTC](https://discuss.elastic.co/t/max-value-of-index-with-scripted-field-in-visualizasion/260688/9 "2021-02-11T09:21:49Z")

</div>

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