Git Product home page Git Product logo

logchain's Introduction

Logchain

Logchain is a GRPC adapter for clickhouse and postgres for sinking and persisting application logs.

Use cases

  • When applications are deployment on-premise or on customer side. Logchain provides visibility into Errors for application support without additional infrastructure
  • For small/medium applications that do not need huge logging infrastructure but still need visibility.

Setup Logchain

Install logchain using the following command:

go install github.com/adaptive-scale/[email protected]

Alternatively, you can setup the whole stack as follows:

docker stack deploy logchain --compose-file ./dev/docker-compose.yaml

This will start the logchain server on port 9090, clickhouse on port 8123 and grafana at port 3000.

For golang client, import the logchain client as follows:

package main

import (
	"github.com/adaptive-scale/logchain/pkg/logchain"
	"github.com/adaptive-scale/logchain/pkg/logchainhook"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"github.com/sirupsen/logrus"
)

func main()  {
	conn, err := grpc.Dial("localhost:9090", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		logrus.Fatalf("did not connect: %v", err)
	}
	c := logchain.NewLogChainClient(conn)
	hook := logchainhook.NewLogChainHook("app=name", c, logrus.ErrorLevel)
	logrus.AddHook(hook)
	
	logrus.WithField("key", "value").Error("error message")
}

Setup Logging Dashboards in Grafana

You can select the clickhouse as datasource and then use the following query to get the logs:

SELECT app_name, date(timestamp) dt,  message, labels, count(message) cnt FROM logchain.log_stores  group by app_name, dt, message, labels order by dt desc, cnt desc LIMIT 100

The output of the query looks as follows:

Screenshot 2024-01-18 at 12 49 53

logchain's People

Contributors

debarshibasak avatar neerajnabar-adaptive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.