Loki-stack monitoring
Monitoring system for metrics and logs collection, data visualization and real-time alerting.
Data range should be set before exporting the logs, for instructions on how to set data range please refer to the grafana documentation:
https://grafana.com/docs/grafana/latest/dashboards/use-dashboards/#common-time-range-controls
1. Logs query
- In order to aggregate all logs from the desired namespace, use the following query:
{namespace="$NAMESPACE"} | line_format "{{.pod}} {{ __line__ }}"
Replace the
$NAMESPACE
with the actual namespace name
- To make the above query more specific, you can use a filter with (for eg.) ID:
{namespace="$NAMESPACE"} | line_format "{{.pod}} {{ __line__ }}" |= "$ID"
2. Grafana logs exporting
- Open Grafana and navigate to the desired dashboard containing the logs you want to export.
- Click on the "Explore" button on the top menu to access the Explorer.
- In the Explorer, select the Loki data source from the drop-down menu on the top left, if it's not already selected.
- Specify the log query or filter in the query input field. You can use labels, keywords, or other parameters to filter the logs according to your requirements.
- Adjust the time range using the time picker located at the top right to specify the time period for which you want to export logs.
- Once you have configured the query and time range, click on the "Run" button to execute the query and fetch the logs.
- The logs will be displayed in the table format below the query input field.
- Click on the "Inspect" button on the top right corner of the table to open the Inspector view.
- In the Inspector, navigate to the "Data" tab.
- Under the "Data" tab, you will see a section called "Raw JSON Data" which shows the logs in JSON format.
- Scroll down to the bottom of the "Data" tab and locate the "Download CSV/Logs" button.
- Click on the "Download CSV/Logs" button to export the logs in CSV format.
3. Learn more
Below you'll find useful documentation about various aspects of these monitoring tools:
Updated over 1 year ago
What’s Next