Modifying Event Data

When a query statement or expression modifies event data, for example extracting data, adding new fields, or updating the value of an existing field, the operation updates every event in the event set. This is because the query pipeline performs that same function on every event in the set of events.

For example, consider the following simulated set of events. If a new field is added through the query, each event will now have the new field. Here is the original event set:

host
DEV-DB01
NYC-SRV01
BACKUP01
PROD-APP02
PROD-WEB01

Here a new field is added via a query:

logscale
username := "Bob"

Which leads to the following result, where each event now has a new field:

userhost
BobDEV-DB01
BobNYC-SRV01
BobBACKUP01
BobPROD-APP02
BobPROD-WEB01

Important

Be aware, if there are no events in the event set before the query, creating a new field in the query will not create events. Adding a new field only updates an existing event set, it does not create a new one. You will continue to have an empty event set.

Existing data can also be modified or updated. CQL allows for all fields to be updated or modified in the stream of events, overwriting the original values. For example, this can be performed with an assignment expression, which updates every event. Here is the expression:

logscale
host := "internal"

Here is the updated list of values:

host
internal
internal
internal
internal
internal

The process also works for calculations. For example, here is an expression that creates values in seconds in place of milliseconds:

logscale
cpus := cpums/1000

Which produces values that look like the following:

hostcpumscpus
DEV-US-APP0288898.889
SYD-SRV0141564.156
PROD-DB011270.127
PROD-SQL0112871.287
DHCP011270.127

Processing individual events can be useful when modifying or updating data before aggregation, or summarizing to format information into a suitable format, either for aggregation or identifying or unifying information.