supertokens / supertokens-core

Open source alternative to Auth0 / Firebase Auth / AWS Cognito
https://supertokens.com
Other
12.49k stars 485 forks source link

Logging Research(how logs can be exported/piped to the user) #528

Open jscyo opened 1 year ago

jscyo commented 1 year ago

How other Auth providers handle logging:

Auth0:

There are 3 methods for consuming Auth0 logs:

FusionAuth

Tools we can use:

Configure docker's logging driver:

logsput

A popular library that allows for log streaming, can integrate with papertrail

Notes:

jscyo commented 1 year ago

Additional Research:

We want to use log streaming.

The webhook method is where we ask them to give us an HTTP URL. The core would call that URL and stream some log info to it. This allows the user to choose any service to consume the logs.

jscyo commented 1 year ago

Using Logspout for logging and log streaming:

Logspout is a log router that runs as a docker container and listens to other docker images and can steam logs to popular services like AWS cloudwatch, elastic search, and papertrail or any syslog servers.

Using logspout to expose an endpoint that will stream logs

Running the following will create an endpoint http://localhost:3000/logs which will stream logs

docker run -d --name="logspout" \
        --volume=/var/run/docker.sock:/var/run/docker.sock \
        --publish=127.0.0.1:3000:80 \
        gliderlabs/logspout

This can be tested by running the above command and then running curl http://localhost:3000/logs, if you now run the supertokens core you should see the following:

curl_logs

Logspout filtering

Logspout allows you to create filters to filter logs per container name/label/sources

Connecting to other Log collation services:

The main purpose of logspout is to route logs to services like papertrail or aws cloudwatch by supplying a syslog tls endpoint from the service.

For example, connecting with paper trail:

$ docker run --name="logspout" \
    --volume=/var/run/docker.sock:/var/run/docker.sock \
    gliderlabs/logspout \
    syslog+tls://logs.papertrailapp.com:55555

Customizing log format

As mentioned in their docs, you should be able to customize the format for the logs

Testing