Hello,
I use a pipeline to ingest logs generated by suricata, everything set up with filebeat setup --pipelines --modules suricata,<other_modules>
. I don't want to ingest any "event" logs, only "alert" logs. So I added the following to the "filter" section of my conf.d/my-logstash.conf:
input {
beats {
port => 5044
ssl => true
ssl_certificate => "/etc/logstash/input.crt"
ssl_key => "/etc/logstash/input.key"
}
}
filter {
[...]
# we block all the events (not alerts) from suricata
if ([event][dataset] == "suricata.eve" and [event][kind] == "event") {
drop { }
}
[...]
}
output {
if [@metadata][pipeline] {
elasticsearch {
hosts => "REDACTED"
manage_template => false
index => "%{[@metadata][pipeline]}-%{+YYYY.MM.dd}"
pipeline => "%{[@metadata][pipeline]}"
user => "REDACTED"
password => "REDACTED"
}
} else {
elasticsearch {
hosts => "REDACTED"
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
user => "REDACTED"
password => "REDACTED"
}
}
}
A sample log that should not be ingested, but is:
{
"_index": "filebeat-7.17.5-suricata-eve-pipeline-2022.07.26",
"_type": "_doc",
"_id": "REDACTED",
"_version": 1,
"_score": 1,
"_ignored": [
"event.original.keyword"
],
"_source": {
"agent": {
"name": "REDACTED"
},
"log": {
"file": {
"path": "/var/log/suricata/eve.json"
},
"offset": 652069717
},
"destination": {
"port": REDACTED,
"bytes": 0,
"ip": "REDACTED",
"packets": 0
},
"source": {
"geo": {
"continent_name": "REDACTED",
"country_iso_code": "REDACTED",
"country_name": "REDACTED",
"location": {
"lon": REDACTED,
"lat": REDACTED
}
},
"as": {
"number": REDACTED,
"organization": {
"name": "REDACTED"
}
},
"port": REDACTED,
"bytes": 318,
"ip": "REDACTED",
"packets": 2
},
"fileset": {},
"network": {
"community_id": "1:REDACTED",
"bytes": 318,
"transport": "tcp",
"packets": 2,
"direction": "inbound"
},
"tags": [
"suricata",
"beats_input_raw_event"
],
"input": {},
"@timestamp": "2022-07-26T14:51:32.179Z",
"ecs": {},
"related": {
"ip": [
"REDACTED",
"REDACTED"
]
},
"service": {},
"@version": "1",
"host": {},
"suricata": {
"eve": {
"tcp": {
"tcp_flags_ts": "00",
"tcp_flags_tc": "00",
"tcp_flags": "00"
},
"community_id": "1:REDACTED",
"event_type": "flow",
"vlan": [
6
],
"flow_id": "REDACTED",
"flow": {
"reason": "timeout",
"alerted": false,
"state": "new",
"age": 0
}
}
},
"event": {
"duration": 17000000,
"ingested": "2022-07-26T14:51:33.065975148Z",
"original": "{\"timestamp\":\"2022-07-26T16:51:32.179196+0200\",\"flow_id\":REDACTED,\"in_iface\":\"REDACTED\",\"event_type\":\"flow\",\"vlan\":[6],\"src_ip\":\"REDACTED\",\"src_port\":REDACTED,\"dest_ip\":\"REDACTED\",\"dest_port\":REDACTED,\"proto\":\"TCP\",\"flow\":{\"pkts_toserver\":2,\"pkts_toclient\":0,\"bytes_toserver\":318,\"bytes_toclient\":0,\"start\":\"2022-07-26T16:48:45.891794+0200\",\"end\":\"2022-07-26T16:48:45.908620+0200\",\"age\":0,\"state\":\"new\",\"reason\":\"timeout\",\"alerted\":false},\"community_id\":\"1REDACTED\",\"tcp\":{\"tcp_flags\":\"00\",\"tcp_flags_ts\":\"00\",\"tcp_flags_tc\":\"00\"}}",
"created": "2022-07-26T14:51:32.624Z",
"kind": "event",
"start": "2022-07-26T14:48:45.891Z",
"end": "2022-07-26T14:48:45.908Z",
"category": [
"network"
],
"type": [
"connection",
"start"
],
"dataset": "suricata.eve"
}
},
"fields": {
"suricata.eve.community_id.keyword": [
"1REDACTED"
],
"event.category": [
"network"
],
"event.category.keyword": [
"network"
],
"event.dataset.keyword": [
"suricata.eve"
],
"suricata.eve.tcp.tcp_flags": [
"00"
],
"suricata.eve.tcp.tcp_flags_tc": [
"00"
],
"related.ip.keyword": [
"REDACTED",
"REDACTED"
],
"event.kind.keyword": [
"event"
],
"source.ip": [
"REDACTED"
],
"agent.name": [
"REDACTED"
],
"suricata.eve.flow.reason": [
"timeout"
],
"suricata.eve.event_type": [
"flow"
],
"network.community_id": [
"REDACTED"
],
"suricata.eve.tcp.tcp_flags_tc.keyword": [
"00"
],
"event.kind": [
"event"
],
"suricata.eve.flow_id": [
"REDACTED"
],
"suricata.eve.tcp.tcp_flags.keyword": [
"00"
],
"event.original": [
"{\"timestamp\":\"2022-07-26T16:51:32.179196+0200\",\"flow_id\":REDACTED,\"in_iface\":\"REDACTED\",\"event_type\":\"flow\",\"vlan\":[6],\"src_ip\":\"REDACTED\",\"src_port\":REDACTED,\"dest_ip\":\"REDACTED",\"dest_port\":REDACTED,\"proto\":\"TCP\",\"flow\":{\"pkts_toserver\":2,\"pkts_toclient\":0,\"bytes_toserver\":318,\"bytes_toclient\":0,\"start\":\"2022-07-26T16:48:45.891794+0200\",\"end\":\"2022-07-26T16:48:45.908620+0200\",\"age\":0,\"state\":\"new\",\"reason\":\"timeout\",\"alerted\":false},\"community_id\":\"1REDACTED",\"tcp\":{\"tcp_flags\":\"00\",\"tcp_flags_ts\":\"00\",\"tcp_flags_tc\":\"00\"}}"
],
"source.geo.location.lon": [
REDACTED
],
"source.packets": [
2
],
"suricata.eve.tcp.tcp_flags_ts": [
"00"
],
"suricata.eve.community_id": [
"1:REDACTED="
],
"network.packets": [
2
],
"source.as.organization.name.keyword": [
"REDACTED"
],
"@version.keyword": [
"1"
],
"log.offset": [
652069717
],
"suricata.eve.flow.reason.keyword": [
"timeout"
],
"tags": [
"suricata",
"beats_input_raw_event"
],
"destination.ip.keyword": [
"REDACTED"
],
"source.port": [
REDACTED
],
"event.created": [
"2022-07-26T14:51:32.624Z"
],
"source.ip.keyword": [
"REDACTED"
],
"destination.bytes": [
0
],
"event.start": [
"2022-07-26T14:48:45.891Z"
],
"source.as.number": [
REDACTED
],
"suricata.eve.flow.state.keyword": [
"new"
],
"network.community_id.keyword": [
"1:REDACTED"
],
"destination.port": [
REDACTED
],
"tags.keyword": [
"suricata",
"beats_input_raw_event"
],
"event.end": [
"2022-07-26T14:48:45.908Z"
],
"suricata.eve.event_type.keyword": [
"flow"
],
"destination.packets": [
0
],
"event.type.keyword": [
"connection",
"start"
],
"suricata.eve.flow.state": [
"new"
],
"related.ip": [
"REDACTED",
"REDACTED"
],
"source.geo.country_iso_code": [
"REDACTED"
],
"@version": [
"1"
],
"source.geo.country_iso_code.keyword": [
"REDACTED"
],
"network.bytes": [
318
],
"network.direction": [
"inbound"
],
"log.file.path.keyword": [
"/var/log/suricata/eve.json"
],
"source.bytes": [
318
],
"network.direction.keyword": [
"inbound"
],
"suricata.eve.flow_id.keyword": [
"REDACTED"
],
"suricata.eve.flow.alerted": [
false
],
"agent.name.keyword": [
"REDACTED"
],
"suricata.eve.flow.age": [
0
],
"source.as.organization.name": [
"REDACTED"
],
"source.geo.continent_name": [
"REDACTED"
],
"network.transport.keyword": [
"tcp"
],
"destination.ip": [
"REDACTED"
],
"network.transport": [
"tcp"
],
"event.duration": [
17000000
],
"suricata.eve.tcp.tcp_flags_ts.keyword": [
"00"
],
"event.ingested": [
"2022-07-26T14:51:33.065Z"
],
"@timestamp": [
"2022-07-26T14:51:32.179Z"
],
"suricata.eve.vlan": [
6
],
"source.geo.location.lat": [
REDACTED
],
"event.type": [
"connection",
"start"
],
"log.file.path": [
"/var/log/suricata/eve.json"
],
"source.geo.country_name.keyword": [
"REDACTED"
],
"source.geo.continent_name.keyword": [
"REDACTED"
],
"source.geo.country_name": [
"REDACTED"
],
"event.dataset": [
"suricata.eve"
]
},
"ignored_field_values": {
"event.original.keyword": [
"{\"timestamp\":\"2022-07-26T16:51:32.179196+0200\",\"flow_id\":REDACTED,\"in_iface\":\"REDACTED\",\"event_type\":\"flow\",\"vlan\":[6],\"src_ip\":\"REDACTED",\"src_port\":REDACTED,\"dest_ip\":\"REDACTED\",\"dest_port\":REDACTED,\"proto\":\"TCP\",\"flow\":{\"pkts_toserver\":2,\"pkts_toclient\":0,\"bytes_toserver\":318,\"bytes_toclient\":0,\"start\":\"2022-07-26T16:48:45.891794+0200\",\"end\":\"2022-07-26T16:48:45.908620+0200\",\"age\":0,\"state\":\"new\",\"reason\":\"timeout\",\"alerted\":false},\"community_id\":\"1:REDACTED\",\"tcp\":{\"tcp_flags\":\"00\",\"tcp_flags_ts\":\"00\",\"tcp_flags_tc\":\"00\"}}"
]
}
}
Other filters I've created also do not work, all are similar: an if condition on some fields, then if the conditions are satisfied, drop { }
is called. How can I achieve what I'm trying to do, which is ignoring some stuff that is sent to Logstash but that I do not want in my ES? Maybe I have some fundamental misunderstanding about how things work. I also suspect those "keyword" fields: why are they created in the first place? Why can't I just have the normal fields and work with that? I've tried adding "[keyword]" at the end of my fields in the filter, same result.
Anyhow, running bin/logstash --config.test_and_exit -f /etc/logstash/conf.d/my-logstash.conf
only returns ECS warnings (because I didn't set it), then "Using config.test_and_exit mode. Config Validation Result: OK. Exiting Logstash".
I use the up-to-date Debian packages on ES's repo, so v7.17.5 for all ES tools. Any help would be greatly appreciated! Thanks a lot.