The table()
function displays query results
in a table, allowing to specify the list of fields to include in
the table.
The table()
function is an aggregate
function and does as follows:
- Sorts columns in the table based on specified field order.
-
Aggregates events based on the
limit
parameter. It will limit the number of events returned using thelimit
parameter. -
Sorts results according to the
sortby
parameter.
For large data exports, consider using the
select()
function instead. The
select()
function provides similar tabular
output but without row limits or sorting constraints.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
fields [a] | array of strings | required | The names of the fields to select. | |
limit | number | optional[b] | 200 | The argument given to this parameter determines the limit on the number of rows included in the result of the function. The maximum is controlled by the StateRowLimit dynamic configuration, which is StateRowLimit by default. If the argument is max (limit=max ), then the value of StateRowLimit is used. |
order | array of strings | optional[b] | desc | Order to sort in. |
Values | ||||
asc | Ascending (A-Z, 0-9) order | |||
desc | Descending (Z-A, 9-0) order | |||
reverse | boolean | optional[b] | Whether to sort in descending order. Deprecated: prefer order instead. | |
sortby | array of strings | optional[b] | @timestamp | Names of fields to sort by. |
type | array of strings | optional[b] | number | Type of the fields to sort. |
Values | ||||
any | Any fields. (deprecated in 1.125) | |||
hex | Hexadecimal fields | |||
number | Numerical fields | |||
string | String fields | |||
[b] Optional parameters use their default value unless explicitly set. |
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
fields
can be omitted; the following forms of this function are equivalent:logscale Syntaxtable(["value"])
and:
logscale Syntaxtable(fields=["value"])
These examples show basic structure only.
table()
Syntax Examples
Create a table of HTTP GET methods displaying the fields statuscode and responsetime:
method=GET
| table([statuscode, responsetime])
Display the 50 slowest requests by name and responsetime:
table([name, responsetime], sortby=responsetime, limit=50, order=asc)
table()
Examples
Click
next to an example below to get the full details.Calculate Query Costs by User and Repository in a Single Field
Calculate query costs by user across multiple repositories, showing the repository/user as a single field
Query
#type=humio #kind=logs class=c.h.j.RunningQueriesLoggerJob message="Highest Cost query"
| repoUser:= format("%s/%s", field=[dataspace, initiatingUser])
| top(repoUser, sum=deltaTotalCost, as=cost)
|table([cost, repoUser], sortby=cost)
Introduction
In this example, the query filter events in the humio
repository that are tagged with
kind
equal to
logs
and then returns the events
where the class field has values
containing
c.h.j.RunningQueriesLoggerJob
,
searching for the specific value Highest Cost
query
. The query then combines the results in a new field
repoUser. The query then uses
top()
and table()
functions to
aggregate and display the results.
Example incoming data might look like this:
#type | #kind | class | message | timestamp | dataspace | initiatingUser | totalLiveCost | totalStaticCost | deltaTotalCost | repo |
---|---|---|---|---|---|---|---|---|---|---|
humio | logs | c.h.j.RunningQueriesLoggerJob | Highest Cost query | 2025-03-26T09:30:00Z | production | john.doe | 1500 | 800 | 2300 | security-logs |
humio | logs c.h.j.RunningQueriesLoggerJob | Highest Cost query | 2025-03-26T09:31:00Z | development | jane.smith | 2000 | 1200 | 3200 | app-logs | |
humio | logs | c.h.j.RunningQueriesLoggerJob | Highest Cost query | 2025-03-26T09:32:00Z | staging | bob.wilson | 1000 | 500 | 1500 | infra-logs |
humio | logs | c.h.j.RunningQueriesLoggerJob | Highest Cost query | 2025-03-26T09:33:00Z | production | john.doe | 1800 | 900 | 2700 | security-logs |
humio | logs | c.h.j.RunningQueriesLoggerJob | Highest Cost query | 2025-03-26T09:34:00Z | development | jane.smith | 2500 | 1300 | 3800 | app-logs |
humio | logs | c.h.j.RunningQueriesLoggerJob | Highest Cost query | 2025-03-26T09:35:00Z | staging | alice.cooper | 1200 | 600 | 1800 | infra-logs |
Step-by-Step
Starting with the source repository events.
- logscale
#type=humio #kind=logs class=c.h.j.RunningQueriesLoggerJob message="Highest Cost query"
Filters for Humio internal logs containing
c.h.j. RunningQueriesLoggerJob
in the class field and where the value in the message field is equal toHighest Cost query
. - logscale
| repoUser:= format("%s/%s", field=[dataspace, initiatingUser])
Combines the fields dataspace and initiatingUser with a
/
separator, and then assigns the combined value to a new field named repoUser. Example of combined value:dataspace/username
. - logscale
| top(repoUser, sum=deltaTotalCost, as=cost)
Finds the most common values in the field repoUser, makes a sum of the field deltaTotalCost, and returns the results in a new field named cost.
- logscale
|table([cost, repoUser], sortby=cost)
Displays the results in a table with fields
cost
andrepoUser
, sorted by the columncost
. Event Result set.
Summary and Results
The query is used to search across multiple repositories and calculate query costs per user, by combining costs and showing the repository/user as a single field.
Sample output from the incoming example data:
cost | repoUser |
---|---|
3200 | development/jane.smith |
2300 | production/john.doe |
1500 | staging/bob.wilson |