Ingest data with Fluent Bit into Azure Data Explorer

Fluent Bit is an open-source agent that collects logs, metrics, and traces from various sources. It allows you to filter, modify, and aggregate event data before sending it to storage. Azure Data Explorer is a fast and highly scalable data exploration service for log and telemetry data. This article guides you through the process of using Fluent Bit to send data to Azure Data Explorer.

In this article, you'll learn how to:

For a complete list of data connectors, see Data connectors overview.

Prerequisites

Create an Azure Data Explorer table to store your logs

Fluent Bit forwards logs to Azure Data Explorer in JSON format with three properties: log (dynamic), tag (string), and timestamp (datetime).

You can create a table with columns for each of these properties. Alternatively, if you have structured logs, you can create a table with log properties mapped to custom columns. To learn more, select the relevant tab.

To create a table for incoming logs from Fluent Bit:

  1. Select the database where you'd like to create the table.

  2. Run the following .create table command:

    .create table FluentBitLogs (log:dynamic, tag:string, timestamp:datetime)
    

    Azure Data Explorer automatically maps incoming JSON properties into the correct column.

Register an Azure AD app with permissions to ingest data

Azure Active Directory (Azure AD) application authentication is used for applications that need to access Azure Data Explorer without a user present. To ingest data using Fluent Bit, you need to create and register an Azure AD service principal, and then authorize this principal to ingest data into your Azure Data Explorer table.

  1. Create an Azure AD application registration.

  2. Save the Application (client) ID, Directory (tenant) ID, and client secret key value for use in the following steps.

  3. Run the following command, replacing <MyDatabase> with the name of the database:

    .add database MyDatabase ingestors ('aadapp=<Application (client) ID>;<Directory (tenant) ID>' 'Fluent Bit application)
    

    This command grants the application permissions to ingest data into your table. For more information, see role-based access control.

Configure Fluent Bit to send logs to your table

To configure Fluent Bit to send logs to your Azure Data Explorer table, create a classic mode or YAML mode configuration file with the following output properties:

Field Description
Name azure_kusto
Match A pattern to match against the tags of incoming records. It's case-sensitive and supports the star (*) character as a wildcard.
Tenant_Id Directory (tenant) ID from Register an Azure AD app with permissions to ingest data.
Client_Id Application (client) ID from Register an Azure AD app with permissions to ingest data.
Client_Secret The client secret key value Register an Azure AD app with permissions to ingest data.
Ingestion_Endpoint Use the Data Ingestion URI found in the Azure portal under your cluster overview.
Database_Name The name of the database that contains your logs table.
Table_Name The name of the table from Create an Azure Data Explorer table.
Ingestion_Mapping_Reference The name of the ingestion mapping from Create an Azure Data Explorer table. If you didn't create an ingestion mapping, remove the property from the configuration file.

To see an example configuration file, select the relevant tab:

[SERVICE]
    Daemon Off
    Flush 1
    Log_Level trace
    HTTP_Server On
    HTTP_Listen 0.0.0.0
    HTTP_Port 2020
    Health_Check On

[INPUT]
    Name tail
    Path /var/log/containers/*.log
    Tag kube.*
    Mem_Buf_Limit 1MB
    Skip_Long_Lines On
    Refresh_Interval 10

[OUTPUT]
    Name azure_kusto
    Match *
    Tenant_Id azure-tenant-id
    Client_Id azure-client-id
    Client_Secret azure-client-secret
    Ingestion_Endpoint azure-data-explorer-ingestion-endpoint
    Database_Name azure-data-explorer-database-name
    Table_Name azure-data-explorer-table-name

Verify that data is ingested into Azure Data Explorer

Once the configuration is complete, logs should arrive in your Azure Data Explorer table.

  1. To verify that logs have been ingested, run the following query:

    FluentBitLogs
    | count
    
  2. To view a sample of log data, run the following query:

    FluentBitLogs
    | take 100