untable - Splunk Documentation (2024)

Description

Converts results from a tabular format to a format similar to stats output. This command is the inverse of the xyseries command.

Syntax

untable <x-field> <y-name-field> <y-data-field>

Required arguments

<x-field>
Syntax: <field>
Description: The field to use for the x-axis labels or row names. This is the first field in the output.
<y-name-field>
Syntax: <field>
Description: A name for the field to contain the labels for the data series. All of the field names, other than <x-field>, are used as the values for the <y-name-field> field. You can specify any name for this field.
<y-data-field>
Syntax: <field>
Description: A name for the field to contain the data to chart. All of the values from the fields, other than <x-field>, are used as the values for the <y-data-field> field. You can specify any name for this field.

Usage

The untable command is a distributable streaming command. See Command types.

Results with duplicate field values

When you untable a set of results and then use the xyseries command to combine the results, results that contain duplicate values are removed.

You can use the streamstats command create unique record numbers and use those numbers to retain all results. See Extended examples.

Basic example

This example uses the sample data from the Search Tutorial. To try this example on your own Splunk instance, you must download the sample data and follow the instructions to get the tutorial data into Splunk. Use the time range All time when you run the search.

To show how to use the untable command, we need results that appear in a table format. Run this search.

sourcetype=access_* status=200 action=purchase | top categoryId

The results appear on the Statistics tab and look something like this:

categoryIdcountpercent
STRATEGY80630.495649
ARCADE49318.653046
TEE36713.885736
ACCESSORIES34813.166856
SIMULATION2469.307605
SHOOTER2459.269769
SPORTS1385.221339

The top command automatically adds the count and percent fields to the results.

For each categoryId, there are two values, the count and the percent. When you untable these results, there will be three columns in the output:

  • The first column lists the category IDs
  • The second column lists the type of calculation: count or percent
  • The third column lists the values for each calculation

When you use the untable command to convert the tabular results, you must specify the categoryId field first. You can use any field name you want for the type of calculation and the values. For example:

sourcetype=access_* status=200 action=purchase | top categoryId | untable categoryId calculation value

The results appear on the Statistics tab and look something like this:

categoryIdcalculationvalue
STRATEGYcount806
STRATEGYpercent30.495649
ARCADEcount493
ARCADEpercent18.653046
TEEcount367
TEEpercent13.885736
ACCESSORIEScount348
ACCESSORIESpercent13.166856
SIMULATIONcount246
SIMULATIONpercent9.307605

Extended example

The untable command does exactly what the name says, it converts tabular information into individual rows of results. Suppose you have this search:

...| table _time EventCode Message

The search produces these results:

_timeEventCodeMessage
date-time14136Too late now
date_time21234I dont know
date_time33456Too busy, ask again later
date_time41256Everything is happening at once
date_time41257And right now, as well

Notice that this set of events has duplicate values in the _time field for date_time4. We will come back to that in a moment.

Use the untable command to remove the tabular format.

...| untable _time FieldName FieldValue

Here are the results from the untable command:

_timeFieldNameFieldValue
date-time1EventCode4136
date-time1MessageToo late now
date_time2EventCode1234
date-time2MessageI dont know
date_time3EventCode3456
date-time3MessageToo busy, ask again later
date_time4EventCode1256
date-time4MessageEverything is happening at once
date_time4EventCode1257
date-time4MessageAnd right now, as well

Events with duplicate timestamps

Remember that the original set of events in this example had duplicates for date_time4. If you want to process the events in some way and then put the events back together, you can avoid eliminating the duplicate events by using the streamstats command.

Use the streamstats command to give each event a unique record number and use that unique number as the key field for the untable and xyseries commands.

For example, you can add the streamstats command to your original search.

...| table _time EventCode Message | streamstats count as recno

The search produces these results:

_timeEventCodeMessagerecno
date-time14136Too late now1
date_time21234I dont know2
date_time33456Too busy, ask again later3
date_time41256Everything is happening at once4
date_time41257And right now, as well5

You can then add the untable command to your search, using recno as the <x-field>:

...| table _time EventCode Message | streamstats count as recno | untable recno FieldName FieldValue

The search produces these results:

recnoFieldNameFieldValue
1EventCode4136
1MessageToo late now
2EventCode1234
2MessageI dont know
3EventCode3456
3MessageToo busy, ask again later
4EventCode1256
4MessageEverything is happening at once
4EventCode1257
4MessageAnd right now, as well

These events can be put back together by using the xyseries command, again using the recno field as the <x-field>. For example:

...| xyseries recno FieldName FieldValue

The search produces these results:

recnoEventCodeMessage
14136Too late now
21234I dont know
33456Too busy, ask again later
41256Everything is happening at once
51257And right now, as well

Restoring the timestamps

In addition to using the streamstats command to generate a record number, you can use the rename command to restore the timestamp information after the xyseries command. For example:

...| table _time EventCode Message | streamstats count as recno | rename _time as time| untable recno FieldName FieldValue| xyseries recno FieldName FieldValue| rename time as _time

(Thanks to Splunk users DalJeanis and BigCosta for their help with this example.)

See also

xyseries

untable - Splunk Documentation (2024)
Top Articles
Latest Posts
Article information

Author: Fr. Dewey Fisher

Last Updated:

Views: 6239

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Fr. Dewey Fisher

Birthday: 1993-03-26

Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

Phone: +5938540192553

Job: Administration Developer

Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.