Get started with logging in Logtail

ezgif.com-gif-maker.jpg

Introduction

Logtail 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 Logtail, 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.

info

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 Logtail account. A source is a service that generates logs which are then sent to Logtail, 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 Logtail 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 Logtail.

  • Go to Sources -> select the desired Source
  • You'll find the Source token in the Basic information section

fa5633d-sourcetoken.png

  • Then run the following command in the terminal. Don't forget to replace the <YourSourceToken> with your source token.
curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <YourSourceToken>' \
-d '{"dt":"'"$(date -u +'%Y-%m-%d %T UTC')"'","message":"Hello from Logtail!"}' \
-k \
https://in.logtail.com
Copied!
  • Now, navigate to the Live tail tab and select the newly created source. You'll see a log message like this:
{
  "dt":"2022-06-15 11:24:09.000 UTC",
  "message_string":"Hello from Logtail!"
}
Copied!

Amazing job! 🎉 You have just sent your first log message.

Next steps to enhance your logging set-up 🏄‍♀️

Now that Logtail is set up to receive your logs, you can integrate it into your project.

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.