Hello All,
After trying several time,I'm unable to process one column in oracle table that contains json data and I would require every field in that as seperate filed created in elastic index.Could someone guide what am i doing wrong here and even if I get incorrect data then only getting 1 recors only ,not all.
package_id is unique here and I'm getting only 1 record,total 8 records in table.
{"status":"Start","errorData":null,"creationDate":1668596975812,"lastModificationDate":null,"dataInfoProcess":[{"RequestId":"123AA","Counter":1,"size":12,"docId":"ED9","processid":"","lastPart":true}]}
would require in index:
Status,errrordata,requestid.....as seperate fields created.
Above image package_data column data is stored as json and would require in elastic index to come as each seperate fields created.
Template
PUT _index_template/tcs-package-details
{
"template": {
"settings": {
"index": {
"lifecycle": {
"name": "tcs-policy",
"rollover_alias": "tcs-package-details"
},
"number_of_shards": "1",
"number_of_replicas": "0"
}
},
"mappings": {
"_routing": {
"required": false
},
"numeric_detection": false,
"dynamic_date_formats": [
"strict_date_optional_time",
"yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
],
"_source": {
"excludes": [],
"includes": [],
"enabled": true
},
"dynamic": true,
"date_detection": true
}
},
"index_patterns": [
"tcs-package-details-*"
],
"composed_of": []
}
Logstash config:
input {
jdbc {
jdbc_connection_string => "jdbc:oracle:thin:@abc:1821/tcs"
jdbc_user => "random"
jdbc_password => "random"
jdbc_driver_library => "../lib/ojdbc8-11.2.0.1.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_paging_enabled => true
last_run_metadata_path => "../config/lastrun-tcs-p-details.yml"
schedule => "*/25 * * * * *"
connection_retry_attempts => 5
connection_retry_attempts_wait_time => 10
statement=> "select PACKAGE_ID,PACKAGE_DATA, from_tz(CAST (CREATION_DATE AS TIMESTAMP), 'UTC') as CREATION_DATE, from_tz(CAST (LAST_MOD_DATE AS TIMESTAMP), 'UTC') as LAST_MOD_DATE from tcs_ar2mig_newpack where LAST_MOD_DATE >= SYS_EXTRACT_UTC(:sql_last_value)"
type => "tcs-package-details"
}
}
filter {
json {source => "package_data"}
split {field => "package_data"}
mutate {remove_field => [ "package_data"]}
}
output {
#stdout { codec => json_lines }
if [type] == "tcs-package-details"{
elasticsearch {
hosts => "abc:9200"
ilm_pattern => "{now/d}-000001"
"doc_as_upsert" => true
ilm_rollover_alias => "tcs-package-details"
ilm_policy => "tcs-policy"
"document_id" => "%{package_id}"
}
}
}
Kindly guide here,how it can be achieved
Thanx