# How to split one hit in kibana ( single field data) to diiferent hits for a json data?

**URL:** https://discuss.elastic.co/t/how-to-split-one-hit-in-kibana-single-field-data-to-diiferent-hits-for-a-json-data/203562
**Category:** Logstash
**Created:** [October 15, 2019, 5:35am UTC](https://discuss.elastic.co/t/how-to-split-one-hit-in-kibana-single-field-data-to-diiferent-hits-for-a-json-data/203562 "2019-10-15T05:35:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Muhammed\_Danish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammed_danish/32/55579_2.png) [@Muhammed\_Danish](https://discuss.elastic.co/u/Muhammed_Danish)
#### Post date: [October 15, 2019, 5:35am UTC](https://discuss.elastic.co/t/how-to-split-one-hit-in-kibana-single-field-data-to-diiferent-hits-for-a-json-data/203562/1 "2019-10-15T05:35:43Z")

</div>

Hi all, I have imported the json data in postgresql to elasticsearch using jdbc driver in logstash. But it is viewed as a single hit in kibana (as one filed data) and I can't create visualization using that. So, I need to split the json data to multiple hits in kibana. While using the split filter I am getting the error "NILCLASS IS NOT SPLITTABLE". The following data need to be splitted:

"ansible\_local": {"tinc\_facts": {"date": "Tue Oct 1 12:49:30 IST 2019"}, "cis\_audit\_status": {"Dns": "", "Fat": "1.1.1.8 - Mounting of vfat filesystems is not Disabled FAILED", "Ftp": "", "Gdm": "1.7.2 - GDM Login Banner is not configured FAILED", "Hfs": "1.1.1.4 - Mounting of hfs filesystems is not Disabled FAILED", "Mcs": "", "Nis": "", "Ntp": "2.2.1.2 - NTP is not configured FAILED", "Rds": "3.5.3 RDS is not Disabled FAILED", "Rsh": "", "Tmp": "1.1.2 - Separate partition not exists for /tmp FAILED", "Udf": "1.1.1.7 - Mounting of udf filesystems is not Disabled FAILED", "Var": "1.1.6 - Separate partition not exists for /var FAILED", "Aide": "1.3.1 - AIDE is not installed FAILED", "Aslr": "1.5.3 - Address Space Layout Randomization (ASLR) is not enabled FAILED", "Cron": "", "Cups": "", "Dccp": "3.5.1 DCCP is not Disabled FAILED", "Dhcp": "", "Echo": "", "Home": "", "Http": "", "Icmp": "3.2.2 - ICMP redirects are accpeted FAILED", "Imap": "", "Ipv6": "3.3.3 - Ensure IPv6 is not disabled FAILED", "Ldap": "", "Mail": "2.2.15 - Mail Transfer Agent is not configured for local-only mode FAILED", "Nisc": "2.3.1 - NIS Client is Installed FAILED",

Thanks in advance for the help.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [October 15, 2019, 2:20pm UTC](https://discuss.elastic.co/t/how-to-split-one-hit-in-kibana-single-field-data-to-diiferent-hits-for-a-json-data/203562/2 "2019-10-15T14:20:11Z")

</div>

What does your split filter configuration look like?

---

<div class="post-metadata">

### Author: ![Muhammed\_Danish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammed_danish/32/55579_2.png) [@Muhammed\_Danish](https://discuss.elastic.co/u/Muhammed_Danish)
#### Post date: [October 16, 2019, 6:01am UTC](https://discuss.elastic.co/t/how-to-split-one-hit-in-kibana-single-field-data-to-diiferent-hits-for-a-json-data/203562/3 "2019-10-16T06:01:21Z")

</div>

Sorry for the late reply and thanks for your reply. Now I can able to split the json to different fields in kibana by using ruby. But my intention is to split the data to multiple hits or events in kibana. That is, I need to view the data in separate rows of the elasticsearch in head plugin.  
Following is my logstash conf file:  
input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:postgresql://x.x.x.x:5432/awx"  
jdbc\_user =\> "postgres"  
jdbc\_validate\_connection =\> true  
jdbc\_driver\_library =\> "/usr/share/logstash/logstash-core/lib/jars/postgresql-jdbc.jar"  
jdbc\_driver\_class =\> "org.postgresql.Driver"  
clean\_run =\> true  
schedule =\> "\*/1 \* \* \* \*"  
statement =\> "SELECT DISTINCT ON (name) name,id,message-\>\>'ansible\_local'::TEXT AS message FROM main"  
use\_column\_value =\> true  
tracking\_column =\> "id"  
}

}

filter {  
mutate {  
copy =\> { "id" =\> "[@metadata][\_id]"}  
remove\_field =\> ["id", "@version"]  
}  
}

filter {  
mutate {  
copy =\> { "message" =\> "[@metadata][\_message]"}  
remove\_field =\> ["message", "@version"]  
}  
}

filter {  
mutate {  
copy =\> { "name" =\> "[@metadata][\_name]"}  
remove\_field =\> ["name", "@version"]  
}  
}  
filter {  
json { source =\> "[@metadata][\_message]" }  
json {  
skip\_on\_invalid\_json =\> true  
source =\> ["[@metadata][\_message][0]"]  
target =\> "[@metadata][\_message]"  
}  
}  
filter {  
json {  
source =\> "[@metadata][\_message]"  
}  
ruby {  
code =\> '  
event.to\_hash.each do |key, value|  
if value.is\_a?(Hash)  
value.each do |field, child|  
if child.is\_a?(Array)  
event.set("renameable\_field", "[#{key}][#{field}]")  
break  
end  
end  
end  
end  
'  
}  
if [renameable\_field] {  
mutate {  
rename =\> {"[%{renameable\_field}]" =\> "field\_that\_needs\_splitting"}  
}  
split {  
field =\> "[field\_that\_needs\_splitting]"  
}  
mutate {  
rename =\> {"field\_that\_needs\_splitting" =\> "[%{renameable\_field}]"}  
}  
ruby {  
code =\> '  
renameable\_field = event.remove("renameable\_field")  
inner = event.get(renameable\_field)  
if inner.is\_a?(Hash)  
inner.each do |field, child|  
if child.is\_a?(Array)  
event.set("renameable\_field", renameable\_field + "[#{field}]")  
break  
end  
end  
end  
'  
}  
if [renameable\_field] {  
mutate {  
rename =\> {"[%{renameable\_field}]" =\> "field\_that\_needs\_splitting"}  
}  
split {  
field =\> "[field\_that\_needs\_splitting]"  
}  
mutate {  
rename =\> {"field\_that\_needs\_splitting" =\> "[%{renameable\_field}]"}  
}  
}  
}  
}  
output {  
elasticsearch {  
index =\> "%{[@metadata][\_name]}-index"  
document\_id =\> "%{[@metadata][\_id]}"  
hosts =\> "x.x.x.x:9200"  
}  
}

Is there any way to split the fields to multiple hits in kibana from logstash? with field only I can't able to create visualization according to my need.

---

<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: [November 13, 2019, 6:01am UTC](https://discuss.elastic.co/t/how-to-split-one-hit-in-kibana-single-field-data-to-diiferent-hits-for-a-json-data/203562/4 "2019-11-13T06:01:37Z")

</div>

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