nevinpuri / erlog

Minimalist log collector
MIT License
112 stars 1 forks source link

Erlog

A Log Platform which runs on a $4 VPS

img1

Features

Sending Logs

Just send a POST request to erlog with JSON

{
  "timestamp": "1675955819",
  "level": "debug",
  "service": "my_service",
  "key": "value",
  "data": {
    "another_key": "another value"
  }
}

Alternatively, run export LOGS=file1.txt file2.txt and those files will be tailed and ingested in to erlog.

Viewing Logs

img2

Querying

Erql is extremely simple. Here are some examples

# search for "foo" in any log (case sensitive)
foo
"foo"

# search where name = "foo" or name = "foo bar"
name:foo
name:"foo bar"

# search for {name: {first: 'foo'}}
name.first:foo
name.first:"foo bar"

# search for name[0] = "item"
name.0:item

# member = true
member:true
member:false

# null search
member:null

# search for height =, >, >=, <, <=
height:=100
height:>100
height:>=100
height:<100
height:<=100

# search for height in range (inclusive, exclusive)
height:[100 TO 200]
height:{100 TO 200}

# AND/OR operators
name:foo AND height:=100
name:foo OR name:bar

# grouping
name:foo AND (bio:bar OR bio:baz)

Instrumenting

Just have your structured logger log in json, and then forward those logs to a file. A collector is coming soon which just tails a file and forwards the requests to your erlog instance.

Look here for an example of an instrumented function.

Example Project

For an example project, see app/main.py. Erlog is instrumented using structlog. If you run export LOGS=file1.txt and python3 -m uvicorn main:app > file1.txt, you will start seeing erlogs logs in erlog.

Using parent_id

import uuid
from structlog import get_logger

logger = get_logger()

# don't forget str()
# making the id a Uuid type won't work
# as it'll be printed as Uuid('iaodjfoiasjdijdsaiojf')
# instead of 'iaodjfoiasjdijdsaiojf'

id = str(uuid.uuid4())
logger.log("root log", id=id)
logger.log("child of root", parent_id=id)

This will show the log "root log" in the erlog ui. Once you click on "root log", you will be able to see "child of root" in the log viewer.

This is useful for when you want to capture logs across many different services, and have them all be in one location.

Todo

installation packages

to install m2crypto on mac

env LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \
pip3 install m2crypto

We get it, monitoring your applications in production is difficult. Most logging platforms are designed for large applications where people need to __.

However, that's not you. You're just building a small project and want to view your logs from your next js api routes, formatted, in one place, without configuring any additional collector. Erlog is really great at doing that.

Most logging platforms are built for enterprise

Most logging platforms aren't built for people like you

(aren't built for people like you)

They have every single use case, a convoluted ui, and follow a standard which is too complicated

ours: