# JSON input causes unknown key error

**URL:** https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153
**Category:** Kibana
**Created:** [July 14, 2017, 9:29am UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153 "2017-07-14T09:29:24Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mle](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mle](https://discuss.elastic.co/u/mle)
#### Post date: [July 14, 2017, 9:29am UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153/1 "2017-07-14T09:29:24Z")

</div>

Hello!

I just started working with Kibana some days ago and now I want to explore the json input field.

In a histogram I want to count the occurences of the field "test\_id". Therefore I use a filter which works fine.

In addition, I want to group the test\_id's by the test\_name. Because there can occur different names all the time I do not want to hardcode additional filters. Therefore I thought that JSON inputs can solve my problem.

I've added the following code but I always get an error message (Unknown key for a START\_OBJECT in [3]: [aggs].)

> {  
> "aggs": {  
> "4": {  
> "terms": {  
> "field": "test\_name"  
> }  
> }  
> }  
> }

Also when I created a blank histogram and added the JSON input for the filter, I get the same error message. The JSON input for the filter is

{  
"aggs": {  
"3": {  
"filters": {  
"filters": {  
"test\_id:_": {  
"query": {  
"query\_string": {  
"query": "test\_id:_",  
"analyze\_wildcard": true  
}  
}  
}  
}  
}  
}  
}  
}

I'm using Kibana 4.4.1 and ES 2.2.0.

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [July 14, 2017, 11:02am UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153/2 "2017-07-14T11:02:05Z")

</div>

Are you talking about json input field under the advanced options for each aggregation ?

you can't set filters there, you can just set additional configurations on that specific aggregation.

---

<div class="post-metadata">

### Author: ![mle](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mle](https://discuss.elastic.co/u/mle)
#### Post date: [July 14, 2017, 11:16am UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153/3 "2017-07-14T11:16:20Z")

</div>

Yes, I was thinking that it is possible to add filters/aggregations etc. there..

Is there any other possibility to group the filtered data dynamically (to group the data returned by the filter by a field value in the ES)?

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [July 14, 2017, 11:20am UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153/4 "2017-07-14T11:20:11Z")

</div>

could you provide an example of what you would want to achieve ?

---

<div class="post-metadata">

### Author: ![mle](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mle](https://discuss.elastic.co/u/mle)
#### Post date: [July 14, 2017, 1:09pm UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153/5 "2017-07-14T13:09:27Z")

</div>

In my es I have a field test\_data which contains test\_id and test\_name.

I want to create a line chart which should shows the following:

1. The number of test\_id's over time
2. The number of test\_id's grouped by test\_name over time

The first part can be easily done with the count aggregation and a filter on the x- axis. But I do not know how I can achieve the second part.  
I do not want to use additional filters like

> test\_data.test\_name:testName1

because if I add a new test\_name to the es I have to add another filter in kibana too.

I hope it is clear what I want to achieve.

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [July 14, 2017, 1:47pm UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153/6 "2017-07-14T13:47:41Z")

</div>

why are you using filter in the first example ? wouldn't

- using date histogram for your x axis (on timestamp field)
- count metric on y axis  
do the job ?

for second example, how would you want to see your data ?  
monday, group1: 345, group2, 123, group3: 453 ?

then this should do it:

- date histogram for your x axis (timestamp field)
- split series, terms aggregation, split on test\_name field
- count metric on your y axis

this should produce one line for each test\_name

---

<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: [August 11, 2017, 1:48pm UTC](https://discuss.elastic.co/t/json-input-causes-unknown-key-error/93153/7 "2017-08-11T13:48:00Z")

</div>

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