Writing custom Wazuh rules lets you detect what the default ruleset misses
Custom rules are the part of the Wazuh server that decides which decoded events become alerts. The Wazuh server analyzes agent data with decoders and rules: decoders extract fields from a raw log line, and rules match those fields and assign each match an alert level and a description. When your team sends logs from an in-house application or an unsupported device, the decoder may already extract the data correctly, yet no default rule matches the events you care about. In that situation the logs are parsed but silent, and a custom rule is the mechanism that turns a specific event pattern into an alert your analysts can see.
Teams should separate two situations. If a default rule already matches the event and fires at the wrong level, or fires far too often for a benign cause, the first step is to adjust that existing rule, for example by overriding its level or suppressing known-good activity. If no rule covers the event at all, or the detection depends on a combination of fields from a source the ruleset does not know, a new rule is the right tool. Before writing anything, confirm which case applies by checking the decoded output of real sample events against the ruleset in a test environment. This keeps the custom content small and avoids duplicate alerts for the same behavior.
Custom rules must also survive upgrades. Wazuh releases arrive regularly within the 4.14 line, so the work should live in local rule files and use ID ranges and overwrite mechanisms that the upgrade process leaves intact, rather than editing the files Wazuh ships. Plan the ID range, the file names and a short description for each rule before the first deployment, and record who owns each rule. Ask your team to confirm, against the current release notes, that the local files and the ID scheme they chose are preserved by the upgrade steps in the environment they run.
How rule files, ID ranges and the local ruleset fit together
Custom Wazuh detections live in a small set of connected choices: where the rule file sits, which IDs it uses, how it links to shipped rules and how it is tracked over time. Getting one of these wrong usually shows up later as a silently overwritten rule or a broken upgrade, so review all four together before the first rule is deployed.
File placement in the local ruleset
Custom rules belong in the local rules directory on the Wazuh server, not in the files Wazuh ships and replaces during upgrades. Keep each custom file focused on one data source or detection area so reviewers can see what it covers. Confirm the exact local rules path and the file load order for your 4.14 release against the current documentation before you write the first file, because the path is the first thing an upgrade must preserve.
Wazuh release notesID allocation outside shipped ranges
Every rule needs a unique numeric ID, and a custom ID that collides with a shipped rule can change or hide detections the team depends on. Agree on one custom range for the organization, record which IDs are in use, and keep a register that new rules must join. Confirm the reserved range guidance for 4.14 in the current documentation, since the recommended range is the detail most likely to be revised.
Parent rule linkage
A custom rule usually extends a shipped parent rule through its if_sid or if_group element, so it only evaluates events the parent already matched. A wrong parent can make a rule fire on everything or on nothing. Check each parent ID against the shipped ruleset on your version, and test the child with real sample events so you know the link works in practice.
Version control and change review
The local rules directory is the only part of the ruleset that belongs to your team, so it should live in a Git repository with reviewed changes, a named owner and a record of which Wazuh version each rule was tested on. Pair each commit with a sample event and the expected rule ID. Ask your implementation partner or internal team how rule changes move from the repository to the production server, and who approves them.
Rule attributes and when each fits
This table compares the rule attributes you are most likely to use when writing custom Wazuh rules, with the job each one does and the mistake that tends to follow when it is misused. Read it as a checklist before you write a rule: start with the narrowest attribute that matches the event, and add matching or chaining only when a single event is not enough. Exact syntax and defaults belong in the Wazuh documentation for your release.
| Attribute | When it fits | What breaks if misused |
|---|---|---|
| id | Every custom rule needs a unique ID in the custom range so it survives upgrades and can be referenced by child rules | Reusing an ID from the default ruleset or another custom file can overwrite or shadow a rule you did not intend to change |
| level | Sets how severe the alert is, which drives dashboard views and any alert thresholds you route on | Setting levels high by default floods analysts with alerts; levels that are too low can hide events that should page someone |
| match and regex | Match literal text in the decoded log, or pattern-match fields when the log has a stable, specific string | Broad patterns match benign events too, and expensive regex across high-volume sources can slow analysis |
| if_sid and if_group | Chain a rule to a parent rule or rule group so it only evaluates events the parent has already classified | Pointing at the wrong parent means the child never fires; a broad parent group pulls in unrelated events |
| frequency and timeframe | Fire only when a number of matching events occurs within a time window, such as repeated failures from one source | Thresholds set too low create noise; a window that is too short misses slow activity. Check exact options in the documentation |
| overwrite | Changes a default rule's level or fields without copying the whole rule, for example to lower noise from a known benign event | Overwriting a rule you do not fully understand can silence a detection that other teams rely on, and the change is hard to spot later |
| description and groups | Give analysts a clear sentence about what happened and a group label they can filter and report on | Vague descriptions slow triage; missing groups make the rule invisible to dashboard filters and reporting |
Changing default rule levels with overwrite without losing upgrades
Editing the rule files that ship with Wazuh is the fastest way to lose a local change at upgrade time. The shipped rules under the default ruleset directory are replaced when you upgrade the Wazuh server, so any edit made there is either overwritten or conflicts with the new files. The supported approach is to keep the default rules untouched and place a local rule that uses the overwrite="yes" attribute on the rule ID you want to change. The local rule can then set a different level for the same event, and it can replace fields such as description or group in the default rule, without modifying the file that ships. Confirm the exact behavior of overwrite against the rule reference for your release before relying on it, because the set of fields it can change and the way it interacts with child rules are details to verify in your own environment.
The trade-off is that an override points at a default rule ID, and default IDs are not a permanent contract. Wazuh can change, split or renumber shipped rules between releases, so an override that matched rule 5710 last quarter may match nothing, or may silently change a different rule, after an upgrade. Treat every override as a dependency on the default ruleset. Keep a short register of each override with the default rule ID, the original level, the new level, the reason and the owner, and record the Wazuh version it was last tested against. Use the logtest workflow described elsewhere on this page to confirm that the intended events still produce the expected alert level after each change.
Recheck every override after each patch release, not only after major upgrades. Wazuh shipped 4.14 patch releases on 17 March, 23 April, 1 July, 29 July, 23 September and 14 October 2026, so a support team running this release line should expect a retest cycle every one to two months. Automate the check where you can: replay a fixed set of sample events for each overridden rule and fail the review if the level, group or description changes unexpectedly. Ask your Wazuh partner or internal team to document which release notes mention rule changes so the register can be updated before the upgrade reaches production.
Setting up a custom rule from sample log to deployed alert
This sequence takes one real log line from a source system to a custom rule that fires as a visible alert in the dashboard. Each step ends with a check, so the team knows the rule works before it reaches production.
Collect a representative sample log
The engineer who owns the source system copies one or more real log lines that show the event you want to detect, including a few near-miss lines that should not match. Store them in a version-controlled folder with the source name and collection date. The step is done when the sample set contains both positive and negative examples and the team agrees they reflect production output, not a hand-written guess. Confirm log format and any sensitive fields with the data owner before copying anything out of the environment.
Confirm the decoder extracts the fields
Run each sample through wazuh-logtest and read the decoding phase output. Check that the decoder name is the one you expect and that the fields the rule will use, such as the user, source address or action, appear with the correct values. If a field is missing, fix the decoder before writing any rule, because a rule cannot match a field that was never extracted. The step is done when every positive sample decodes with the expected decoder and every field the rule needs is present in the output.
Write the rule with a safe ID
Add the rule to the local rules file on the Wazuh server, which is the file meant for custom content so default rules are left untouched. Choose a rule ID from the custom range your team has documented, and check the ID is not already used in any file under the ruleset directories. Set a clear description, a level that matches the response expectation, and the match conditions taken from the decoded fields. The step is done when the file passes the syntax check that the documentation describes for the manager, and no duplicate ID warning appears.
Test the rule with wazuh-logtest
Feed the positive samples into wazuh-logtest and confirm the output shows your rule ID and description in the rule phase. Then feed the negative samples and confirm your rule does not fire on them. If a positive sample is silent, compare its decoded fields with the rule conditions and adjust the match. The step is done when every positive sample returns the expected rule ID and every negative sample returns none of your custom IDs. Keep the test output with the sample files so the result can be reviewed later.
Restart or reload the manager as documented
Apply the change on the Wazuh server using the restart or reload method the current release documentation specifies for rule changes, and check the manager service status afterward. Do this during a window your operations team has approved, and keep a copy of the previous rules file so you can roll back. The step is done when the manager reports healthy and the logs show no errors on startup related to the rules file. Confirm the exact command for your installed version in the documentation before running it.
Replay or generate a live event
Trigger the event on a test endpoint or replay a sample log through the normal collection path so the event travels through the agent, server and indexer as it would in production. This confirms that the source is actually sending the data to the server, which logtest cannot prove. The step is done when the raw event appears in the archives or in the server log for the source you tested. If it does not appear, the problem is in collection, not in the rule, so check the agent or syslog configuration first.
Confirm the alert in the dashboard
Open the Wazuh dashboard, filter the alerts view by your rule ID and the test agent or source, and confirm the alert shows the description, level and fields you set. Check that the alert carries the group tags your analysts will filter on. The step is done when the alert appears with the expected rule ID and fields, and a second person on the team can find it using the same filter. Record the rule ID, the file path and the test date in your change log before handing the rule to the detection owner.
How a log moves from agent to custom rule alert
The path starts on the endpoint, where the Wazuh agent collects a log and forwards it to the Wazuh server. The server runs pre-decoding and decoding, then evaluates rules from the default rule set and from your local rule file. The matched alert is stored in the Wazuh indexer and shown in the dashboard. Check the local rule file carefully, because it is the part your team owns and the part that must survive upgrades. Use wazuh-logtest to confirm which rule fires before you deploy.
Alert path from endpoint log to dashboard, with the local rule file marked as customer-owned.
Writing rule descriptions and groups analysts can act on
A rule description should tell an analyst three things in one line: what happened, which entity it happened to, and where to look first. A description such as "Multiple failed logins" leaves the analyst to open the event to learn the account, the source and the system. A better pattern names the event, then the affected entity drawn from a field the decoder extracted, then the first check to run, for example "Repeated failed sudo attempts by user $(dstuser) on host $(hostname), check whether the user changed role recently." Descriptions in Wazuh rules can reference captured fields in this way, so the decoder work in the decoders section determines how much detail the description can carry. Keep the text short enough to read in the alert list, and put longer guidance in the team's runbook, linked by the rule's ID.
Groups make alerts searchable and filterable after they fire. Each rule can carry a group attribute with one or more labels, and the dashboard and API can then select alerts by those labels. Use a small, stable vocabulary, such as one label for the source product or log type and one for the category of activity, and reuse existing labels where the default ruleset already uses them so that a single filter catches both custom and built-in rules. Changing a group name later breaks saved searches and dashboards, so agree the vocabulary before the first rule ships. Confirm the exact syntax for your Wazuh release in the rule syntax reference, and test a sample alert in the dashboard to check that the label appears where your analysts will look for it.
Mapping rules to MITRE ATT&CK is a separate, later step that builds on these descriptions and groups. The technique IDs are added as tags once the rule's behavior and wording are settled, so review descriptions first and tag after the rules have been tested with wazuh-logtest. Treat descriptions and groups as part of the rule's review checklist: an analyst who did not write the rule should be able to read the alert and know the next step. Whether this improves triage speed in your environment is something to measure with your own analysts rather than assume.
Security and operational risks of local rule changes
Local Wazuh rule changes are small files with large effects: a single level override or regex can hide alerts, slow the server, or expose data in the dashboard. The four cards below cover the risks that most often reach production, and each names the check that should catch it before a change ships.
Silent suppression through level overrides
A local rule that uses overwrite on a default rule can lower its level or change its behavior without any visible error. Analysts then stop seeing alerts they relied on, and nothing in the dashboard shows that a detection went quiet. Control: keep a register of every overwritten rule ID with its original level, the reason and the owner, and run a logtest case for each overwritten rule that asserts the expected level still fires. Review the register at each Wazuh upgrade.
Costly regex on high-volume logs
Rules and decoders that use broad or backtracking regular expressions run against every matching event, and on busy log sources that cost adds up on the Wazuh server. A pattern that works on sample lines can slow processing once real traffic arrives. Control: anchor patterns to a fixed prefix or program name, avoid nested quantifiers, and measure processing lag on a representative log volume before enabling the rule on production agents.
Sensitive values in descriptions
Rule descriptions and alert fields are stored in the Wazuh indexer and shown to every user with dashboard access. If a description copies a captured field such as a token, account number or patient identifier, that value is retained and visible beyond the people who need it. Control: write descriptions that name the event type only, reference captured fields by role rather than value, and review the ruleset for $ variables in description text during peer review.
Direct edits on the server
Editing files under the server's rules directory by hand leaves no history, no reviewer and no way to rebuild the server after a failure. Two administrators can also make conflicting changes that are hard to trace. Control: keep all local rule and decoder files in a Git repository, deploy them through a pipeline that runs logtest tests first, and block manual edits on the server with file permissions and access logs.
Questions buyers ask about writing custom Wazuh rules
Can our own security team write custom Wazuh rules without a partner?
Yes, a team with Linux administration skills and access to its log sources can write simple rules, and many do. The harder part is the ongoing discipline: keeping rule IDs in the correct range, testing every change against real logs, and documenting why each rule exists. Teams that already run a SIEM and understand their log formats usually start in-house. Teams without an engineer who can read decoders and XML rule syntax often engage a partner for the first rule set and then take over maintenance with a clear runbook. Ask your team to rewrite one existing rule from start to finish before deciding.
What drives the effort of writing Wazuh rules?
Effort scales mainly with three drivers: how many distinct log formats you need to parse, how many sources feed them, and how much testing your change process requires. A single application with well-structured logs is a small job. Many sources with inconsistent formats, nested JSON, or multi-line events add decoder work before any rule is written. Testing needs add effort when detections must be checked in a pipeline, reviewed by a second engineer, or traced to MITRE ATT&CK technique IDs. Ask any provider to break the quote down by source, decoder work, rule work and test work.
What do we need to provide before custom rule work starts?
You need representative sample logs from each source, including normal events and the security events you want to detect, plus access to the Wazuh manager or a test instance where rules can be loaded. Sample logs should cover the formats your systems produce across versions, because an upgrade on the source system can change the text a decoder expects. You also need a named owner for each detection who decides what an alert means and what analysts should do with it. Without triage owners, rules fire into a queue that nobody acts on, and the work produces noise rather than coverage.
Do custom Wazuh rules survive upgrades?
Custom rules survive upgrades when they live in the local rule and decoder files rather than in the default files that Wazuh ships and replaces. Use the documented custom rule ID range, avoid editing default rule files, and use the overwrite mechanism to change a default rule's level or behavior. Each upgrade still needs a check: a rule that depends on a default decoder or field can change meaning after a release, so re-run your logtest samples against the new version before rolling it out. Confirm the exact file paths and ID ranges against the Wazuh documentation for the release line you run, currently 4.14.
How long does it take to validate a first set of custom Wazuh rules?
The duration depends on how many sources the first set covers, how clean your sample logs are, and how much review your change process requires. There is no fixed timeline that applies across environments, so ask for a schedule tied to a written scope. A reasonable first milestone is validation of one source end to end: decode the sample logs, confirm the expected rule fires, confirm benign events do not, and confirm the alert reaches the dashboard with the fields analysts need. Repeat that cycle per source. Plan extra time for approvals and for the first alert review with your analysts, because most rework surfaces there.
Can a partner write rules for our data without seeing production logs?
Usually not well. Rules depend on the exact text your applications and devices emit, so sample logs from your environment are the most important input. Where production logs contain personal or regulated data, agree on redaction or a secure transfer method before sharing them, and ask whether synthetic samples that match the format can be used for the first pass. Confirm handling terms in writing as part of the scope. The engagement should not require access to data beyond what the detections need.
What should we check to confirm a custom rule is working?
Check four things before relying on a rule: the log decodes into the fields you expect, the intended rule fires on the malicious or suspicious sample, benign samples do not fire it, and the resulting alert shows a description that an analyst can act on. Wazuh's logtest tool supports the first three checks against a single log line. Repeat the tests after each change and after each Wazuh upgrade. Keep the sample set in version control so that a regression is caught by someone other than the author.
How DeployOpen scopes and delivers custom Wazuh rule work
DeployOpen plans and implements custom Wazuh detection content inside your own infrastructure, and most engagements are fixed-scope, with the detections to be written, the log sources covered and the deliverables agreed in writing before any rule file is touched. The scope usually names the log sources and the events each detection must catch, the Wazuh server version it targets, and where the custom files will live on the server. Clients who run their own change control should confirm early whether the work goes through a repository and a review step, because that decision shapes how the files are delivered and tested.
A typical delivery covers sample logs collected from your systems, the decoder and rule files themselves, test evidence showing which sample events decode and which rules fire, and handover documentation that explains each rule's ID, level, description and the reasoning behind it. Ask for the handover to include the rule ID range in use, the list of default rules overridden with overwrite, and the steps an analyst should follow when an alert fires. These artifacts are what your team will rely on after the engagement ends, so they should be readable without the consultant present.
Because Wazuh releases patches regularly, custom content needs ongoing attention. DeployOpen offers optional retainers for rule maintenance across upgrades, covering review of overridden default rules after each release and retesting of custom detections against current sample logs. Confirm with your provider how a retainer is priced and what it includes, and ask whether upgrade retesting is part of the base scope or an add-on. The written scope should state these terms so that maintenance responsibility is clear before the first upgrade.

