Create Data Compatible With Sankey Diagram Widget - Example 1

Create data compatible with sankey diagram widget using the sankey() function to show flow relationship

Query

flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1{{Aggregate}} result{{Result Set}} repo --> 0 0 --> 1 1 --> result
logscale
type=accesslog
| sankey(source=method, target=url)

Introduction

A sankey diagram widget is a visualization used to depict a flow from one set of values to another.

In this example, the sankey() function is used to produce sankey compatible data for a webserver log showing wich URLs matches the HTTP methods.

Example incoming event data might look like this:

typetimestampmethodurl
accesslog2025-05-02 11:45:23GET/api/users
accesslog2025-05-02 11:45:30POST/api/users
accesslog2025-05-02 11:46:12GET/api/products
accesslog2025-05-02 11:46:45PUT/api/users
accesslog2025-05-02 11:47:01DELETE/api/users
accesslog2025-05-02 11:47:33GET/api/orders
accesslog2025-05-02 11:48:02POST/api/orders
accesslog2025-05-02 11:48:15GET/api/cart
accesslog2025-05-02 11:48:45POST/api/login
accesslog2025-05-02 11:49:01GET/api/logout
accesslog2025-05-02 11:49:30GET/api/users
accesslog2025-05-02 11:50:00POST/api/products
accesslog2025-05-02 11:50:23PUT/api/products
accesslog2025-05-02 11:50:45GET/api/users
accesslog2025-05-02 11:51:12POST/api/cart
accesslog2025-05-02 11:51:33GET/api/users
accesslog2025-05-02 11:52:01GET/api/products
accesslog2025-05-02 11:52:30POST/api/orders
accesslog2025-05-02 11:53:00DELETE/api/products
accesslog2025-05-02 11:53:15GET/api/dashboard

Step-by-Step

  1. Starting with the source repository events.

  2. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1{{Aggregate}} result{{Result Set}} repo --> 0 0 --> 1 1 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    type=accesslog

    Filters for all webserver logs. The access log is a list of all requests for individual files (for example HTML files) that users have made from a website, therefore, webserver logs provide valuable business insight.

  3. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1{{Aggregate}} result{{Result Set}} repo --> 0 0 --> 1 1 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    | sankey(source=method, target=url)

    Produces sankey compatible data for a webserver log showing wich URLs matches the HTTP methods. It shows how traffic is distributed across different endpoints.

    Note that source and target are required fields to be able to produce a Sankey Diagram.

  4. Event Result set.

Summary and Results

The query is used to produce data compatible with sankey diagram widgets, in this example visualizing the relationship between HTTP methods and URLs.

Sankey diagram widgets are a powerful data visualization tool used to represent the flow of values between stages, offering valuable insights into the flow of data. When used with well-structured data, they can help identify patterns, bottlenecks, and significant resource allocation trends.

Sankey diagram widgets are useful in case you want to show complex processes visually, with a focus on a single aspect or resource required to be highlighted. Sankey diagram widgets can also be used to reveal inconsistent data, as the visualization of data inconsistencies makes detection easier.

Showing Relationship with sankey()