Файловый менеджер - Редактировать - /usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/loki.cpython-310.pyc
Ðазад
o G%@iT � @ s^ d dl mZ d dlmZmZmZ d dlmZmZmZ d dl m Z mZmZ G dd� de e�Z dS )� )�Optional)�datetime� timedelta�timezone)�JSONDecodeError�dumps�loads)�Plugin�IndependentPlugin� PluginOptc @ s� e Zd ZdZdZdZdZdZdZdZ e dd d d�e dd d d�e dd dd�e ddedd�e ddedd�gZde e de e fdd�Zde e de e fdd�Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'S )(�Lokia Collects logs and configuration from Loki. This plugin interacts with the Loki API to fetch logs based on specified labels and provides options for pagination and label detection. It also collects relevant configuration files and masks sensitive information. It works with both charmed and non-charmed Loki. To fetch internal Loki logs, run it from the Loki container. You can also run it from another machine and fetch only logs from Loki API, by providing the following parameters: `-k loki.collect-logs=true -k loki.endpoint=LOKI_URL` Usage: sos report -o loki -k loki.collect-logs=true -k loki.labels=severity:charm -k loki.detect-labels=true -k loki.paginate=true -k loki.endpoint=LOKI_URL zLoki service�loki)�servicesi� �d )r �collect-logsFzcollect logs from Loki API)�default�desc� detect-labelszTfetch logs for all available labels. May result in multiple files with the same logs�paginatez'fetch all available logs from Loki API.�labels� z1colon-delimited list of labels to fetch logs from)r �val_typer �endpoint�http://localhost:3100zDloki endpoint to fetch logs from. Defaults to http://localhost:3100.�start�endc C s` |st �tj�}|s|tdd� }|�d�}|�d�}d|� d|� d|� d|� dtj� d �}|S ) N� )�daysz%Y-%m-%dT%H:%M:%S.%fZ�curl -G -s 'z3/loki/api/v1/query_range' --data-urlencode 'query={z!=~".+"}' --data-urlencode 'start=z' --data-urlencode 'end=z' --data-urlencode 'limit=z' )r �nowr �utcr �strftimer �LOKI_QUERY_LIMIT)�selfr �labelr r �start_formatted� end_formatted�command� r( �9/usr/lib/python3/dist-packages/sos/report/plugins/loki.py� query_command<