hello, I'm new to logstash conditional, I want to make different index output based on some field reference on my logstash
here is my index example :
{
"_index": "iris-new-2021.09",
"_type": "_doc",
"_id": "EKS5EHwBUrXRxI7i7tvA",
"_version": 1,
"_score": null,
"_source": {
"input": {
"type": "syslog"
},
"@timestamp": "2021-09-23T03:36:30.421Z",
"tags": [
"beats_input_codec_plain_applied"
],
"openshift": {
"message": "\tat com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)",
"level": "unknown",
"viaq_msg_id": "YTlkYzdhNzItM2U2NC00NmRiLWFmZTItNDc2M2FiZWExZTJj",
"kubernetes": {
"container_image_id": "image-registry.openshift-image-registry.svc:5000/iris-uat/iris-batch-swcon-prod@sha256:d4d74861c96f728af3cb953aa77e0f4c7d220541fb82a048a76f546b4e5a3c94",
"pod_id": "96a3657c-a2e7-4918-9f83-10be97123270",
"container_name": "iris-batch-swcon-prod",
"master_url": "https://kubernetes.default.svc",
"container_image": "image-registry.openshift-image-registry.svc:5000/iris-uat/iris-batch-swcon-prod@sha256:d4d74861c96f728af3cb953aa77e0f4c7d220541fb82a048a76f546b4e5a3c94",
"host": "devocpworker04.ocpdev.dti.co.id",
"pod_name": "iris-batch-swcon-prod-1-s57zc",
"flat_labels": [
"app=iris-batch-swcon-prod",
"deployment=iris-batch-swcon-prod-1",
"deploymentconfig=iris-batch-swcon-prod"
],
"namespace_name": "iris-uat",
"namespace_id": "0da8b310-ceaf-4446-a645-11f3b792d572"
},
"pipeline_metadata": {
"collector": {
"ipaddr4": "10.58.81.34",
"name": "fluentd",
"version": "1.7.4 1.6.0",
"received_at": "2021-08-01T03:23:39.492821+00:00",
"inputname": "fluent-plugin-systemd"
}
},
"docker": {
"container_id": "5001c9085439a436eb3ef1f146b0e390003e01f93dda1a269b9d2fae3a8a4286"
},
"hostname": "devocpworker04.ocpdev.dti.co.id",
"@timestamp": "2021-08-01T03:23:38.794143+00:00"
}
},
"fields": {
"openshift.@timestamp": [
"2021-08-01T03:23:38.794Z"
],
"openshift.pipeline_metadata.collector.received_at": [
"2021-08-01T03:23:39.492Z"
],
"@timestamp": [
"2021-09-23T03:36:30.421Z"
]
},
"sort": [
1632368190421
]
}
I want to use [_source][openshift][kubernetes][namespace_name] as reference to make index output
here's what I've tried :
1.
if "iris-uat" in "%{[openshift][kubernetes][namespace_name]}" {
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-uat-%{+YYYY.MM}"
}
}
if "iris-uat" in "[openshift][kubernetes][namespace_name]" {
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-uat-%{+YYYY.MM}"
}
}
if "iris-uat" in [openshift][kubernetes][namespace_name] {
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-uat-%{+YYYY.MM}"
}
}
am I missing something, I've also tried delete the [openshift] and only use the rest of sub field instead, but I still couldn't get the output
feel free to ask for more information regarding my question if you don't understand about what I'm asking
Thanks