How to Use Wazuh Dynamic Fields to Extract Custom Log Data

Modern IT environments generate enormous volumes of logs from cloud services, SaaS platforms, firewalls, operating systems, containers, APIs, and custom applications. While many of these logs follow standardized formats, an increasing number use nested JSON structures, proprietary field names, and application-specific metadata that traditional security monitoring tools struggle to parse efficiently. This is where Wazuh Dynamic Fields become valuable.

Dynamic fields allow Wazuh to extract virtually unlimited pieces of information from incoming logs instead of being restricted to a predefined set of static fields.

Rather than forcing every log into the same rigid structure, dynamic fields let decoders create new field names on demand, making it possible to parse complex JSON documents, cloud events, API responses, and custom application logs with far greater flexibility.

Whether you’re building custom decoders for an internal application, monitoring Kubernetes workloads, ingesting cloud logs, or integrating third-party security products, understanding dynamic fields is essential for writing scalable detection rules and improving alert quality.

In this guide, you’ll learn:

  • What Wazuh Dynamic Fields are
  • How they work inside the decoder engine
  • Why they’re better than traditional static fields
  • How to create decoders that extract custom fields
  • Best practices for naming, performance, and troubleshooting
  • Real-world examples for parsing modern log formats

By the end, you’ll understand how to use Wazuh Dynamic Fields to extract meaningful security data from virtually any log source.


What Are Wazuh Dynamic Fields?

 

Definition of Dynamic Fields

Dynamic fields are custom field names created by Wazuh decoders during log processing.

Instead of storing extracted values only in a limited collection of predefined fields, dynamic fields allow decoders to generate descriptive field names that match the structure of the original log.

For example, instead of only extracting:

  • srcip
  • dstip
  • user
  • action

a decoder can create fields such as:

cloud.account.id
cloud.region
http.request.method
http.response.code
container.image.name
kubernetes.namespace
authentication.mfa.enabled

These fields become part of the decoded event and can later be referenced inside detection rules, dashboards, searches, and alert outputs.

Unlike static fields, dynamic fields aren’t limited by a fixed schema, making them ideal for today’s increasingly complex log formats.

For more information about creating custom decoders, see Wazuh Decoder Guide.

For the official decoder documentation, see https://documentation.wazuh.com/current/user-manual/ruleset/decoders/index.html

How They Differ from Static Fields

Historically, Wazuh decoders extracted data into a predefined list of static fields such as:

  • srcip
  • dstip
  • hostname
  • location
  • user
  • program_name
  • status
  • action

These fields work well for common operating system and network logs but become limiting when parsing modern JSON-based applications.

For example, consider the following log:

{
  "tenant":"acme",
  "cloud":{
      "region":"us-east-1",
      "account":"123456789"
  },
  "user":{
      "name":"alice",
      "department":"Finance"
  }
}

Using only static fields would force many of these values to be ignored or awkwardly mapped into unrelated field names.

Dynamic fields eliminate this limitation by allowing the decoder to preserve the original structure:

tenant
cloud.region
cloud.account
user.name
user.department

The result is cleaner, more meaningful data that is easier to search and build detection logic around.

Why Dynamic Fields Were Introduced

Modern security monitoring has evolved far beyond traditional syslog messages.

Today’s organizations collect telemetry from:

  • Cloud platforms
  • Kubernetes clusters
  • Container runtimes
  • Identity providers
  • SaaS applications
  • REST APIs
  • Endpoint security products
  • Custom business applications

Many of these sources generate nested JSON documents containing dozens, or even hundreds, of unique fields.

Maintaining a fixed list of supported field names simply doesn’t scale.

Dynamic fields were introduced to allow Wazuh decoders to adapt to virtually any log structure without requiring the ruleset to continually expand its predefined schema.

This makes Wazuh significantly more flexible for modern security operations and custom integrations.

The official Wazuh documentation recommends dynamic fields when parsing JSON and custom data structures because they provide a scalable way to extract structured information from diverse log sources.

Benefits for Parsing Modern Log Formats

Dynamic fields provide several practical advantages over traditional decoding approaches.

Some of the biggest benefits include:

  • Extract information from deeply nested JSON objects
  • Preserve descriptive field names
  • Support logs containing dozens or hundreds of attributes
  • Simplify integrations with cloud-native platforms
  • Improve alert readability
  • Enable highly specific detection rules
  • Reduce decoder maintenance
  • Support proprietary log formats without schema limitations

These capabilities are especially useful when monitoring technologies such as Kubernetes, cloud services, and custom web applications.

If you’re monitoring Kubernetes environments, see How to Monitor Kubernetes Using Wazuh.

Common Use Cases

Dynamic fields are useful anywhere logs contain rich structured data.

Common examples include:

  • AWS CloudTrail events
  • Azure activity logs
  • Google Cloud audit logs
  • Kubernetes audit logs
  • Docker container logs
  • REST API request logs
  • Identity provider authentication logs
  • Endpoint Detection and Response (EDR) telemetry
  • Custom enterprise applications
  • Business application audit logs

For example, an authentication application may expose fields such as:

authentication.method
authentication.mfa
device.id
risk.score
session.id
geo.country
geo.city

Instead of discarding this information, dynamic fields preserve it so that detection rules can identify suspicious combinations such as failed MFA attempts from high-risk countries or repeated logins from unknown devices.

If you’re ingesting AWS logs, see How to Monitor AWS CloudTrail Logs Using Wazuh.


How Wazuh Dynamic Fields Work

 

Decoder Processing Pipeline

Dynamic fields are created during Wazuh’s normal log decoding process.

The simplified pipeline looks like this:

Log arrives
      │
      ▼
Pre-decoding
      │
      ▼
Parent decoder matches
      │
      ▼
Child decoder extracts fields
      │
      ▼
Dynamic fields created
      │
      ▼
Rules evaluate extracted values
      │
      ▼
Alert generated

During decoding, Wazuh identifies the appropriate decoder, applies regular expressions or JSON parsing, and assigns captured values to dynamic field names defined by the decoder configuration.

For a deeper understanding of decoder processing, see Wazuh Decoder Guide.

Field Extraction During Decoding

Once a decoder matches an incoming log, Wazuh extracts values from the message using decoder directives such as regular expressions, JSON parsing, or plugin decoders.

Each captured value is then assigned to its corresponding field name.

For example:

{
  "username":"alice",
  "department":"Finance",
  "country":"Canada"
}

can become:

user.name = alice
user.department = Finance
geo.country = Canada

These extracted fields remain attached to the event throughout the remainder of the processing pipeline, allowing rules to reference them later.

Testing extracted fields before deploying them into production is considered a best practice.

You can validate decoder output with How to Use Wazuh Logtest.

Dynamic Field Naming

One of the biggest strengths of dynamic fields is descriptive naming.

Rather than using generic field names, you can organize related information into logical namespaces.

Examples include:

http.request.method
http.request.uri
http.response.code
cloud.account.id
cloud.region
container.image
container.name
authentication.user
authentication.result
device.hostname

This hierarchical naming makes complex alerts much easier to understand and maintain, especially when multiple teams share detection rules across large environments.

Consistent naming conventions also reduce confusion when developing custom rules.

Relationship Between Decoders and Rules

Dynamic fields are only useful if detection rules can reference them.

The workflow is straightforward:

  1. Decoder extracts data.
  2. Dynamic fields are created.
  3. Rules evaluate those fields.
  4. Matching rules generate alerts.

For example:

authentication.result = failed
authentication.user = alice
geo.country = Russia

A custom rule can then generate an alert whenever authentication failures originate from unexpected geographic locations.

This separation between parsing and detection makes Wazuh rules easier to maintain because changes to log formats are often isolated to the decoder rather than requiring every detection rule to be rewritten.

If you’re creating custom detections, see How to Create Custom Detection Rules in Wazuh (With Examples).

How Extracted Fields Appear in Alerts

After decoding and rule evaluation, dynamic fields become part of the generated alert.

They can typically be viewed in:

  • Wazuh Dashboard
  • JSON alert output
  • API responses
  • OpenSearch indexes
  • Search queries
  • Dashboards and visualizations

This allows analysts to filter alerts using custom fields that didn’t exist in Wazuh’s original predefined schema.

For example, instead of searching only by username or IP address, analysts can search for:

cloud.region = us-east-1
authentication.mfa = false
device.serial = ABC12345
application.version = 5.7.2

This richer context significantly improves investigations and threat hunting.


Why Use Dynamic Fields Instead of Static Fields?

 

Unlimited Field Extraction

One of the biggest limitations of static fields is their finite number.

As applications become more complex, a single event may contain dozens of meaningful attributes.

Dynamic fields remove this limitation by allowing decoders to extract as many relevant values as needed, making them well suited for cloud-native and enterprise applications.

Better Support for JSON Logs

JSON has become the standard logging format for cloud services, containers, APIs, and modern software platforms.

Dynamic fields naturally preserve JSON hierarchies instead of flattening them into unrelated static fields.

This results in cleaner data models, more intuitive searches, and simpler detection rules.

According to the OpenTelemetry Logs Data Model, structured log attributes provide richer machine-readable context than unstructured text, improving downstream analysis and interoperability.

Easier Parsing of Proprietary Applications

Many organizations develop internal applications with unique logging formats that don’t align with standard schemas.

Dynamic fields allow decoders to mirror these proprietary structures instead of forcing developers to rename or discard valuable information.

This reduces the effort required to integrate custom applications into Wazuh while preserving important business context.

Reduced Decoder Complexity

Without dynamic fields, developers often need numerous decoders or cumbersome field mappings to accommodate different log structures.

Dynamic fields simplify decoder design by allowing meaningful field names to be assigned directly during extraction.

This produces cleaner XML configurations that are easier to read, maintain, and extend over time.

When dealing with more advanced parsing scenarios, combining dynamic fields with parent-child decoders can further reduce duplication.

See How to Map Complex Log Fields Using Wazuh Parent Child Rules.

Improved Rule Flexibility

Detection rules become significantly more expressive when they can reference descriptive field names instead of generic placeholders.

For example, a rule can evaluate:

authentication.mfa = false
risk.score > 80
device.trusted = false
cloud.region = eu-west-1

rather than relying on ambiguous static mappings.

Security practitioners, including contributors to the MITRE ATT&CK knowledge base, consistently emphasize the importance of rich contextual telemetry for improving detection engineering and reducing false positives.

Dynamic fields support this approach by preserving more of the original event context, enabling higher-fidelity analytics and more precise detections.


Common Use Cases for Wazuh Dynamic Fields

Dynamic fields are most valuable when logs contain rich, structured data that cannot be adequately represented using Wazuh’s predefined static fields.

They allow security teams to preserve important contextual information, making alerts more informative and detection rules more precise.

Below are some of the most common scenarios where dynamic fields significantly improve log parsing and threat detection.

Cloud Provider Logs

Cloud platforms generate JSON-based logs containing detailed information about identities, resources, regions, API operations, and network activity.

These logs often include dozens of nested attributes that are difficult to map using static fields.

For example, an AWS CloudTrail event may contain fields such as:

{
  "eventSource": "ec2.amazonaws.com",
  "eventName": "RunInstances",
  "awsRegion": "us-east-1",
  "userIdentity": {
    "type": "IAMUser",
    "userName": "alice"
  },
  "sourceIPAddress": "203.0.113.25"
}

A custom decoder can extract these as dynamic fields:

cloud.provider = aws
cloud.region = us-east-1
cloud.service = ec2
event.name = RunInstances
identity.user = alice
network.source.ip = 203.0.113.25

This enables highly targeted rules, such as detecting privileged API calls originating from unfamiliar regions or unauthorized account activity.

For AWS monitoring, see How to Monitor AWS CloudTrail Logs Using Wazuh.

Kubernetes Audit Logs

Kubernetes audit logs are deeply nested JSON documents containing information about clusters, namespaces, pods, users, API operations, and resource types.

Instead of flattening this information, dynamic fields preserve the original hierarchy:

kubernetes.namespace
kubernetes.pod.name
kubernetes.container.name
kubernetes.resource.kind
kubernetes.user.username
kubernetes.verb

Security teams can then create rules for activities such as:

  • Unauthorized pod creation
  • Secret access
  • Privilege escalation
  • Changes to RBAC policies
  • Deployment modifications

These descriptive fields make investigations significantly easier because analysts can immediately identify which Kubernetes resources were affected.

See How to Monitor Kubernetes Using Wazuh.

Web Application Logs

Modern web applications frequently log structured request and response data.

Dynamic fields can extract values such as:

http.request.method
http.request.uri
http.request.user_agent
http.response.code
application.response_time
session.id

These fields allow Wazuh to detect events including:

  • Repeated HTTP 401 responses
  • Administrative endpoint access
  • Suspicious user agents
  • Directory traversal attempts
  • Unusual response codes

Rather than writing separate decoders for each application, developers can reuse consistent field names across multiple services.

API Gateway Logs

API gateways generate logs containing valuable information about clients, authentication methods, request paths, and rate limiting.

Useful dynamic fields include:

api.client.id
api.key.id
api.endpoint
api.version
api.request.id
api.response.status
api.latency

These fields enable rules that detect:

  • Excessive API requests
  • Unauthorized endpoint access
  • Invalid authentication tokens
  • Rate-limit violations
  • Requests originating from unexpected geographic locations

The additional context also improves incident investigations by making API activity easier to correlate across multiple services.

Firewall Events

Next-generation firewalls often generate structured logs with numerous networking attributes beyond simple source and destination IP addresses.

Dynamic fields can capture information such as:

firewall.rule.name
firewall.policy.id
network.application
network.protocol
network.bytes_sent
network.bytes_received
threat.category

This allows analysts to identify:

  • Policy violations
  • Malware detections
  • Unexpected application traffic
  • Excessive bandwidth usage
  • Unauthorized outbound connections

For firewall integrations, see How to Collect Firewall Logs in Wazuh.

Authentication Systems

Identity providers and authentication platforms produce rich audit logs containing user, device, location, and authentication metadata.

Examples include:

authentication.user
authentication.method
authentication.result
authentication.mfa
device.hostname
device.id
geo.country
risk.score

These fields support advanced detections such as:

  • Impossible travel
  • MFA bypass attempts
  • Repeated login failures
  • High-risk sign-ins
  • New device registrations

Compared to traditional static fields, dynamic fields preserve much more context surrounding each authentication event.

SaaS Application Logs

Organizations increasingly rely on SaaS platforms that expose detailed audit logs through APIs.

Applications such as Microsoft 365, Google Workspace, GitHub, Slack, Salesforce, and numerous security platforms generate JSON events containing organization-specific metadata.

Dynamic fields make it easy to preserve information such as:

organization.id
repository.name
workspace.id
document.owner
application.module
audit.operation

This allows organizations to monitor administrative actions, configuration changes, permission modifications, and suspicious user activity without creating dozens of specialized decoders.

Custom Business Applications

One of the most common uses of dynamic fields is parsing internally developed software.

Every organization has applications with unique logging formats that contain business-specific information.

Examples include:

customer.id
invoice.number
order.total
payment.status
warehouse.location
device.serial
employee.department
transaction.id

By preserving these fields, Wazuh can detect both security threats and business anomalies, such as unauthorized financial transactions, unusual inventory changes, or suspicious customer account activity.

Dynamic fields allow organizations to model their logs around their own business terminology instead of forcing everything into a generic schema.


Prerequisites

Before creating decoders that use dynamic fields, ensure your Wazuh environment is properly configured.

Having the right tools and permissions in place will make development and troubleshooting much easier.

Working Wazuh Manager

Dynamic fields are generated by Wazuh decoders running on the Wazuh Manager.

Verify that the manager is installed, operational, and successfully receiving logs from your agents or integrations.

If custom decoders fail to load, no dynamic fields will be extracted regardless of their configuration.

For deployment guidance, see The Complete Wazuh Cluster Architecture Guide.

Access to Custom Decoder Files

You’ll need permission to edit the decoder configuration files stored on the manager.

Custom decoders are typically placed inside the local decoder directory so they remain separate from the default Wazuh ruleset and are easier to maintain during upgrades.

Keeping custom decoders isolated also simplifies version control and rollback procedures.

For decoder fundamentals, see Wazuh Decoder Guide.

Sample Log Data

Always develop decoders using representative production logs rather than simplified examples.

Your sample logs should include:

  • Normal events
  • Edge cases
  • Missing fields
  • Malformed entries
  • Different application versions

Testing against realistic data helps ensure your decoder continues working as log formats evolve.

Administrative Privileges

Creating or modifying decoders typically requires administrative access to the Wazuh Manager.

You’ll generally need permission to:

  • Edit decoder files
  • Restart Wazuh services
  • Review manager logs
  • Execute validation tools
  • Inspect generated alerts

Without sufficient privileges, decoder changes cannot be applied.

Familiarity with Regular Expressions

Although JSON plugin decoders reduce the need for complex pattern matching, many custom decoders still rely on regular expressions to identify and extract values.

Understanding concepts such as:

  • Character classes
  • Capture groups
  • Anchors
  • Quantifiers
  • Escaping special characters

will make decoder development considerably easier.

The official regular expression reference provided by the PCRE2 project is an excellent resource for learning advanced regex syntax.

Wazuh Logtest Installed for Validation

Before deploying a decoder into production, validate it using wazuh-logtest.

This utility shows:

  • Which decoder matched
  • Extracted dynamic fields
  • Rule evaluation
  • Generated alerts
  • Parsing errors

Using Logtest during development dramatically reduces troubleshooting time and helps identify extraction issues before they affect production monitoring.

See How to Use Wazuh Logtest.


Understanding Dynamic Decoder Syntax

Dynamic fields are defined within Wazuh decoders using XML elements that specify what data should be captured and how it should be named.

Understanding these building blocks is essential for creating reliable, maintainable decoders.

Dynamic Field Names

Unlike static fields, dynamic fields can use descriptive names that closely match the structure of the original log.

Examples include:

cloud.region
cloud.account.id
http.request.method
authentication.user
authentication.result
container.image
device.serial
risk.score

Choose names that are:

  • Descriptive
  • Consistent
  • Easy to search
  • Reusable across applications

Using a standardized naming convention also simplifies rule creation and dashboard development.

Using the <order> Element

The <order> element determines how captured values from a decoder are assigned to field names.

Each capture group in the decoder’s regular expression is mapped to a corresponding field listed in <order>.

For example:

<decoder name="custom-app">
  <regex>User=(\S+) IP=(\S+) Action=(\S+)</regex>
  <order>authentication.user,network.source.ip,event.action</order>
</decoder>

In this example:

  • The first capture group becomes authentication.user
  • The second becomes network.source.ip
  • The third becomes event.action

Keeping the order aligned with the regex capture groups is critical. If they don’t match, fields may receive incorrect values or fail to populate altogether.

For more information, refer to the official Wazuh decoder documentation.

Regex Capture Groups

Regular expressions define which parts of a log should be extracted.

Each set of parentheses creates a capture group that can be assigned to a dynamic field.

Example:

User=alice IP=192.168.10.15 Status=Failed

Regex:

User=(\S+)\s+IP=(\S+)\s+Status=(\S+)

Produces:

authentication.user = alice
network.source.ip = 192.168.10.15
authentication.status = Failed

When writing complex decoders, use only the capture groups you intend to map to fields.

Unnecessary groups can make maintenance more difficult and increase the risk of incorrect field assignments.

Parent and Child Decoders

For complex log formats, Wazuh supports parent-child decoder relationships.

A parent decoder identifies the general log type, while child decoders perform more specific extraction based on the matched log.

This approach offers several benefits:

  • Reduces duplicate regex patterns
  • Simplifies maintenance
  • Allows multiple child decoders to share a common parent
  • Makes decoders easier to extend as log formats evolve

Parent-child decoders are especially useful when different event types share the same log prefix but contain different payloads.

For a detailed walkthrough, see How to Map Complex Log Fields Using Wazuh Parent Child Rules.

Nested Dynamic Fields

One of the biggest advantages of dynamic fields is the ability to represent nested objects using hierarchical names.

For example:

cloud.account.id
cloud.account.name
cloud.region
user.identity.name
user.identity.role

This mirrors the structure of modern JSON logs, making alerts more intuitive and reducing ambiguity when multiple fields have similar meanings.

Dot Notation for Field Organization

Dot notation groups related information into logical namespaces, making dynamic fields easier to understand and query.

Instead of using inconsistent names such as:

region
cloudregion
awsregion
userip
sourceip

adopt a consistent convention:

cloud.region
cloud.provider
network.source.ip
network.destination.ip
authentication.user
authentication.result
http.request.method
http.response.code

This approach improves readability, encourages reuse across decoders, and simplifies rule creation.

It also aligns well with widely adopted structured logging conventions, such as the Elastic Common Schema (ECS), which organizes event attributes into hierarchical field sets for better interoperability across security tools.


Creating Your First Dynamic Field Decoder

Now that you understand how dynamic fields work, let’s build a simple custom decoder that extracts information from a log and stores it as dynamic fields.

This example demonstrates the complete workflow, from creating the decoder to verifying that Wazuh successfully loads it.

Sample Log Entry

Suppose your application generates authentication logs like this:

2026-07-30 09:18:42 User=alice SrcIP=192.168.10.25 DstIP=10.0.0.15 Port=443 Session=ABCD12345 Method=POST URL=/login Status=200

The goal is to extract each important value into a separate dynamic field that can later be referenced by custom rules.

Ideally, your sample logs should come from your production environment to ensure your decoder accurately reflects the actual log format.

Creating the Decoder XML

Custom decoders are written in XML and are typically stored in Wazuh’s local decoder directory.

A basic decoder might look like this:

<decoder name="custom-webapp">
  <prematch>User=</prematch>

  <regex>User=(\S+)\s+SrcIP=(\S+)\s+DstIP=(\S+)\s+Port=(\d+)\s+Session=(\S+)\s+Method=(\S+)\s+URL=(\S+)\s+Status=(\d+)</regex>

  <order>
    authentication.user,
    network.source.ip,
    network.destination.ip,
    network.destination.port,
    session.id,
    http.request.method,
    url.path,
    http.response.status_code
  </order>
</decoder>

This decoder first identifies matching log entries using <prematch>, then extracts values using the regular expression.

For a complete overview of decoder syntax, see Wazuh Decoder Guide.

Defining Dynamic Field Names

Choose field names that clearly describe the data being extracted.

Good examples include:

authentication.user
network.source.ip
network.destination.ip
network.destination.port
session.id
http.request.method
url.path
http.response.status_code

Avoid generic names like:

field1
field2
data
value
misc

Meaningful names make detection rules easier to understand months or even years after they’re written.

Whenever possible, use consistent namespaces throughout your custom decoders.

Mapping Capture Groups

Every capture group in the regular expression corresponds to one field listed in the <order> element.

For example:

User=(\S+)
SrcIP=(\S+)
DstIP=(\S+)
Port=(\d+)

maps to:

authentication.user
network.source.ip
network.destination.ip
network.destination.port

The mapping is positional:

Capture GroupDynamic Field
Group 1authentication.user
Group 2network.source.ip
Group 3network.destination.ip
Group 4network.destination.port

If the number of capture groups does not match the number of fields listed in <order>, extraction may fail or assign incorrect values.

Saving the Decoder

After creating the decoder:

  1. Save the XML file in your custom decoder directory.
  2. Verify that the XML is well-formed.
  3. Ensure the filename follows your organization’s naming conventions.
  4. Keep custom decoders separate from the built-in Wazuh ruleset whenever possible.

Storing custom decoders separately makes future Wazuh upgrades much easier because your changes are less likely to be overwritten.

Restarting the Wazuh Manager

After saving the decoder, restart the Wazuh Manager so it reloads the decoder configuration.

Once restarted, the manager will:

  • Load the updated decoder
  • Validate the XML syntax
  • Register the new decoder
  • Report any configuration errors in the manager logs

If the decoder contains syntax errors, Wazuh typically logs detailed messages indicating the line number and the nature of the problem.

For common decoder syntax issues, see How to Fix “Field Already Defined” Syntax Errors in Wazuh Decoders.

Verifying Successful Loading

Before relying on your decoder in production, verify that it loaded correctly.

The easiest method is to use wazuh-logtest.

A successful test should show:

  • The correct decoder matched
  • Dynamic fields populated
  • Expected values extracted
  • Rules evaluated successfully
  • No decoder errors

For example:

Decoder: custom-webapp

authentication.user = alice
network.source.ip = 192.168.10.25
network.destination.ip = 10.0.0.15
network.destination.port = 443
session.id = ABCD12345
http.request.method = POST
url.path = /login
http.response.status_code = 200

If any fields are missing, verify your regular expression, capture groups, and <order> element before troubleshooting the rule itself.

See How to Use Wazuh Logtest.


Extracting Multiple Dynamic Fields

One of the biggest strengths of dynamic fields is the ability to extract numerous pieces of information from a single log entry.

Rather than creating multiple decoders or sacrificing valuable context, you can capture all relevant attributes in a single pass.

Parsing Usernames

Usernames are among the most commonly extracted fields because they’re frequently used in authentication and authorization rules.

Example:

User=alice

Dynamic field:

authentication.user = alice

Detection rules can then identify repeated login failures, privilege escalation attempts, or suspicious account activity.

Capturing Source IP Addresses

Source IP addresses provide essential context for identifying attackers and tracing network activity.

Example:

SrcIP=203.0.113.42

Dynamic field:

network.source.ip = 203.0.113.42

This field can be correlated with:

  • Threat intelligence feeds
  • Firewall logs
  • VPN connections
  • Geographic lookups
  • Previous authentication events

Extracting Destination IPs

Destination addresses identify which system or service was targeted.

Example:

DstIP=10.0.0.15

Produces:

network.destination.ip = 10.0.0.15

Combining source and destination addresses allows rules to detect lateral movement, unusual communication paths, and policy violations.

Parsing Ports

Ports provide additional context about the targeted service.

Example:

Port=443

Dynamic field:

network.destination.port = 443

Rules can distinguish between:

  • SSH attacks
  • RDP activity
  • Database connections
  • Web traffic
  • Administrative services

without requiring separate decoders for each protocol.

Extracting Session IDs

Many enterprise applications generate session identifiers that link multiple events together.

Example:

Session=ABCD12345

Produces:

session.id = ABCD12345

Session IDs allow investigators to reconstruct complete user sessions across authentication, application activity, and logout events.

Capturing Request Methods

HTTP request methods help distinguish different types of application activity.

Example:

Method=POST

Dynamic field:

http.request.method = POST

Security teams frequently build rules around unexpected methods such as:

  • PUT
  • DELETE
  • PATCH
  • TRACE

particularly when they target sensitive application endpoints.

Parsing URLs

URLs provide insight into which resources users or attackers attempted to access.

Example:

URL=/admin/users

Produces:

url.path = /admin/users

Rules can detect requests targeting:

  • Administrative interfaces
  • Login pages
  • API endpoints
  • Sensitive configuration files
  • Hidden directories

Extracting Response Codes

HTTP status codes help determine whether requests succeeded or failed.

Example:

Status=403

Dynamic field:

http.response.status_code = 403

Monitoring response codes enables detections such as:

  • Excessive 401 Unauthorized responses
  • Large numbers of 404 requests during reconnaissance
  • Repeated 500 Internal Server Errors
  • Unexpected 302 redirects

Collectively, these extracted fields provide much richer context than a handful of traditional static fields, allowing security teams to build more accurate and actionable detection rules.


Using Dynamic Fields with JSON Logs

JSON has become the dominant logging format for cloud-native applications, making dynamic fields especially valuable.

Wazuh can extract structured data directly from JSON objects, preserving the relationships between fields and enabling more precise detections.

JSON Decoder Basics

Unlike plain-text logs that rely heavily on regular expressions, JSON logs can often be parsed using Wazuh’s JSON decoding capabilities.

For example:

{
  "username": "alice",
  "source_ip": "192.168.1.15",
  "action": "login",
  "status": "failed"
}

can be mapped to dynamic fields such as:

authentication.user
network.source.ip
authentication.action
authentication.status

JSON parsing generally requires less maintenance because field names remain consistent even as additional attributes are added to the log.

Mapping Nested Objects

Modern JSON logs frequently contain nested objects.

Example:

{
  "cloud": {
    "provider": "aws",
    "region": "us-east-1"
  },
  "user": {
    "name": "alice"
  }
}

Dynamic fields can mirror this hierarchy:

cloud.provider
cloud.region
user.name

Maintaining the original structure improves readability and simplifies rule creation.

Extracting Arrays

Some JSON logs contain arrays of values rather than individual fields.

Example:

{
  "roles": [
    "Admin",
    "Developer"
  ]
}

Depending on the log structure and parsing strategy, arrays can be processed to support detections involving:

  • User roles
  • Group memberships
  • Network interfaces
  • IP address lists
  • Granted permissions
  • Attached policies

When designing decoders for array-heavy logs, consider how the extracted values will be used in detection rules to avoid unnecessary complexity.

Flattening JSON Structures

Many applications produce deeply nested JSON documents.

Rather than creating long nested paths for every query, some organizations choose to flatten portions of the structure.

For example:

Instead of:

application.authentication.identity.user.name

you might expose:

authentication.user

Flattening selectively can make searches, dashboards, and custom rules easier to write while still preserving enough context to understand the event.

The key is to strike a balance between readability and fidelity to the original log structure.

Handling Optional Fields

Not every JSON event contains the same attributes.

For example:

{
  "user": "alice",
  "mfa": true
}

might omit fields such as:

  • device.id
  • geo.country
  • risk.score

Design your decoders and detection rules to tolerate missing values gracefully.

Avoid assuming every field will always be present, particularly when logs originate from multiple application versions or cloud services with evolving schemas.

Working with Cloud Service Logs

Cloud platforms such as AWS, Microsoft Azure, and Google Cloud generate extensive JSON audit logs containing metadata about identities, resources, networking, and API operations.

Dynamic fields allow you to preserve information such as:

cloud.provider
cloud.account.id
cloud.project.id
cloud.subscription.id
cloud.region
event.name
identity.user
network.source.ip

This additional context enables detections for suspicious API usage, privilege changes, resource creation, and anomalous geographic access while keeping decoder configurations scalable as cloud services introduce new fields.

For additional guidance on cloud monitoring, see How to Monitor AWS CloudTrail Logs Using Wazuh and Wazuh MySQL Integration: Security & Log Detection for examples of integrating structured data sources.


Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *