Splunk® Cloud Services

SPL2 Search Reference

Acrobat logo Download manual as PDF


Acrobat logo Download topic as PDF

flatten command usage

Flattening nested objects

The flatten command can flatten only the first level of an object. For example, when an object such {a: {b: 2}} is flattened a field called a is created with a value {b: 2}.

To flatten nested objects, use the expand command with the flatten command.

For an example of how these two commands are used together, see flatten command examples and expand command examples.

Field order in the output

When you flatten the values in an object, fields are created in the search results. The order of the fields displayed in the output is lexicographical. Lexicographical order means that numbers come before letters and uppercase letters come before lowercase letters.

For example, suppose you have the following object:

{name: "Akashi-Kaikyo Bridge", length: 12800, city: "Kobe", country: "Japan", Opened: 1998} 

When the object is flattened, the order of the fields are rearranged to this:

  • Opened
  • city
  • country
  • length
  • name

The output looks like this:

Opened city country length name
1998 Kobe Japan 12800 Akashi-Kaikyo Bridge

To learn more about lexicographical order, see Lexicographical order in the SPL2 Search Manual.

See also

flatten command
flatten command overview
flatten command syntax details
flatten command examples
Last modified on 01 March, 2021
PREVIOUS
flatten command syntax details
  NEXT
flatten command examples

This documentation applies to the following versions of Splunk® Cloud Services: current


Was this documentation topic helpful?

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters