🕓 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.
- Create a New Application
- Create a New Application Component
- Build your application
- Deploy your Application
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
- In Logging & Tracing section of the sidebar, select Logging.
- 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.
- If you prefer entering a query manually, you can switch by clicking on the Code button.
- If you get lost while generating queries, there is a Loki Cheat Sheet (❓ button) to help you with making queries.
- For a better understanding of Loki's query language, please refer to Loki's documentation.
- Once you have generated a query, run it by clicking on the Run query button.
- 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.
- Find the log you were looking for and click on it for more details.
- 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.
Using More Queries
- Add a new Query by clicking on the Add query button
- 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
Learn more about Loki