# Using script fields in Kibana

**URL:** https://discuss.elastic.co/t/using-script-fields-in-kibana/16736
**Category:** Elasticsearch
**Created:** [April 1, 2014, 12:48pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736 "2014-04-01T12:48:19Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Gal\_Zolkover](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Gal\_Zolkover](https://discuss.elastic.co/u/Gal_Zolkover)
#### Post date: [April 1, 2014, 12:48pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/1 "2014-04-01T12:48:19Z")

</div>

Hi All

I'm new to ES and Kibana and i have a simple question:

I have ES collecting counters and i'd like to present in Kibana KPI based  
on the collected counters so i have a script that works in Chrome Sense  
extension,  
my question is how do i pass this script and execute it via Kibana to  
present the calculated counters AKA KPI new calculated fields in the  
Dashboard as a histogram and as table?

script example

GET kpi1-xxxx/\_search  
{

```
    "script_fields" : {
    "reg_succ_rate" : {
        "script" : "doc['UEREGISTRATIONSUCCESS'].value / 

```

doc['UEREGISTRATIONATTEMPTS'].value"  
},  
"test2" : {  
"script" : "doc['UEREGISTRATIONATTEMPTS'].value \* factor",  
"params" : {  
"factor" : 1.0  
}  
}  
}  
}

Regards

Gal

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7dd9a0be-fc34-4c30-8111-ebe07417528a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7dd9a0be-fc34-4c30-8111-ebe07417528a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [April 1, 2014, 12:58pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/2 "2014-04-01T12:58:43Z")

</div>

Unfortunately not out of the box. If you're up to it, you can probably  
create a panel that runs this kind of query in Kibana and wire it in. Need  
to learn a little of Angular and Javascript but its doable. 🙂

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bfeb09a5-8efb-4900-8781-f6b0d062e9bd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bfeb09a5-8efb-4900-8781-f6b0d062e9bd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Gal\_Zolkover](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Gal\_Zolkover](https://discuss.elastic.co/u/Gal_Zolkover)
#### Post date: [April 1, 2014, 1:02pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/3 "2014-04-01T13:02:59Z")

</div>

ok i'm native to java so no issue there, any references i can use or  
examples i can follow ?

On Tuesday, April 1, 2014 3:48:19 PM UTC+3, Gal Zolkover wrote:

> Hi All
> 
> I'm new to ES and Kibana and i have a simple question:
> 
> I have ES collecting counters and i'd like to present in Kibana KPI based  
> on the collected counters so i have a script that works in Chrome Sense  
> extension,  
> my question is how do i pass this script and execute it via Kibana to  
> present the calculated counters AKA KPI new calculated fields in the  
> Dashboard as a histogram and as table?
> 
> script example
> 
> GET kpi1-xxxx/\_search  
> {
> 
> ```
> "script_fields" : {
> "reg_succ_rate" : {
> "script" : "doc['UEREGISTRATIONSUCCESS'].value / 
> 
> ```
> 
> doc['UEREGISTRATIONATTEMPTS'].value"  
> },  
> "test2" : {  
> "script" : "doc['UEREGISTRATIONATTEMPTS'].value \* factor",  
> "params" : {  
> "factor" : 1.0  
> }  
> }  
> }  
> }
> 
> Regards
> 
> Gal

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/48560ce2-c39a-4f83-bdea-fd557c21324c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/48560ce2-c39a-4f83-bdea-fd557c21324c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [April 1, 2014, 3:28pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/4 "2014-04-01T15:28:23Z")

</div>

The basic idea is as follows:

1. In the Kibana src folder, there is a config.js file. At the bottom of  
that file is a list of panel names available to Kibana. You will add your  
new panel name there.

2. Then, under src/app/panels, create folder that corresponds to your panel  
name and then copy a bunch of files from an existing panel - I'd probably  
use the text panel as the basis for testing and experimentation

3. Then in your new panel folder, edit the files that you copied from  
another panel so that the name of the panel and references in code matches  
your new panel name

4. Then study the more complex panels like histogram or table and you  
should be able to duplicate them and adapt to your requirements. Just need  
to inject your script fields right where the query is constructed and then  
extract the script field results and inject into the panel's model data  
structure

It will be time consuming but not impossible. 🙂

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e388fd5d-3686-4f5d-be61-6f72fa599191%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e388fd5d-3686-4f5d-be61-6f72fa599191%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Gal\_Zolkover](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@Gal\_Zolkover](https://discuss.elastic.co/u/Gal_Zolkover)
#### Post date: [April 1, 2014, 4:27pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/5 "2014-04-01T16:27:42Z")

</div>

Ok thank you , I'm up for the chalange 😀

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ad37c4db-ce55-4e0a-af5b-22d007fa452e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ad37c4db-ce55-4e0a-af5b-22d007fa452e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![giu\_migliozzi](https://avatars.discourse-cdn.com/v4/letter/g/ad7895/32.png) [@giu\_migliozzi](https://discuss.elastic.co/u/giu_migliozzi)
#### Post date: [June 25, 2014, 4:18pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/6 "2014-06-25T16:18:17Z")

</div>

Hi Gal, if you complete this challenge...can you post the result?

Il giorno martedì 1 aprile 2014 21:57:42 UTC+5:30, Gal Zolkover ha scritto:

> Ok thank you , I'm up for the chalange 😀

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/41018a05-c994-410f-a21e-dfa5320571fd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/41018a05-c994-410f-a21e-dfa5320571fd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![linkwoman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/linkwoman/32/1395_2.png) [@linkwoman](https://discuss.elastic.co/u/linkwoman)
#### Post date: [July 17, 2014, 5:30pm UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/7 "2014-07-17T17:30:39Z")

</div>

Gal, I too would appreciate seeing your solution. Thank you!

On Tuesday, April 1, 2014 9:27:42 AM UTC-7, Gal Zolkover wrote:

> Ok thank you , I'm up for the chalange 😀

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7e7347fe-dc75-4c97-933c-eddb06484e8c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7e7347fe-dc75-4c97-933c-eddb06484e8c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:15am UTC](https://discuss.elastic.co/t/using-script-fields-in-kibana/16736/8 "2017-07-06T01:15:09Z")

</div>


