Try it free

Record functions

  • Latest Dynatrace
  • Reference
  • Published Sep 10, 2026

Record functions allow you to create records or extract data from them.

record

Creates a record from the keys and values of the parameter.

Syntax

record(expression, …)

Parameters

ParameterTypeDescriptionRequired

expression

array, boolean, double, duration, ip, long, record, string, timeframe, timestamp

An expression to add to the record.

Required

Returns

The data type of the returned value is record.

Examples

Example 1
data record(executable = "java", technologies = array("Java", "Spring", "Jetty")),
record(executable = "python", technologies = array("Python", "Flask")),
record(executable = "java", technologies = array("Java", "Jetty", "Hibernate"))

Query result:

executabletechnologies

java

[Java, Spring, Jetty]

python

[Python, Flask]

java

[Java, Jetty, Hibernate]

recordField

Returns the value of a single field from a record by name.

The recordField function is the record counterpart to jsonField, which extracts a value by name from a JSON string.

Syntax

recordField(record, name)

Parameters

ParameterTypeDescriptionRequired

record

record

The record to extract the field value from.

Required

name

string

The name of the field to extract.

Required

Returns

The data type of the returned value depends on the type of the named field in the record.

Basic examples

Example 1: Extract a field from a nested record

The following example uses recordField to extract the host field from a nested metadata record.

data record(event = "failed to find product",
metadata = record(host = "web-1", region = "us-east-1"))
| fieldsAdd recordField(metadata, "host")

Query result:

eventmetadatarecordField(metadata, "host")

failed to find product

host: web-1 region: us-east-1

web-1

recordFields

Returns all fields of a record as an array of key-value pairs.

Each element in the returned array is a record with two fields: key (the field name as a string) and value (the field value). The function is non-recursive: if a field value is itself a record, it's returned as-is, not expanded.

The resulting array can be used with field access notation—out[][key] yields an array of all keys, and out[][value] yields an array of all values. To reconstruct a record from key-value pairs, use recordFromFields.

Syntax

recordFields(record)

Parameters

ParameterTypeDescriptionRequired

record

record

The record to convert to an array of key-value pairs.

Required

Returns

The data type of the returned value is array. Each element is a record with fields key (string) and value.

Basic examples

Example 1: Get all key-value pairs from a record

The following example converts the nested metadata record into an array of key-value pair records.

data record(event = "failed to find product",
metadata = record(host = "web-1", region = "us-east-1"))
| fieldsAdd recordFields(metadata)

Query result:

eventmetadatarecordFields(metadata)

failed to find product

host: web-1 region: us-east-1

[key: host value: web-1, key: region value: us-east-1]

Example 2: Extract only the keys or only the values

The following example shows how to use array field access notation to get all keys and all values from the result of recordFields.

data record(metadata = record(host = "web-1", region = "us-east-1", env = "prod"))
| fieldsAdd pairs = recordFields(metadata)
| fieldsAdd keys = pairs[]["key"], values = pairs[]["value"]
| fieldsRemove pairs

Query result:

metadatakeysvalues

host: web-1 region: us-east-1 env: prod

[host, region, env]

[web-1, us-east-1, prod]

recordFromFields

Creates a record from an array of key-value pairs.

The recordFromFields function is the inverse of recordFields. It takes an array of records, each with a key field (string) and a value field, and assembles them into a single record.

Syntax

recordFromFields(fields)

Parameters

ParameterTypeDescriptionRequired

fields

array

An array of records, each containing a key (string) field and a value field, as produced by recordFields.

Required

Returns

The data type of the returned value is record.

Basic examples

Example 1: Round-trip a record through key-value pairs

The following example converts a record to key-value pairs using recordFields, then reconstructs it using recordFromFields.

data record(metadata = record(host = "web-1", region = "us-east-1"))
| fieldsAdd pairs = recordFields(metadata)
| fieldsAdd reconstructed = recordFromFields(pairs)
| fieldsRemove pairs

Query result:

metadatareconstructed

host: web-1 region: us-east-1

host: web-1 region: us-east-1

recordKeys

Returns the field names of a record as an array of strings.

Syntax

recordKeys(record)

Parameters

ParameterTypeDescriptionRequired

record

record

The record whose field names to return.

Required

Returns

The data type of the returned value is array. Each element is a string.

Basic examples

Example 1: Get the field names of a record

The following example returns the field names of the nested metadata record.

data record(metadata = record(host = "web-1", region = "us-east-1", env = "prod"))
| fieldsAdd recordKeys(metadata)

Query result:

metadatarecordKeys(metadata)

host: web-1 region: us-east-1 env: prod

[host, region, env]

recordValues

Returns the field values of a record as an array.

Syntax

recordValues(record)

Parameters

ParameterTypeDescriptionRequired

record

record

The record whose field values to return.

Required

Returns

The data type of the returned value is array. The type of each element depends on the corresponding field value in the record.

Basic examples

Example 1: Get the values of a record

The following example returns the field values of the nested metadata record.

data record(metadata = record(host = "web-1", region = "us-east-1", env = "prod"))
| fieldsAdd recordValues(metadata)

Query result:

metadatarecordValues(metadata)

host: web-1 region: us-east-1 env: prod

[web-1, us-east-1, prod]

Related topics

  • Dynatrace Query Language
  • Use DQL queries
  • DQL compared to SQL and more
  • DQL language reference
  • DQL commands
  • DQL operators
  • DQL data types
  • DQL best practices
Related tags
Dynatrace Platform