Call Named Function on a Field - Example 1

Calls the named function (avg()) on a field over a set of events

Query

logscale
avg_sent:=callFunction("avg", field=bytes_sent)

Introduction

The callFunction() function calls a specific function. The parameters of the called function are passed as parameters in callFunction().

In this example, the callFunction() function is used to find the average bytes sent in HTTP responses. It calls the named function (avg()) on a field over a set of events.

Step-by-Step

  1. Starting with the source repository events.

  2. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0{{Aggregate}} result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    avg_sent:=callFunction("avg", field=bytes_sent)

    Finds the average bytes sent in HTTP response, and returns the results in a new field named avg_sent. Notice that the avg() function is used indirectly in this example.

  3. Event Result set.

Summary and Results

The query is used to find the average bytes sent in HTTP responses. Using a query parameter (for example, ?function) to select the aggregation function for a timeChart() is useful for dashboard widgets.

Using callFunction() allow for using a function based on the data or dashboard parameter instead of writing the query directly.