🕓 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,
- and 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 the Loki tool 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.
- Find the "Logging&Tracing" section in the sidebar menu and go to the "Logging" option.
- You have different options to enter a query:
- You can use "Log browser" button to automatically generate a query:
- Select some labels and then select values for each of these labels.
- Tool will automatically generate the query, which you can see as "Resulting selector" at the bottom of log browser.
- Press "Show logs" button.
- You can write your own queries from basic queries and then click on the "Run Query" button.:
- Logs for your namespace:
- Logs for the specific application:
- NOTE: You can't use traceID for application logs.
- Logs for your namespace:
To understand how to write more complex queries, please refer to LogQL's online documentation.
To understand how to write queries for the Loki tool, please refer to "Loki Cheat Sheet".
- The appeared graph shows you the request statistics in time. Below it you will find application logs.
- You can also set the appearance of the logs: time, unique labels, wrap lines or dedup. You can additionally flip the results' order.
- You can expand the log to see more details
- You can click on "Jaeger" button to see the corresponding trace
- You can set the time range for your application and see the corresponding logs.
- Additional information related to time range controls is available in the corresponding section of Grafana's online documentation.
- For live monitoring of your application, click on the "Live" button.
- For pausing or stopping the live monitoring, simply click on the "Live" button again.
- If you want to add another query and run both the original query and the new query at the same time, you can click on the "Add query" button.
- You can simply disable or remove a query by clicking on buttons in the right side of the query
- You can split your screen in two by clicking on the "split" sign.
- Here we described the basics of using Logging in Grafana. For more details visit the corresponding section of Grafana's online documentation.