Skip to content

Instantly share code, notes, and snippets.

@webmat
Last active December 18, 2023 07:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmat/be9d145d52749ce61b5c75621a383f52 to your computer and use it in GitHub Desktop.
Save webmat/be9d145d52749ce61b5c75621a383f52 to your computer and use it in GitHub Desktop.
Understanding Filebeat modules

Filebeat modules are all either open source, or provided via the Elastic License. You can look at them all, to understand how the parsing, the conversion and the mapping to ECS are done.

Looking for the modules

Looking at the code of the pipelines

From either module directory, the structure is the same:

  • You'll have a directory named after the module
  • Under it you'll have one or more directory for "file sets" (different logs like apache error & access log).
  • For a given fileset / log directory, you will either have Beats processors in config/*.yml or an Elasticsearch ingest pipeline at ingest/*.json or ingest/*.yml, some modules have both Beats processors and ES pipelines.
  • Concrete example Suricata (x-pack/filebeat/module/suricata, under the "eve" file set):

Log samples

Most modules have tests which include raw logs and the converted log, which you can also look at.

Note about the format of the "-expected.json" files

These test files do not show the actual format of the document as it will be in Elasticsearch. This file is instead optimized for "diffing" before/after, when making changes to the module. In other words, it's made easier to read for humans.

The real format of the converted JSON documents is that there are no dotted keys, it's all nested JSON objects.

So where you'd see this in the "-expected.json"

{
  "@timestamp": "2018-07-05T19:01:09.820Z",
  "destination.address": "192.168.253.112",
  ...
}

Means the document would look like this in Elasticsearch:

{
  "@timestamp": "2018-07-05T19:01:09.820Z",
  "destination": {
    "address": "192.168.253.112",
    ...
  }
...
}

Field definitions

If you're looking for the field definitions of a given module, you'll generally find them inside each fileset's directory as well. If some field definitions are common across the module, and not specific to a fileset, you may also find them at the module level. Simply navigate to _meta/fields.yml in each of these locations.

Concretely:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment