Logging
🕓 10 minutes
#
What you’ll learnHow to use logs of your application for monitoring, debugging, and better understanding the process behind the code.
- Logging helps you to:
- follow the system actions and information about user,
- reveal application problems and where they occur.
#
Prerequisites#
Overview#
Loki toolCodeNow is using the Loki tool for both logs and metrics, which is a horizontally-scallable log aggregation system.
Loki comes with its own PromQL-inspired language for queries called LogQL.
LogQL uses labels and operators for filtering.
For more information about how to write LogQL queries see: https://grafana.com/docs/loki/latest/logql/
If you want to find out more about Loki tool itself, see: https://grafana.com/docs/grafana/latest/datasources/loki/
#
Logs- Find the "Logging&Tracing" section in the sidebar menu and go to the "Logging" option.


- You can investigate your application logs by entering the specific query into the query field and click on the "Run Query" button.
Some basic queries are:
- Logs for your namespace:
{namespace="_name_of_the_namespace_"}
- Logs for the specific application:
{app="_name_of_the_application_", namespace="_name_of_the_namespace_"}
- Logs for your namespace:
NOTE: You can't use traceID for application logs.
You can find out more by looking at the "Loki Cheat Sheet", where you can find instructions on how to write queries for the Loki tool.
- The appeared graph shows you the request statistics in time. Below it you will find application logs.
- Also you can change, if you'd like to see the time, unique labels, wrap lines or set the dedup.

- You can set the time range for your application, to see corresponding logs.
- For more information about time range control, see: https://grafana.com/docs/grafana/latest/dashboards/time-range-controls/

- For life monitoring of your application, click on the "Live" button.
- For pausing or stopping the live monitoring, simply click on the "Live" button again.

- To see the history of your requested queries, click on the "Query history" button.
- Inside, you will find a "Setting" section, where you can change the history time span and other options.

- If you want to add another query and run both of them at the same time, you can click on the "Add query" button.
- If you want to remove one of the queries, simply click on the button with the minus sign on it.


- You can split your screen into two by clicking on the "split" sign.

- "Log labels" section contains predefined queries that you can use for your application.
- You can search through the different categories such as container, node, release, stream etc.

#
Metrics- Metric queries extend the log queries and calculate the sample values based on the content of the logs from a log query.
- Metric queries can be used to calculate things such as the rate of error messages, or the top N log sources with the most amount of logs over the last 3 hours.

- You can investigate your application metrics by entering the specific query into the query field.
- You will see a graph that represents the statistics of the requests in time. Below it, you will find the application metrics.

- You can look at the "LogQL Cheat Sheet", where you find instructions on how to write queries for extracting metrics.
- TIP: Instead of a job , you can place the name of your namespace(
namespace="_your_namespace_"
).
- TIP: Instead of a job , you can place the name of your namespace(

#
What’s next?See our other manuals: