# Can I use json input for metrics in a table?

**URL:** https://discuss.elastic.co/t/can-i-use-json-input-for-metrics-in-a-table/199595
**Category:** Kibana
**Created:** [September 16, 2019, 7:48am UTC](https://discuss.elastic.co/t/can-i-use-json-input-for-metrics-in-a-table/199595 "2019-09-16T07:48:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Yungyoung\_Ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yungyoung_ok/32/43465_2.png) [@Yungyoung\_Ok](https://discuss.elastic.co/u/Yungyoung_Ok)
#### Post date: [September 16, 2019, 7:48am UTC](https://discuss.elastic.co/t/can-i-use-json-input-for-metrics-in-a-table/199595/1 "2019-09-16T07:48:46Z")

</div>

Can I use json input for metrics in a table?

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/6/f61fd2a7c5c0eeb8d6d36c6d452578bcc242bffc.png)

I want to indicate whether or not to check, depending on the value of the state field.  
For example, if the state value is 1, I want ok,  
and if the state value is 0, I want no.

here is elasticsearch aggregation...

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/b/eb56fe78284c2762c7aa6b32cd4199cb550417f2.png)

kibana json input:  
{  
"script":"doc['state'].value == 1 ? 'OK' : 'NO'"  
}

but kibana json input is error...  
unknown key for a VALUE\_STRING in [script]...

Is it possible with json input?  
How can I write a script if possible?

---

<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: [September 16, 2019, 4:53pm UTC](https://discuss.elastic.co/t/can-i-use-json-input-for-metrics-in-a-table/199595/2 "2019-09-16T16:53:07Z")

</div>

Hey @Yungyoung_Ok, if you wish to use a "script\_fields" in Elasticsearch, you'll want to use a [Kibana Scripted Field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html).

After you create the Kibana Scripted Field, it will show up like a normal field in Discover and when creating a new Visualization.

---

<div class="post-metadata">

### Author: ![Yungyoung\_Ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yungyoung_ok/32/43465_2.png) [@Yungyoung\_Ok](https://discuss.elastic.co/u/Yungyoung_Ok)
#### Post date: [September 17, 2019, 4:17am UTC](https://discuss.elastic.co/t/can-i-use-json-input-for-metrics-in-a-table/199595/3 "2019-09-17T04:17:31Z")

</div>

I know scripted field uses a lot of memory.

Is there a way to use fields only in that graph with json input?

---

<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: [September 17, 2019, 2:15pm UTC](https://discuss.elastic.co/t/can-i-use-json-input-for-metrics-in-a-table/199595/4 "2019-09-17T14:15:18Z")

</div>

> Is there a way to use fields only in that graph with json input?

Unfortunately, there is not.

> I know scripted field uses a lot of memory.

Using it inline via JSON input vs a scripted field has very little difference in memory utilization. However, the scripted field is used more widely, perhaps when it's not needed, so I can see your point about it's impact on the memory utilization of the cluster. Would you mind opening up a feature request [here](https://github.com/elastic/kibana/issues/new?template=Feature_request.md) and explaining your rationale?

---

<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: [October 15, 2019, 2:15pm UTC](https://discuss.elastic.co/t/can-i-use-json-input-for-metrics-in-a-table/199595/5 "2019-10-15T14:15:19Z")

</div>

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