Testing Wazuh rules and decoders with wazuh-logtest

Use wazuh-logtest to see what a log decodes to and which rule fires before a change reaches production, and learn where the test stops being reliable.

On this page

How to test Wazuh rules and decoders with wazuh-logtest before deployment

wazuh-logtest is the Wazuh server tool that shows how a single log line is decoded and which rule, if any, fires on it. Teams reach for it when they are about to deploy a custom decoder or rule and need evidence that the change parses the right fields and matches the intended detection, before the change touches live agent traffic. It runs inside the Wazuh server, which is one of the four components alongside the Wazuh indexer, the Wazuh dashboard and the agents on endpoints. Because the Wazuh server is distributed under the GNU General Public License version 2, the tool is part of the open-source platform your team already reviews, with no separate license to buy.

The tool checks three things in order: whether a pre-decoder and decoder extract the fields you expect, whether a rule matches those fields at the level you intend, and whether any frequency or timeframe logic behaves as designed across a sequence of events. Run it with a representative sample of real log lines from the source system, including malformed and edge-case entries, and record the decoded output next to the expected result. Confirm the exact command syntax, session behavior and output format for your release in the Wazuh documentation, since these details can change between 4.14 patch releases.

Treat wazuh-logtest as the first gate, not the only one. It validates content on one server against the lines you give it, so it cannot prove that a source system will send those lines in production, that agents forward them, or that the rule does not flood the dashboard. Plan a staging step that replays the same samples through a test deployment, and keep the logtest transcripts with the change request so reviewers can see what was tested and what was expected.

Log flow through wazuh-logtest phases

A sample log enters wazuh-logtest and passes pre-decoding, which extracts the timestamp, hostname and program name, then decoding, which matches a decoder and pulls out fields. The rule phase then tests the decoded event against rules. Check the decoder name and extracted fields at the decoding step, and the rule ID and alert level at the end. Two outcomes need attention: no decoder match, where the log falls through without fields, and no rule match, where the decoded event triggers nothing.

Phases a sample log passes through in wazuh-logtest, with the checks a tester makes at each stage.

Which logtest inputs and modes fit each testing need

This table compares the three ways to test Wazuh detection content: the interactive wazuh-logtest session on the server, sessions that keep state for frequency rules, and the dashboard ruleset test. Read each row to see what the method checks, when it fits, and where it stops, then pick the method that matches the rule or decoder you are changing.

Test methodWhat it checksWhen it fitsLimits to plan for
Interactive wazuh-logtest on the serverPre-decoding, decoding and rule matching for one pasted log line, with the decoder and rule that firedQuick checks while writing a new decoder or rule and confirming a sample log decodes as expectedRuns on the Wazuh server with server access, is manual, and does not verify rules after future changes
Logtest session with state keptFrequency and timeframe rules that depend on earlier events in the same sessionTesting correlation rules that need several sample events before the alert level is reachedState only lasts for the session, so a new session starts from zero and results depend on event order
Dashboard ruleset testDecoding and rule matching for a submitted log sample through the web interfaceAnalysts and reviewers who need to check a sample without shell access to the serverConfirm in the documentation which roles can use it and how closely it matches server-side results
Repeatable test pipelineExpected rule matches for a stored set of sample logs after each changeCatching regressions after upgrades or rule edits, once the team treats detection content as codeRequires building the harness yourself, and the logtest API usage should be confirmed in the documentation

Testing frequency rules and sessions without false passes

A single-event rule matches one decoded log on its own. When you send that log to wazuh-logtest, the output shows the fields the decoder extracted and the rule that matched, so one test can confirm the rule fires. Use a raw sample copied from the source system, keeping spacing, timestamps and punctuation exactly as the system wrote them, because small differences can change which decoder runs.

  • Decoded fields: Confirm each field the rule checks appears in the output with the expected name and value.
  • Matched rule: Check that your rule is the one reported, not a broader parent rule that also matches the line.
  • Level and description: Confirm the level and description match what analysts will see in the dashboard.
  • Negative samples: Feed lines that should not match and confirm that no alert is produced.
  • Log variants: Test every format the source produces, including error messages and lines from different software versions.

Check that each sample line produces the rule ID and level you documented before you copy the rule to the server.

Running a first logtest on your decoder and rule

This sequence checks, before anything reaches production, that a real log line is parsed by the decoder you wrote, that the intended rule fires at the intended level, and that unrelated logs stay quiet. It produces a short, repeatable record of what each sample decodes to and which rule it triggers.

  1. Collect representative sample logs from the source

    The detection engineer copies raw log lines from the real source system, such as the application log file, the device syslog output or the cloud audit export, rather than writing them from memory. Include variants that differ in message format, optional fields and timestamp style, and keep each line exactly as the source wrote it. Store the samples in a file the team can reuse. The step is done when every event you want to detect has at least one untouched sample and you can name the source system for each.

  2. Confirm custom files are loaded on the server

    On the Wazuh server, the engineer checks that the custom decoder and rule files sit in the local decoder and rule directories, and that the file names and permissions match what the server expects. Confirm the files are the versions in your change record, not an older copy from a previous session. Then restart or reload the manager according to the procedure for your installed version, and confirm the service is running without configuration errors in its log. Confirm the exact paths and reload method against the documentation for your release, since they can differ between versions. The step is done when the server starts cleanly and the files you edited are the ones it reads.

  3. Run wazuh-logtest with a sample line

    The engineer starts wazuh-logtest on the Wazuh server with the command-line tool and pastes one sample line at the prompt. The tool runs the line through the three phases of analysis: pre-decoding, decoding and rule matching, and prints the result of each. Run one sample at a time at first so each output maps to a single input. Note any error the tool prints about the line before reading the rest of the output. The step is done when the tool returns a result for the sample without errors, and the sample's output is saved next to the sample file.

  4. Check the decoder name and extracted fields

    In the phase two output, the engineer confirms that the decoder named in the result is the custom decoder you wrote, not a generic decoder that happened to match. Compare each extracted field, such as the user, source address or action, against the value in the raw line. A field that is missing, truncated or assigned to the wrong name will break any rule that depends on it, so fix the regular expression or the field order and rerun. The step is done when the decoder name matches the intent and every field a rule uses has the expected value.

  5. Confirm the rule ID and level

    In the phase three output, the engineer checks which rule fired, its rule ID, its level and its description. Confirm the ID falls in your custom range, the level matches the severity agreed for that event, and the description reads well enough for an analyst to act on it. If a default Wazuh rule fired instead, or no rule fired, check the parent and child rule relationship, the decoder name the rule expects and the field conditions. The step is done when the expected rule fires with the expected ID and level for every positive sample.

  6. Test negative samples and edge cases

    Repeat the process with lines that should not trigger the rule, such as successful logins when you are only detecting failures, or the same event from an approved source. Include malformed lines and lines from neighboring applications that share some text. A rule that fires on a negative sample is too broad, and one that never fires on a valid variant is too narrow. Record the outcome for each negative sample in the same file as the positives. The step is done when no negative sample triggers your rule and any gaps are logged as open issues before the content goes further.

  7. Save the results as a repeatable record

    The engineer stores the sample file, the logtest output for each line and the decoder and rule file versions in the detection repository or change ticket. A reviewer should be able to rerun the same samples later and get the same decoder name, fields, rule ID and level. This record is also the starting point for automated testing of the same content. The step is done when a second person can reproduce the results from the stored files without access to the original session.

Handling real logs safely during rule tests

Logtest runs against live decoders and rules, and the sample logs you paste into it often contain personal data or credentials. The cards below cover who may test, where samples live and how decoder changes are approved, so that testing does not create a new exposure.

Sanitize samples before pasting

Production logs often carry usernames, email addresses, client IP addresses, session tokens and API keys inside messages. Logtest output echoes the full log back, so a pasted sample can be copied into a ticket or a screenshot. Replace personal data and credentials with consistent placeholder values that keep the field structure intact, so the decoder still matches. Check that the placeholders still trigger the rule you are testing before you save the sample.

Limit who runs logtest

Logtest is an administrative tool on the Wazuh server, so anyone who can run it on a production node can read decoder output and rule logic. Decide in writing which roles may use it, and keep those roles separate from people who can change decoder or rule files. Ask your team how server access is granted and logged, since the tool itself does not replace access control on the host.

Keep samples in a controlled repository

Store test samples in a version-controlled repository with the decoders and rules they test, not in personal notes or chat threads. Restrict read access to the people who maintain detections, and set a retention rule for samples that carry any residual personal data. A sample that matches an expected rule is useful evidence, so record the expected decoder name and rule ID next to it.

Put decoder changes under change control

A decoder change can alter how every matching log is parsed, and a broken parent decoder can silence alerts from several sources at once. Require a reviewed change for each decoder edit, with the logtest output before and after attached. Confirm who approves production deployment and how the change is rolled back if the new decoder stops matching real events.

Test on a non-production node first

Where your architecture allows, run logtest against a staging Wazuh server loaded with the same decoders and rules as production. Logtest sessions on a production node consume the same resources as the analysis pipeline, so heavy testing during busy hours can affect live alert processing. Confirm the staging ruleset matches production before trusting a passing result.

Questions teams ask before testing Wazuh rules

Is wazuh-logtest free to use with the open-source Wazuh server?

Yes, wazuh-logtest is part of the Wazuh server, and the self-hosted Wazuh software is open source under the GNU General Public License version 2 with no license fee. The license is not the main cost, though. Your team pays for the infrastructure the server runs on, the time to build and review sample logs, and any outside help you buy. Wazuh Cloud is a separate, managed service with its own paid tiers, so confirm which deployment you are costing before you compare numbers.

How long does testing Wazuh rules and decoders take?

No fixed duration applies, because the effort depends on the work in front of you. The main drivers are the number of log sources, how complex the decoders and rules are, and how good your sample logs are. A few well-chosen samples from each source go much faster than an unlabeled export of production traffic. Ask any partner for a written scope that lists the sources, the rule count, the sample collection method and the review steps, then compare the effort against that list.

Can an internal team test Wazuh rules and decoders on its own?

Yes, a team with Linux administration skills and some familiarity with Wazuh decoders and rules can run wazuh-logtest on its own. The work is repetitive and rewards discipline: keep a set of representative logs, record the expected decoder and rule for each one, and repeat the check after every change. Teams that lack this experience often find the hardest part is building realistic samples and understanding why a rule did not fire, so a short outside review can be useful for that step.

What does a partner need from our team to test Wazuh content?

A partner needs access to a Wazuh test environment or a copy of your server configuration, sample logs from each source in the same format your agents send them, and the rules or decoders you already run. Owners of the log sources should confirm what each event means and which events must alert. Agree in writing who approves changes and who can grant access to the environment. Missing samples are the most common cause of delay, so ask for them before the engagement starts.

When should we move Wazuh rule testing into CI?

Move testing into CI once rules and decoders are stored in version control and change more than occasionally. A pipeline that replays sample logs through the logtest API catches a broken decoder or a rule that stopped matching before it reaches the server. Start with manual logtest runs to learn what the expected output looks like, then automate the same checks. The CI pipeline and its session handling are covered in a separate topic on testing Wazuh rules in CI.

Why does a log event decode but no rule fire in wazuh-logtest?

A decoder can match a log while no rule matches the decoded fields, which usually means the rule expects a field name, value or format the decoder does not produce. Check the phase output in wazuh-logtest first, because it shows which decoder matched and which fields were extracted. Then compare those field names with the conditions in the rule, and confirm the rule's level is high enough for the output you expect. Keep the failing log as a test case so the fix stays fixed.

Does a passing wazuh-logtest result prove the rule works in production?

No, a passing result shows that the decoder and rule behave correctly for the samples you tested, not for every event your sources will send. Production logs vary in format, timing and volume, and frequency rules depend on the sequence of events they receive. Use logtest to confirm known cases, then validate with a controlled sample of live or replayed events in a non-production environment before you deploy. Ask any partner which test cases they will cover and which they will leave for your team to confirm.

How DeployOpen scopes and tests Wazuh detection content

DeployOpen plans, implements, tests and documents Wazuh detection content inside your own infrastructure, including the logtest checks that show how each sample log decodes and which rule fires. Engagements are fixed-scope, with the scope, deliverables and timeline agreed in writing before work starts.

How we scope

  • We inventory the log sources, sample events and detection goals that the decoder and rule work must cover.
  • The written scope lists which decoders, rules and frequency logic are in scope and which are excluded.
  • We confirm the Wazuh version and deployment method in use, since test results depend on the running server.

How we build

  • We write sample logs for normal, edge-case and malicious events and store them with the detection content.
  • We run each sample through wazuh-logtest to confirm the pre-decoding, decoding and rule phases behave as designed.
  • We test sessions and frequency rules with ordered event sequences, then check the dashboard ruleset test matches results.

How we hand over

  • You receive the decoders, rules, sample logs and logtest output that prove each expected match or non-match.
  • We document the test procedure so your team can rerun it after each change or Wazuh patch release.
  • Handover includes a review session where your analysts walk through the tests and ask questions about the results.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the initial handover.
  • Retainer work can rerun the logtest suite when Wazuh releases a new 4.14 patch or your log formats change.
  • Ask any partner to confirm how regression tests will be kept current and who approves changes to detection content.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.