Try it free

DPL Structure

  • Latest Dynatrace
  • Reference

STRUCTURE

The STRUCTURE{ matcher_expression } matcher allows capturing any sequence of matchers in record data type.

Use the following expression to parse the value:

STRUCTURE{ INT:i ',' LD:string }:result

For example, capturing an integer and a string as one record:

Descriptioninput (string)result (record)

Integer and string members

1,red fox jumps

{"i": 1, "string": "red fox jumps"}

Invalid input

random text

null

Whitespace

␣

null

See how to use in DQL
data record(input = "1,red fox jumps"),
record(input = "random text"),
record(input = " ")
| parse input, "STRUCTURE{ INT:i ',' LD:string }:result"

Syntax

STRUCTURE{ matcher_expression }:result

Returns

The data type of the extracted value is record. Each named member becomes a field in the record, keeping the data type of its matcher.

Practical examples

Example 1: Parse optional members

Wrap part of the pattern in ( ... )? to make members optional. When the optional part is absent, its members are null and the structure still matches.

Use the following expression to capture a client address and an optional port:

STRUCTURE{ IPADDR:client (SPACE INT:port)? }:result
input (string)result (record)

10.0.0.1 8080

{"client": "10.0.0.1", "port": 8080}

10.0.0.1

{"client": "10.0.0.1", "port": null}

See how to use in DQL
data record(input = "10.0.0.1 8080"),
record(input = "10.0.0.1")
| parse input, "STRUCTURE{ IPADDR:client (SPACE INT:port)? }:result"
Example 2: Parse a nested structure

A structure can contain another structure, producing a nested record.

Given the following input:

Vienna 48.2,16.3

Use the following expression to capture the city and a nested coordinate record:

STRUCTURE{ WORD:city SPACE STRUCTURE{ DOUBLE:lat ',' DOUBLE:lon }:coords }:result
result (record)

{"city": "Vienna", "coords": {"lat": 48.2, "lon": 16.3}}

See how to use in DQL
data record(input = "Vienna 48.2,16.3")
| parse input, "STRUCTURE{ WORD:city SPACE STRUCTURE{ DOUBLE:lat ',' DOUBLE:lon }:coords }:result"
Example 3: Parse a delimited key-value list into an array of records

Wrap a structure in an ARRAY to capture a repeating group as an array of records, then use expand to emit one row per element.

Given the following input, a comma-separated list of folder paths and file counts:

C:\ftp\acme=0,C:\ftp\acme\INBOUND\Claims=2,C:\ftp\acme\INBOUND\Contribution=0,C:\ftp\acme\INBOUND\Enrollment=0

Use the following expression to capture each path and count as a record:

ARRAY{STRUCTURE{LD:key '=' INT:value}:i ','?}{0,100}:result
result[key] (string)result[value] (long)

C:\ftp\acme

0

C:\ftp\acme\INBOUND\Claims

2

C:\ftp\acme\INBOUND\Contribution

0

C:\ftp\acme\INBOUND\Enrollment

0

See how to use in DQL
data record(input = """C:\ftp\acme=0,C:\ftp\acme\INBOUND\Claims=2,C:\ftp\acme\INBOUND\Contribution=0,C:\ftp\acme\INBOUND\Enrollment=0""")
| parse input, """ARRAY{STRUCTURE{LD:key '=' INT:value}:i ','?}{0,100}:result"""
| expand result
Related tags
Dynatrace Platform