Skip to content

Facets

A faceted filter, also known as faceted search or faceted navigation, is a user interface design element commonly used in information retrieval systems, databases, and online platforms to enhance search and exploration. It allows users to narrow down search results or browse content by applying multiple filters simultaneously.

Facet filters are autogenerated and using them is instant.

Producing facets

Each log line can produce multiple facates that will be used to generate automatic filters

ts
(line: Message): CellHandler => {
    return {
        text: line.json_content.method,
        facets: [
            { name: "Method", value: line.json_content.method }
        ]
    }
}

An example code containing a single facet produced based on method field in the json_content. Because you're using code to generate facets, you can use bespoke logic to decide when and what values to generate.

The below example presents a custom logic for producing a facet value.

ts
(line: Message): CellHandler => {

    facets = []

    if(line.json_content.method.includes('foo')){
        facets.push({ name: "Method", value: line.json_content.method })
    }

    return {
        text: line.json_content.method,
        facets: facets
    }
}

Automatic filters

Filters in the left column are generated automatically based on the Facets produced for each line. Below you can see in the screenshot selected values for different facets.

Facets and filters

Faceted column

Since a lot of times you will end up writing repetitive code that produces a facet like this:

ts
(line: Message): CellHandler => {
    return {
        text: line.json_content.method,
        facets: [
            { name: "Method", value: line.json_content.method }
        ]
    }
}

We've added faceted option to a column. Enabling it will work exactly the same as the above code, except that you don't have to write it so it takes a blink of an eye to enable facets for multiple columns as presented below.

Faceted column

Filtering logic

When selecting facets from multiple groups, the logic used will select rows that meet ALL of the selected values. However for values selected within a single facet, the rows that meet ANY of the values will be selected.

To better illustrate the example. For the above screenshort the filtering logic will look like

Method == POST AND Level == error AND Issuer == disover

However, if you select and additional value from Level facets, then the logic will turn into

Method == POST AND (Level == error OR Level == info) AND Issuer == disover

You can use top bar to provide a search phrase. Currently a full-text-search is conducted, meaning that you have to exactly specify what you are searching for.

Correlation IDs

Logdy can automatically filter log messages that are correlated by the same ID (read more on our blog post). Simply assign a correlation_id field in a middleware for each received log message.

Let's suppose your log messages contain a requestId that holds a random string and that value will be assigned to all of the log messages produced during a particular request lifecycle or a user transaction.

json
{
  "requestId": "UmAdplHI",
  "ts": "19:40:37.3196",
  "uuid": "6b46d8b6-8f2b-4bba-bfa8-85b2cc9a85c9",
  "message": "action successful"
  // more fields...
}

INFO

Keep in mind that the request (or a transaction) can span across multiple modules, services or even remote machines. These can produce logs in different formats, however, one thing in common should be that they all pass the requestId between each other. This is critical for later correlation of these log messages in a centralized logs viewer.

Since it's a JSON format, Logdy supports it naturally, so now you can setup a simple middleware that will assign a correlation_id from a log message.

ts
(line: Message): Message | void => {
    // Simple assignment if all of the logs share the same format
    line.correlation_id = line.json_content.requestId

    // You can assign `correlation_id` from different formats
    let jc = line.json_content
    line.correlation_id = jc.requestId || jc['x-correlation-id'] || jc.reqUuid

    return line;
}

Next, open a specific log message. If the correlation_id has a value assigned, a button Display correlated lines will be active. Clicking it, will filter all of the visible rows to only the ones that share the same correlation_id.

TIP

Keep in mind that current filters and facets will still be applied after you activate filter on correlated log messages.