Tjahzi

Tjahzi is a low overhead logging client for Loki

License

License

GroupId

GroupId

pl.tkowalcz
ArtifactId

ArtifactId

tjahzi
Last Version

Last Version

0.9.1
Release Date

Release Date

Type

Type

pom
Description

Description

Tjahzi
Tjahzi is a low overhead logging client for Loki
Project URL

Project URL

https://github.com/tkowalcz/tjahzi
Source Code Management

Source Code Management

https://github.com/tkowalcz/tjahzi

Download tjahzi

Filename Size
tjahzi-0.9.1.pom 6 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/pl.tkowalcz/tjahzi/ -->
<dependency>
    <groupId>pl.tkowalcz</groupId>
    <artifactId>tjahzi</artifactId>
    <version>0.9.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/pl.tkowalcz/tjahzi/
implementation 'pl.tkowalcz:tjahzi:0.9.1'
// https://jarcasting.com/artifacts/pl.tkowalcz/tjahzi/
implementation ("pl.tkowalcz:tjahzi:0.9.1")
'pl.tkowalcz:tjahzi:pom:0.9.1'
<dependency org="pl.tkowalcz" name="tjahzi" rev="0.9.1">
  <artifact name="tjahzi" type="pom" />
</dependency>
@Grapes(
@Grab(group='pl.tkowalcz', module='tjahzi', version='0.9.1')
)
libraryDependencies += "pl.tkowalcz" % "tjahzi" % "0.9.1"
[pl.tkowalcz/tjahzi "0.9.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • tjahzi-protobuf
  • loki-log4j2-appender
  • tjahzi-core

About

Tjahzi is a set of Java tools and appenders for logging to Grafana Loki.

License: MIT Last Commit CircleCI

Latest releases:

Maven Central Maven Central Maven Central

If you find the project useful (or not useful for some reason) please let me know to encourage further development. Stars are also welcome ;).

Features

Tjahzi allows pushing log data to Loki. It uses protobuf format to push log lines with timestamps and labels to Loki. This is implemented in the core component. On top of that we built appenders for log4j2 and Logback. These feature:

  1. Logging does not allocate objects nor take any locks.
  2. Sending data to Loki in batches allocates as little as possible.
  3. We also provide a no-dependency versions of these appenders.
  4. Includes in-house implementation of protobuf wire format for Loki to reduce dependencies and improve performance.

Log4j2 appender is currently used to ship logs from tens of servers at about 10GB of logs per day.

Getting started

Log4j2

For log4j2 appender quick start guide and detailed discussions see this README.md.

Logback

For Logback appender quick start guide and detailed discussions see this README.md.

Core design principles

Logging should be lightweight and not interfere with main business tasks of threads that happen to log a message. Asking the logging subsystem to log a message should be as CPU efficient as possible. That's a truism. Apart from computation itself there are many other causes of jitter (varying speed of code execution). Thread can be slowed down by excessive allocations, by initialization code running in constructors of unnecessarily allocated objects, by garbage collector activity that is triggered by it. There can by configuration refresh checks on logging path, inter thread signaling etc.

To avoid these effects we strive to adhere to the following principles (and document any violations):

  1. Lock free and wait free API
  2. Allocation free in steady state

You can compare this with design principles of Aeron which are close to our hearts.

Architecture

                [via 10kB thread local buffer]
                           │                                          
┌─────────────┐    Log  ←──┘                                                
│ Application │----------------┐                                          
│  Thread 1   │                │                                          
└─────────────┘                │                                          
                               │                                          
       .                       ▼                                          
                          ┌────────────────────┐         ┌─────────┐         ┌─────────┐
       .      Log         │                    │         │ Reading │         │  I/O    │
          ---------------▶│     Log buffer     ├--→---→--┤ agent   ├--→---→--┤ thread  │      
       .                  │                    │         │ thread  │         │ (Netty) │    
                          └────────────────────┘         └─────────┘         └─────────┘    
       .                             ▲                                    
                                     │                                    
┌─────────────┐      Log             │                                    
│ Application │----------------------┘                                    
│  Thread N   │                                                           
└─────────────┘                                                           

For those interested wiki contains some information on log buffer sizing.

LICENSE

This work is released under MIT license. Feel free to use, copy and modify this work as long as you credit original authors. Pull and feature requests are welcome.

Versions

Version
0.9.1
0.9
0.8.2
0.8.1
0.8
0.6
0.5
0.4