Try it free

DPL Literal Expressions

  • Latest Dynatrace
  • Reference

Literals

Literals are expressed as strings enclosed in single quotes '...' or double quotes "...". They match an exact sequence of characters in the input.

Use the following expression to match a literal value:

'hello'

For example:

Descriptioninput (string)result (boolean)

Exact match

hello

true

Different case

Hello

false

Different word

World

false

Literal followed by more text

hello world

false

Literal preceded by more text

say hello

false

Leading space

␣hello

false

Trailing space

hello␣

false

Whitespace only

␣

false

See how to use in DQL
data record(input = "hello"),
record(input = "Hello"),
record(input = "World"),
record(input = "hello world"),
record(input = "say hello"),
record(input = " hello"),
record(input = "hello "),
record(input = " ")
| fieldsAdd result = matchesPattern(input, "'hello'")

matchesPattern requires the entire input to match the literal—any surrounding characters, including spaces, cause it to return false. To match a literal that appears within a larger value, combine it with other matchers (for example LD 'hello' LD), as shown in the practical example below.

If the literal contains a single quote, enclose it with double quotes, and vice versa. Alternatively, escape the quote with a preceding backslash \ (0x5c ASCII).

Configuration

Specify configuration parameters in parentheses after the literal: 'text'(param=value).

parametertypeDescription

charset

string

Character set name enclosed in single or double quotes (for example charset="ISO-8859-1"). Default: none.

locale

string

String specifying an IETF BCP 47 language tag enclosed in single or double quotes (see IANA language subtag registry). Default: English

Returns

The data type of the extracted value is string. When used without a :name capture, the literal is only matched and not exported to the output.

Basic examples

Example 1: Parse a repeated literal character

The following expression matches one or more occurrences of the character a and captures the result:

'a'+:result
Descriptioninput (string)result (string)

Single character

a

a

Repeated character

aa

aa

Non-matching input

b

null

See how to use in DQL
data record(input = "a"),
record(input = "aa"),
record(input = "b")
| parse input, "'a'+:result"
Example 2: Match a repeated literal character

The following expression checks whether the input consists of one or more occurrences of a:

'a'+
Descriptioninput (string)result (boolean)

Single character

a

true

Repeated character

aa

true

Non-matching input

b

false

See how to use in DQL
data record(input = "a"),
record(input = "aa"),
record(input = "b")
| fieldsAdd result = matchesPattern(input, "'a'+")
Example 3: Match special characters

Literals can include escape sequences such as \t (tab) and \n (newline). The escape matches the corresponding control character in the input, and each escape matches only its own character.

The following expression matches the character a, a tab, and the character b:

'a\tb'
Descriptioninput (string)result (boolean)

Tab matches the \t escape

a⇥b

true

Newline does not match the \t escape

a↵b

false

See how to use in DQL
data record(input = "a\tb"),
record(input = "a\nb")
| fieldsAdd result = matchesPattern(input, "'a\tb'")

Practical examples

Example: Parse a log level from a record

Literals are case-sensitive—the expression matches only if the input contains the exact characters as written. The literal can appear anywhere in a record.

Given the following input:

2024-03-15T08:23:11.000Z host-01 app[123]: level: info Request received

Use the following expression to extract the level value from anywhere in the record:

LD 'level: ' WORD:level
level (string)

info

See how to use in DQL
data record(input = "2024-03-15T08:23:11.000Z host-01 app[123]: level: info Request received")
| parse input, "LD 'level: ' WORD:level"
Related tags
Dynatrace Platform