Skip to main content

Logging

đź•“ 10 minutes

What you’ll learn​

How to use logs of your application for monitoring, debugging, and better understanding of the process behind the code.

Logging helps you to:

  • Follow the system actions and information about user.
  • Reveal application problems together with the place where they occur.

Prerequisites​

Loki​

CodeNow is using Grafana Loki for logs, which is a horizontally scalable log aggregation system.

  • Loki comes with its own language for queries called LogQL.
  • LogQL uses labels and operators for filtering.

How to find a log​

  1. In Logging & Tracing section of the sidebar, select Logging.
  2. In order to generate a query, you need to set label filter expressions. That means choosing a label and attaching a certain value and operation to it.
    • In Loki, a label can represent the namespace, application, pod, etc.
    • Remember that you can't use a traceID for application logs.
    • You can attach multiple label filter expressions to a single query.
  3. If you prefer entering a query manually, you can switch by clicking on the Code button.
  4. If you get lost while generating queries, there is a Loki Cheat Sheet (âť“ button) to help you with making queries.
  5. Once you have generated a query, run it by clicking on the Run query button.
  6. Now you can see the results of your query, specifically:
    • Log statistics in time
    • Application logs
      • You can adjust the appearance with a menu on top of the logs.
  7. Find the log you were looking for and click on it for more details.

Additional settings​

Time​

  • Set the time range on which your query will run by clicking the đź•“ button
  • For live logging, click on the Live button. You can pause or stop the live monitoring by clicking on the Live button again.

Time settings

Using More Queries​

  1. Add a new Query by clicking on the Add query button
  2. You can do the following operations with queries:
    • Duplicate a query - creates a new query with the same settings as the selected one
    • Disable/enable query - query won't/will run when Run query is pressed
    • Remove query - removes the selected query
    • Drag and drop to reorder

tip

Learn more about Loki