GithubHelp home page GithubHelp logo

norpan / lokilogger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wardbekker/lokilogger

0.0 1.0 0.0 33 KB

Elixir Logger Backend for Grafana Loki

License: Apache License 2.0

Elixir 100.00%

lokilogger's Introduction

LokiLogger

LokiLogger is an Elixir logger backend providing support for Logging to Grafana Loki

Hex.pm Version

Known issues

  • "works-on-my-machine" level of quality. Love to get your feedback in the repo's Github issues

Features (and TODO)

  • Elixir Logger formatting
  • Elixir Logger metadata
    • Loki Scope-Org-Id header for multi-tenancy
  • Timezone aware
  • Snappy compressed proto format in the HTTP Body
  • Async http call to backend.
  • Proper unit tests.
  • HTTP post retry strategy on temporary loki backend failure or network hiccups.
  • Authentication with basic auth and/or Oauth2 reverse proxy.
  • CI build integration (e.g. TravisCI)

Installation

The package can be installed by adding loki_logger to your list of dependencies in mix.exs:

def deps do
  [
    {:loki_logger, "~> 0.3.0"}
  ]
end

Configuration

Elixir Project

Loki Logger's behavior is controlled using the application configuration environment:

  • loki_host : the hostname of the syslog server e.g. http://localhost:3100
  • loki_labels : the Loki log labels used to select the log stream in e.g. Grafana
  • loki_scope_org_id: optional tenant ID for multitenancy. Currently not (yet?) supported in Grafana when enforced with auth_enabled: true in Loki config
  • level: logging threshold. Messages "above" this threshold will be discarded. The supported levels, ordered by precedence are :debug, :info, :warn, :error.
  • format: the format message used to print logs. Defaults to: "$metadata level=$level $levelpad$message". It may also be a {module, function} tuple that is invoked with the log level, the message, the current timestamp and the metadata.
  • metadata: the metadata to be printed by $metadata. Defaults to to :all, which prints all metadata.
  • max_buffer: the amount of entries to buffer before posting to the Loki REST api. Defaults to 32.

For example, the following config/config.exs file sets up Loki Logger using level debug, with application label loki_logger_library.

use Mix.Config

config :logger,
       backends: [LokiLogger]

config :logger, :loki_logger,
       level: :debug,
       format: "$metadata level=$level $levelpad$message",
       metadata: :all,
       max_buffer: 300,
       loki_labels: %{application: "loki_logger_library", elixir_node: node()},
       loki_host: "http://localhost:3100"

Protobuff lib regeneration

only needed for development

protoc --proto_path=./lib/proto --elixir_out=./lib lib/proto/loki.proto 

License

Loki Logger is copyright (c) 2019 Ward Bekker

The source code is released under the Apache v2.0 License.

Check LICENSE for more information.

lokilogger's People

Contributors

wardbekker avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.