# Decoding BMC logs in Wazuh: from a syslog sample to a rule

> Turn a management controller syslog sample into decoder fields, a rule and a logtest check, keeping the source format separate from the Wazuh logic.

Published: 2026-11-17. Category: Detection. Tags: Wazuh 4. URL: https://wazuh.blog/en/blog/bmc-syslog-decoders/ Polish original: https://wazuh.blog/blog/wazuh-bmc-syslog-dekodery-reguly/

Syslog from a management controller reaches Wazuh as plain text until a decoder extracts the fields that rules work on. On a sample event I build a decoder, a rule and a test in `wazuh-logtest`, and I take options and defaults from the Wazuh documentation.

## Sample and fields

I start with one syslog line. All values are examples: `agent-01`, `example-bmc`, `example-operator` and an address from the 192.0.2.0/24 range.

```text
Nov 17 12:00:00 agent-01 example-bmc: event=login_failed user=example-operator src=192.0.2.44
```

I assign a field to each fixed fragment before I write a pattern:

| Sample fragment | Field | Kind |
| --- | --- | --- |
| `example-bmc` | `program_name` | syslog header, pre-decoding phase |
| `login_failed` | `bmc_event` | dynamic field |
| `example-operator` | `user` | static field, alias of `dstuser` |
| `192.0.2.44` | `srcip` | static field |

The documentation splits the names in `<order>` into static and dynamic. A dynamic field is any string outside the static list. The `user` field is an alias of `dstuser`, and one decoder can use only one of these names.

| Static field | Description in the documentation |
| --- | --- |
| `srcuser` | source username |
| `dstuser` | destination username |
| `user` | alias of `dstuser` |
| `srcip` | source IP address |
| `dstip` | destination IP address |
| `srcport` | source port |
| `dstport` | destination port |
| `protocol` | protocol |
| `system_name` | system name |
| `id` | event identifier |
| `url` | event URL |
| `action` | event action (deny, drop, accept and so on) |
| `status` | event status (success, failure and so on) |
| `data` | data |
| `extra_data` | any additional data |

Four entries from the first table are enough for the sample. I do not create fields whose values I cannot see in the log.

## Log collection by the agent

The `<localfile>` section configures log collection from files, Windows events and command output. Two options choose the file and the format: `location` points to the source (a file path, an event channel, macos or journald), and `log_format` is required. For most text files with one entry per line, the documentation points to the `syslog` format. Filters and conversion for the journald source are covered in the [post on journald in localfile](/en/blog/journald-localfile-filters/).

| Option | Description in the documentation | Values |
| --- | --- | --- |
| `location` | where the log data comes from | file path, event channel, macos, journald |
| `log_format` | format of the log being read, required field | see the table below |
| `command` | command output read as a log | command |
| `age` | skips files not modified for the given time | number with suffix s, m, h or d |
| `exclude` | excludes a group of files with a wildcard | path with a wildcard |
| `ignore_binaries` | discards binary files | yes, no |

| `log_format` value | Use according to the documentation |
| --- | --- |
| `syslog` | text files in a syslog-like format, one entry per line |
| `generic` | general text files |
| `json` | JSON files with one event per line |
| `command` | runs the command as root, each output line is a separate log |
| `full_command` | runs the command as root, the whole output is one log |
| `journald` | systemd-journal events in syslog format |
| `eventchannel` | Windows event channels |

In file names I can use strftime markers or wildcards, but not both in one entry. The agent monitors at most 1000 files at the same time. The example from the documentation for a syslog file looks like this:

```xml
<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/syslog</location>
</localfile>
```

The server keeps external logs in archives, which are disabled by default. The text archive is `/var/ossec/logs/archives/archives.log`, the JSON archive is `/var/ossec/logs/archives/archives.json`. Two options in the `<global>` section of the server's `/var/ossec/etc/ossec.conf` enable them:

| Option | Effect | Values |
| --- | --- | --- |
| `logall` | writes all logs in syslog format | yes, no |
| `logall_json` | writes events in JSON format | yes, no |

Only `logall_json` provides the index for visualizing events on the dashboard. After the change, the documentation says to restart the manager.

```xml
<ossec_config>
  <global>
    <jsonout_output>yes</jsonout_output>
    <alerts_log>yes</alerts_log>
    <logall>yes</logall>
    <logall_json>yes</logall_json>
  </global>
</ossec_config>
```

The archives hold logs from all monitored endpoints, so over time they take up a lot of space on the server. The manager compresses logs daily and stores them in directories named after the source file, the year and the month. A file compressed on 13 April 2024 goes to `/var/ossec/logs/archives/2024/Apr/` as `ossec-archive-13.log.gz`, with the checksum in `ossec-archive-13.log.sum`. The difference between an archive and an alert is covered in a [separate guide](/en/blog/wazuh-archives-vs-alerts/).

## Decoder

I keep custom decoders in `/var/ossec/etc/decoders/local_decoder.xml`, and for larger changes in separate files of that directory. The parent decoder recognizes the program, the child extracts the fields. The documentation describes these options:

| Option | Values | Description |
| --- | --- | --- |
| `<parent>` | decoder name | the decoder becomes a child and runs after the parent matches |
| `<program_name>` | regex, sregex or pcre2 | the program from the syslog header must match the expression |
| `<prematch>` | regex or pcre2 | condition on the log content without the syslog header |
| `<regex>` | regex or pcre2 | extracts fields from parentheses |
| `<order>` | list of field names | names for consecutive regex groups |

Three restrictions from the documentation apply. `<regex>` requires `<order>` next to it. `<regex>` also requires `<prematch>` or `<program_name>` in the decoder or in its parent. A child decoder cannot be a parent, but one parent can have many children, which gives sibling decoders for logs with a variable structure.

The expression type is set by the `type` attribute:

| Tag | `type` values | Default |
| --- | --- | --- |
| `<program_name>` | `osmatch`, `osregex`, `pcre2` | `osmatch` |
| `<prematch>` | `osregex`, `pcre2` | `osregex` |
| `<regex>` | `osregex`, `pcre2` | `osregex` |

The decoder for the sample uses pcre2 in `<regex>`:

```xml
<decoder name="example-bmc">
  <program_name>^example-bmc</program_name>
</decoder>

<decoder name="example-bmc">
  <parent>example-bmc</parent>
  <regex type="pcre2">event=(\w+) user=([\w-]+) src=([0-9.]+)</regex>
  <order>bmc_event,user,srcip</order>
</decoder>
```

For `<prematch>`, the documentation recommends a pattern as specific as possible, to avoid matching unwanted events. I apply the same rule to `<program_name>` in the parent.

## Rule

I keep custom rules in `/var/ossec/etc/rules/local_rules.xml` or in a separate file of the `/var/ossec/etc/rules/` directory. The documentation assigns custom rule identifiers to the range 100000 to 120000, although the syntax allows numbers from 1 to 999999. Every rule must have at least one group, which the `<group>` element provides.

| `<rule>` attribute | Description | Allowed values |
| --- | --- | --- |
| `level` | rule level used by alerts and responses | 0 to 16 |
| `id` | rule identifier | 1 to 999999 |
| `frequency` | number of matches before an alert | 2 to 9999 |
| `timeframe` | time window in seconds | 1 to 99999 |
| `ignore` | time in seconds during which the rule does not fire after being triggered | 1 to 999999 |
| `noalert` | no alert despite a match | 0 (default) or 1 |

Conditions used in the rules below:

| Condition | Meaning |
| --- | --- |
| `decoded_as` | event decoded by the given decoder |
| `field` | compares a field extracted by the decoder with a regular expression |
| `if_sid` | the rule matches when an earlier rule from the list matched |
| `srcip` | compares an address or CIDR block with the address decoded as `srcip` |

The `field` element takes a `name` attribute with the field name, `negate` (yes or no, default no) and `type` (`osregex` by default, `osmatch`, `pcre2`). Several `field` elements in one rule work as a conjunction: all conditions must be met. The documentation shows `decoded_as` in a level 0 grouping rule from which the detailed rules inherit:

```xml
<rule id="53500" level="0">
  <decoded_as>smtpd</decoded_as>
  <description>OpenSMTPd grouping.</description>
</rule>
```

For the sample I write two rules. The first links the decoder with the value of the `bmc_event` field, the second narrows it to an address range:

```xml
<group name="example-bmc,">
  <rule id="100010" level="5">
    <decoded_as>example-bmc</decoded_as>
    <field name="bmc_event">login_failed</field>
    <description>Example BMC: login failure</description>
  </rule>

  <rule id="100011" level="8">
    <if_sid>100010</if_sid>
    <srcip>192.0.2.0/24</srcip>
    <description>Example BMC: login failure from the example range</description>
  </rule>
</group>
```

I pick levels 5 and 8 only to show the syntax. Separating extraction from detection shows, during a test, whether a missing alert comes from the decoder or from a rule condition. Rules that depend on the number of events are covered in the [post on event correlation](/en/blog/wazuh-event-correlation/).

## Testing in wazuh-logtest

`/var/ossec/bin/wazuh-logtest` runs on the Wazuh server and shares sessions: each one loads its own set of rules and decoders, and the `firedtimes` counter grows within it. In a cluster, the master node processes the events. Parameters of the `<rule_test>` section in `/var/ossec/etc/ossec.conf`:

| Parameter | Description | Default | Allowed values |
| --- | --- | --- | --- |
| `enabled` | enables and disables logtest | yes | yes, no |
| `threads` | number of threads | 1 | 1-128 or auto |
| `max_sessions` | number of open sessions | 64 | 1-500 |
| `session_timeout` | minimum idle time that closes a session | 15m | number with suffix s, m or h, at most 365d |

The output has three phases: pre-decoding (syslog header), decoding (decoder and fields) and filtering (rule). For the first sample, phase 2 should show the `example-bmc` decoder and three fields, and phase 3 should show rule 100011 at level 8. These are values expected from the definitions, not a recorded result.

I change one element at a time and write down the expected result of each phase before running it:

| Input | Expected phase 2 | Expected phase 3 |
| --- | --- | --- |
| unchanged sample | decoder `example-bmc`, three fields | rule 100011 |
| `src=198.51.100.7` | decoder `example-bmc`, three fields | rule 100010, because the address is outside the range |
| `event=login_ok` | `bmc_event` equal to `login_ok` | no 100010 or 100011, because `field` does not match |
| program `example-other` | no `example-bmc` decoder | no rule |
| `example-bmc: heartbeat ok` | no `bmc_event`, `user` or `srcip` fields | no rule |

The last row catches the assumption that every event of a program has the same layout. The phases are explained in the [article on wazuh-logtest](/en/blog/wazuh-logtest/).

Saving the files is enough for a test in logtest. The manager must be restarted to generate alerts from changed definitions:

```bash
systemctl restart wazuh-manager
# or on SysV init
service wazuh-manager restart
```

## Built-in decoder

When a default decoder parses a log badly, I do not edit the file in `/var/ossec/ruleset/decoders/`. The documentation describes another way: I copy the file to `/var/ossec/etc/decoders/`, set the owner and permissions, exclude the original from the load list and change the copy.

```bash
chown wazuh:wazuh /var/ossec/etc/decoders/0310-ssh_decoders.xml
chmod 660 /var/ossec/etc/decoders/0310-ssh_decoders.xml
```

```xml
<ruleset>
  <decoder_dir>ruleset/decoders</decoder_dir>
  <rule_dir>ruleset/rules</rule_dir>
  <decoder_dir>etc/decoders</decoder_dir>
  <rule_dir>etc/rules</rule_dir>
  <decoder_exclude>ruleset/decoders/0310-ssh_decoders.xml</decoder_exclude>
</ruleset>
```

The excluded file does not receive fixes from updates, and the copy stays unchanged, so I port the needed changes by hand. For the BMC format a custom decoder is enough. The syntax is covered in the [guide to custom decoders](/en/blog/wazuh-custom-decoders/), and the file order in the [description of ruleset loading](/en/blog/wazuh-ruleset-loading/).

## What the documentation does not define

The Wazuh documentation does not define the format of IPMI, Redfish or BMC events, common field names across vendors, controller configuration for sending syslog, or a universal rule level for such events. The sample and the field names are examples. Before deployment I replace them with values confirmed in the real log and in the documentation of the source vendor.

## Sources

- https://documentation.wazuh.com/current/user-manual/manager/event-logging.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/localfile.html
- https://documentation.wazuh.com/current/user-manual/ruleset/decoders/custom.html
- https://documentation.wazuh.com/current/user-manual/ruleset/rules/custom.html
- https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/decoders.html
- https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/rules.html
- https://documentation.wazuh.com/current/user-manual/ruleset/testing.html
