loki_api_client package¶
Submodules¶
loki_api_client.loki_connect module¶
A Class for collection of logs from a Loki host.
References
- class loki_api_client.loki_connect.LokiConnect(url: str = 'http://127.0.0.1:3100', headers: Optional[dict] = None, disable_ssl: bool = False, retry: Optional[urllib3.util.retry.Retry] = None, ignore_http_errors: bool = False)[source]¶
Bases:
object
A Class for collection of metrics from a Loki Host.
- Parameters
url (str) – url for the loki host
headers (dict) – A dictionary of http headers to be used to communicate with the host. Example: {“Authorization”: “bearer my_oauth_token_to_the_host”}
disable_ssl (bool) – If set to True, will disable ssl certificate verification for the http requests made to the host
retry (Retry) – Retry adapter to retry on HTTP errors
- query(query: str, limit: int = 10, time: Optional[str] = None, direction: str = 'backward', params: Optional[dict] = None) dict [source]¶
Check if Loki host is ready to accept traffic. Ref: https://grafana.com/docs/loki/latest/api/#query
- Parameters
query (str) – The LogQL query to perform.
limit (int) – The max number of entries to return.
time (str) – The evaluation time for the query as a nanosecond Unix epoch. Defaults to now.
direction (str) – Determines the sort order of logs. Supported values are “forward” or “backward”. Defaults to “backward”.
params (dict) – Optional dictionary containing parameters to be sent along with the API request.
- Returns
A json of queried log data.
- Return type
- ready(params: Optional[dict] = None) bool [source]¶
Check if Loki host is ready to accept traffic. Ref: https://grafana.com/docs/loki/latest/api/#get-ready