Envío archivo .file a logstash

Buenas compañeros, tengo que realizar un SIEM con un cliente que el cual, un servidor envíe logs hacia un ambiente ELK, pero aquí tenemos dos problemas.

  1. El archivo que necesitamos enviar está con extensión .file, o sea no tiene extension.
  2. El archivo por dentro tiene un formato algo diferente a como son los logs normalmente, el formato sería algo así:
2AU120210924100940001930800009B9        BC_JOBS                         RSBTCRTE                                0001B&0&A                                                                               

Así tal cual con los espacios entre si y todos en una misma linea. Ahora, ya se intentó en logstash con filtros para que ver si se podía parsear, pero no hubo cambios a la hora de que kibana los indexara.

Se ha intentado de estas formas:

filter {
  mutate {
  split => {"message" => " "}
  add_field => {"primer_linea" => "%{message[0]}"}
}
}
filter{
  mutate{
  gsub => ["message","2AU","| 2AU"]
   split => {"message" => "|"}
}
}

Entiendo el español, pero no escribo muy bien en ese idioma, te respondo en inglés.

This file you are working with is a SAP Audit file and it is very bad to work for two reasons:

  • It does not have a line break, all the events are written without line breaks between day, if you run, for example cat file | wc -l, to count the lines of the file, it will return 0.
  • The fields in the event have a fixed size in bytes, the entire event has 200 bytes and each field has a fixed lenght size in bytes.

Basically you won't be able to use logstash to parse this file correctly as it does not even have a line break in the end, you will need to build a tool to convert it to a more readable format, something use python for example.

I built a python script while working on a previous employer, but unfortunately I do not have access to this script anymore, what you need to do is to read the file in chunks of 200 bytes and split the fields based on their fixed-lenght sizes.

You can read more about this format in the File Format part of this blog post.

1 Like

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