Splunk® Enterprise

Search Reference

Multivalue stats and chart functions

list(<value>)

Description

The list function returns a multivalue entry from the values in a field. The order of the values reflects the order of the events.

Usage

You can use this function with the chart, stats, and timechart commands.

  • If more than 100 values are in a field, only the first 100 are returned.
  • This function processes field values as strings.

Basic example

To illustrate what the list function does, let's start by generating a few simple results.

  1. Use the makeresults and streamstats commands to generate a set of results that are simply timestamps and a count of the results which are used as row numbers.

    | makeresults count=1000 | streamstats count AS rowNumber

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

    _time rowNumber
    2018-04-02 20:27:11 1
    2018-04-02 20:27:11 2
    2018-04-02 20:27:11 3
    2018-04-02 20:27:11 4
    2018-04-02 20:27:11 5

    Notice that each result appears on a separate row.


  2. Add the stats command with the list function to the search. The numbers are returned in ascending order in a single, multivalue result.

    | makeresults count=1000 | streamstats count AS rowNumber | stats list(rowNumber) AS numbers

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

    numbers
    1
    2
    3
    4
    5

    Notice that it is a single result. There are no alternating row background colors.

  3. Compare this result with the results returned by the values function.

values(<values>)

Description

The values function returns a list of the distinct values in a field as a multivalue entry. The order of the values is lexicographical.

Usage

You can use the values(X) function with the chart, stats, timechart, and tstats commands.

  • By default there is no limit to the number of values returned. Users with the appropriate permissions can specify a limit in the limits.conf file. You specify the limit in the [stats | sistats] stanza using the maxvalues setting.
  • This function processes field values as strings.

Lexicographical order

Lexicographical order sorts items based on the values used to encode the items in computer memory. In Splunk software, this is almost always UTF-8 encoding, which is a superset of ASCII.

  • Numbers are sorted before letters. Numbers are sorted based on the first digit. For example, the numbers 10, 9, 70, 100 are sorted lexicographically as 10, 100, 70, 9.
  • Uppercase letters are sorted before lowercase letters.
  • Symbols are not standard. Some symbols are sorted before numeric values. Other symbols are sorted before or after letters.

Basic example

To illustrate what the values function does, let's start by generating a few simple results.

  1. Use the makeresults and streamstats commands to generate a set of results that are simply timestamps and a count of the results, which are used as row numbers.

    | makeresults count=1000 | streamstats count AS rowNumber

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

    _time rowNumber
    2018-04-02 20:27:11 1
    2018-04-02 20:27:11 2
    2018-04-02 20:27:11 3
    2018-04-02 20:27:11 4
    2018-04-02 20:27:11 5

    Notice that each result appears on a separate row.

  2. Add the stats command with thevalues function to the search. The results are returned in lexicographical order.

    | makeresults count=1000 | streamstats count AS rowNumber | stats values(rowNumber) AS numbers

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

    numbers
    1
    10
    100
    1000
    101
    102
    103
    104
    105
    106
    107
    108
    109
    11
    110

    Notice that it is a single result. There are no alternating row background colors.

  3. Compare these results with the results returned by the list function.
Last modified on 01 June, 2023
Event order functions   Time functions

This documentation applies to the following versions of Splunk® Enterprise: 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.1.6, 7.1.7, 7.1.8, 7.1.9, 7.1.10, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.2.10, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.3.6, 7.3.7, 7.3.8, 7.3.9, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.0.6, 8.0.7, 8.0.8, 8.0.9, 8.0.10, 8.1.0, 8.1.1, 8.1.2, 8.1.3, 8.1.4, 8.1.5, 8.1.6, 8.1.7, 8.1.8, 8.1.9, 8.1.10, 8.1.11, 8.1.12, 8.1.13, 8.1.14, 8.2.0, 8.2.1, 8.2.2, 8.2.3, 8.2.4, 8.2.5, 8.2.6, 8.2.7, 8.2.8, 8.2.9, 8.2.10, 8.2.11, 8.2.12, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 9.0.4, 9.0.5, 9.0.6, 9.0.7, 9.0.8, 9.0.9, 9.0.10, 9.1.0, 9.1.1, 9.1.2, 9.1.3, 9.1.4, 9.1.5, 9.1.6, 9.1.7, 9.2.0, 9.2.1, 9.2.2, 9.2.3, 9.2.4, 9.3.0, 9.3.1, 9.3.2, 9.4.0


Was this topic useful?







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