Hi,
I'm slowly teaching myself the Elastic stack. Current project is attempting to ingest and modelling alerts from snort3 against the elastic common schema. I've run into an issue where an ingest pipeline is not correctly extracting fields out of a json file.
Approach being taken is: filebeat (reading alerts_json.txt file) -> elasticsearch (index template and ingestion pipeline defined).
A snippet from my index template is below:
PUT /_index_template/snort3_template
{
"index_patterns": [
"snort3-*"
],
"template": {
"mappings": {
"properties": {
"destination": {
"properties": {
"address": {
"type": "keyword"
},
"ip": {
"type": "ip"
},
"mac": {
"type": "keyword"
}
}
}
}
A snippet from my ingestion pipeline is below:
PUT /_ingest/pipeline/snort-json-pipeline
{
"description": "Pipeline for ingesting JSON snort3 data",
"processors": [
{
"convert": {
"field": "pkt_num",
"type": "integer",
"ignore_missing": true
}
},
{
"convert": {
"field": "pkt_len",
"type": "integer",
"ignore_missing": true
}
},
{
"convert": {
"field": "src_port",
"type": "integer",
"ignore_missing": true
}
},
{
"rename": {
"field": "src_port",
"target_field": "source.port",
"ignore_missing": true
}
},
{
"convert": {
"field": "dst_port",
"type": "integer",
"ignore_missing": true
}
},
{
"convert": {
"field": "priority",
"type": "integer",
"ignore_missing": true
}
},
{
"rename": {
"field": "src_addr",
"target_field": "source.address",
"if": "ctx._source?.src_addr != '' && ctx._source?.src_addr !=null"
}
},
If I simulate the ingestion pipeline I get the expected result:
POST /_ingest/pipeline/snort-json-pipeline/_simulate
{
"docs": [{"_index":"index","_id":"id","_source":{ "seconds" : 1626683982, "action" : "allow", "class" : "none", "b64_data" : "AAAAAAAAAAAAAAAAAAAAAAAA", "dir" : "UNK", "dst_ap" : ":0", "eth_dst" : "F0:6E:0B:0F:7A:E4", "eth_len" : 60, "eth_src" : "F0:9F:C2:C7:69:1C", "eth_type" : "0x806", "gid" : 112, "iface" : "ens161", "msg" : "(arp_spoof) unicast ARP request", "pkt_gen" : "raw", "pkt_len" : 18, "pkt_num" : 694811210, "priority" : 3, "proto" : "ARP", "rev" : 1, "rule" : "112:1:1", "service" : "unknown", "sid" : 1, "src_ap" : ":0", "vlan" : 0, "timestamp" : "07/19-18:39:42.586277" }}]
}
If I ingest the data via filebeat it does not extract any of the fields from the json message. It will add all of the fields I add via append in the ingest pipeline.
Am stuck at the minute - trying to work out why the field extraction is not working correctly.
cheers,
Michael