![]() |
VOOZH | about |
When you add a processor to a pipeline, you can filter logs to process only a defined subset. This document goes over the following information:
message fieldNote: Worker version 2.11 and newer uses an upgraded search syntax. After you upgrade the Worker to version 2.11, you might need to update your filter queries to match the new syntax. See Upgrade Your Filter Queries to the New Search Syntax for more information.
There are two types of filter queries you can use:
Free text search only searches the message field and is case insensitive. It is composed of terms and operators. There are two types of terms:
test or hello."hello dolly".The following are free text search examples:
hellohello. For example, {"message": "hello world"} is a matching log.Hello worldhello and world. For example, "hello beautiful world" is a match.Hello AND world.hello and world to match."hello world""hello world", "hello-world", and "Hello, world" are all matches.You can search attribute keys and values. For example, if your attribute key is url and you want to filter on the url value www.datadoghq.com, enter: url:www.datadoghq.com.
Note: Attribute searches are case sensitive.
To filter for events that have a specific attribute key, use the _exists_ syntax. For example, if you use the query _exists_:service, the event {"service": "postgres"} matches the query, but the event {"env": "prod"} does not match.
To filter for events that do not have a specific attribute key, use the _missing_ syntax. For example, if you use the query _missing_:service, the event {"env": "prod"} matches the query, but the event {"service": "postgres"} does not match.
Here are some attribute search syntax examples and logs that match the syntax:
status:ok service:flask-web-appok from your flask-web-app service.status:ok AND service:flask-web-app.user.status:inactiveinactive nested under the user attribute.http.url:/api-v1/*http.url attribute that starts with /api-v1/.http.status:[200 TO 299]http.status value that is greater than or equal to 200 and less than or equal to 299.[..] Square brackets mean the ranges are inclusive.http.status:{200 TO 299}http.status value that is greater than 200 or less than 299.{..} Curly brackets mean the ranges are exclusive.http.status_code:[200 TO 299] http.url_details.path:/api-v1/*http.status_code value that is greater than or equal to 200 and less than or equal to 299http.url_details.path attribute that start with /api-v1/."service.status":disabled"service.status": "disabled". This filter syntax searches for a literal . in the attribute key._exists_:serviceservice. For example, the query matches {"service": "postgres"}, but does not match {"env": "prod"}._missing_:serviceservice. For example, the query matches {"env": "prod"}, but does not match {"service": "postgres"}.For this log structure example:
{
"outer_key": {
"inner_key": "inner_value",
"a": {
"double_inner_key": "double_inner_value",
"b": "b value"
},
"c": "c value"
},
"d": "d value"
}
Follow these reference rules:
outer_key.inner_key to reference the key with the value inner_value.outer_key.a.double_inner_key to reference the key with the value double_inner_value.If you want the query to search for a literal . in the attribute key, wrap the key in escaped quotes in the search query. For example, the search query "service.status":disabled matches the event {"service.status": "disabled"}.
In the following example, CloudWatch logs for Windows contain an array of JSON objects under Event.EventData.Data.
Event
{
EventData {
Data [
{"Name":"SubjectUserID1", "value":"12345"},
{"Name":"SubjectUserID2", "value":"Admin"},
{"Name":"ObjectServer", "value":"Security"}
]
}
}
If you use the filter query Event.EventData.Data.Name:ObjectServer, the above log event is matched because it contains a nested object with the attribute key Name and the value ObjectServer.
You can use the following case sensitive Boolean operators to combine multiple terms in a search query.
| Operator | Description |
|---|---|
AND | Intersection: both terms are in the event. |
OR | Union: either term is contained in the event. |
- or NOT | Exclusion: the following term is not in the event. |
The follow are example queries that use Boolean operators:
NOT (status:debug)DEBUG.host:COMP-A9JNGYK OR host:COMP-J58KASHello AND Worldhello and world. For example, "hello beautiful world" is a match.Hello world.hello and world to match.hello AND status:infohello and with status:info.-http.status_code:200service:(postgres OR datadog_agent)postgres or datadog_agent for the service attribute. This query can also be written as: service:postgres OR service:datadog_agentThe following characters are considered special and must be escaped with a backslash (\):
- ! && || > >= < <= ( ) { } [ ] " * ? : #, and spaces.
Notes:
/ is not considered a special character and doesn’t need to be escaped.! in the message field, use the attribute search syntax: message:*!*.Searching for an attribute value that contains special characters requires escaping or double quotes. For example, to search for an attribute my_app with the value hello:world, use the syntax: my_app:hello\:world or my_app:"hello:world".
To match a single special character or space, use the ? wildcard. For example, to search for an attribute my_app with the value hello world again, use the syntax: my_app:hello?world?again.
To learn how to escape special characters and spaces in a search, let’s look at a log example:
{
"service": "postgres",
"status": "INFO",
"tags": [
"env:prod",
"namespace:something",
"reader:logs",
"my_app:hello world again"
]
}
The following are search syntax examples that escape special characters and spaces in the log example:
tags:env*tag attribute value of env.tags:(env\:prod OR env\:test)env:prod or env:test in the tags array.tags:("env:prod" OR "env:test").tags:env\:prod AND -tags:version\:betaenv:prod and does not have version:beta in the tag array.tags:"env:prod" AND -tags:"version:beta".my_app:hello\:worldmy_app:hello:world.my_app:"hello:world".my_app:hello?world?again"my_app":"hello world again".You can use * for wildcard searches. The following are wildcard search examples:
*network*message field value that contains network.web*message field value that starts with web.*webmessage field value that ends with web.service:*mongoservice attribute values that ends with mongo.service:web*service attribute value that starts with web.Notes:
*:app or service*:app."*test*" matches a log which has the string *test* in its message field, while *test* matches a log which has the string test anywhere in the message field.When searching for an attribute that contains special characters or requires escaping or double quotes, use the ? wildcard to match a single special character or space. For example, to search for an attribute my_attribute with the value hello world, use the syntax: my_attribute:hello?world.
| |