Get started with logging

ezgif.com-gif-maker.jpg

Introduction

Better Stack allows you to collect logs across your stack, be it from your node.js app or a Kubernetes cluster, and centralize them into one place. But it's not just storage. With Better Stack, you can live tail and query your logs with blazing speeds using SQL. You can build actionable dashboards and explore all the insights your logs have to give.

On top of that, you can configure presence/absence alerts and get notified whenever there is an issue. All that while collaborating with your colleagues by commenting on specific log fragments and sharing links.

If this is your first time working with logging, we recommend starting with our Logging guides .

Starting with centralized logging

To start logging, we need to connect a source to our Better Stack account. A source is a service that generates logs which are then sent to Better Stack, for example, an application or a web server.

Step 1: Creating a source

a08f24d-connectsourcebutton.png

  • Then name your source (name can be changed later)
  • Then select the type of the source you are connecting. For example, if you are integrating Better Stack into a Node application, select "Node.js". Logs will be then automatically parsed based on the platform.

Step 2: Testing the pipes

You can now test the pipes to see if the Logs are arriving correctly. For this, you will need a source token. Every source has a unique source token that identifies it and is used to connect the actual source to Better Stack.

  • Go to Sources β†’ select the desired Source
  • You'll find the Source token in the Basic information section

fa5633d-sourcetoken.png

Send logs to Logtail
curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer $SOURCE_TOKEN' \
-d '{"dt":"'"$(date -u +'%Y-%m-%d %T UTC')"'","message":"Hello from Better Stack!"}' \
-k \
https://in.logs.betterstack.com
  • Now, navigate to the Live tail tab and select the newly created source. You'll see a log message like this:
Output
{
  "dt":"2022-06-15 11:24:09.000 UTC",
  "message_string":"Hello from Better Stack!"
}

Amazing job! πŸŽ‰ You have just sent your first log message.

Next steps to enhance your logging set-up πŸ„β€β™€οΈ

Now that Better Stack is set up to receive your logs, you can integrate it into your application.

The integration setup depends on the source. Here are guides for the most popular ones:

Source not listed here? Go to Log Sources to see the integration guides for all the available sources.