View Source ClickhouseLogger (ClickhouseLogger v0.1.0)

The Elixir Logger backend that sends logs to clickhouse server.

configuration-example

Configuration example

# config.exs
config :logger, ClickhouseLogger,
  base_uri: "http://localhost:8123",
  database: "logs",
  fields: [
    ts: :timestamp,
    msg: :message,
    app: {:meta, :app, :string},
    file: {:meta, :file, :string},
    line: {:meta, :line, :uint32},
  ]

config :logger,
  baclends: [:console, ClickhouseLogger]

common-configuration-options

Common configuration options

database

database

The Clickhouse database to write logs to. Default value: "default".

table

table

The Clickhouse table to write logs to. Default value: "logs".

fields-required

fields (required)

A keyword list of logged fields. The keys is a Clickhouse table field names. The values can be one of:

  • :timestamp, :message atoms to log appropriate log fields.
  • {:meta, field_name, type} to log appropriate field from metadata. Currently supported types: :string, :uint8/16/32/64, :int8/16/32/64 and {:array, type}.
  • {CustomModule, :custom_func, type} to custom encode logged value. CustomModule.custom_func/4 will be called with level, timestamp, message and metadata arguments and should return logged value.

buffer_size

buffer_size

The number of message that will be buffered in memory before sending to Clickhouse. Default value: 1_000.

buffer_timeout

buffer_timeout

The number of milliseconds after which all buffered messages will be sent to Clickhouse even if they not exceeds buffer_size value. Default value: 3_000.

buffer_limit

buffer_limit

The maximum number of messages in memory buffer. This option needed for cases when Clickhouse server is not available for some reasons. If this limit is reached futher log messages will be dropped. Default value: 10_000.

http-client-configuration-options

HTTP client configuration options

base_uri-required

base_uri (required)

the HTTP endpoint of Clickhouse server URL.

Link to this section Summary

Link to this section Types

@type level() :: :debug | :info | :warn | :error | atom()
@type message() :: iodata()
@type metadata() :: keyword()