You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,23 +22,24 @@ A logging handler that sends log messages to **(Grafana) Loki** in JSON format.
22
22
* label_keys (dict, optional): A dictionary of keys to extract from each log message and use as labels. Defaults to None.
23
23
* auth (tuple, optional): Basic authentication credentials for the Loki request. Defaults to None.
24
24
* additional_headers (dict, optional): Additional headers for the Loki request. Defaults to None.
25
-
* timeout (int, optional): Timeout interval in seconds to wait before flushing the buffer. Defaults to 10 seconds.
26
-
* compressed (bool, optional): Whether to compress the log messages before sending them to Loki. Defaults to True.
27
-
* loguru (bool, optional): Whether to use `LoguruFormatter`. Defaults to False.
28
-
* default_formatter (logging.Formatter, optional): Formatter for the log records. If not provided,`LoggerFormatter` or `LoguruFormatter` will be used.
29
-
* enable_self_errors (bool, optional): Set to True to show Hanlder errors on console. Defaults to False
25
+
* message_in_json_format (bool): Whether to format log values as JSON.
26
+
* timeout (int, optional): Timeout interval for flushing logs in seconds. Defaults to 10 seconds.
27
+
* compressed (bool, optional): Whether to compress the logs before sending them using gzip. Defaults to True.
28
+
* default_formatter (logging.Formatter, optional): Formatter for the log records. If not provided, `LoggerFormatter` or`LoguruFormatter` will be used.
29
+
* enable_self_errors (bool, optional): Set to True to show Handler errors on console. Default False
30
+
30
31
### Loki 3.0
31
32
* enable_structured_loki_metadata (bool, optional): Whether to include structured loki_metadata in the logs. Defaults to False. Only supported for Loki 3.0 and above
32
33
* loki_metadata (dict, optional): Default loki_metadata values. Defaults to None. Only supported for Loki 3.0 and above
33
-
* loki_metadata_keys (arrray, optional): Specific log record keys to extract as loki_metadata. Only supported for Loki 3.0 and above
34
+
* loki_metadata_keys (array, optional): Specific log record keys to extract as loki_metadata. Only supported for Loki 3.0 and above
34
35
35
36
## Formatters
36
37
***LoggerFormatter**: Formatter for default python logging implementation
37
38
***LoguruFormatter**: Formatter for Loguru python library
38
39
39
40
## How to use
40
41
41
-
First create a environment varialble to setup your loki url with this structure (Ej: https://100239:wdadw....dwad@logs-prod-eu-west-0.grafana.net/loki/api/v1/push)
42
+
First create an environment variable to set up your loki url with this structure (Ej: https://100239:wdadw....dwad@logs-prod-eu-west-0.grafana.net/loki/api/v1/push)
Copy file name to clipboardExpand all lines: loki_logger_handler/loki_logger_handler.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -42,18 +42,18 @@ def __init__(
42
42
43
43
Args:
44
44
url (str): The URL of the Loki server.
45
-
labels (dict): Default labels for the logs.
46
-
label_keys (dict, optional): Specific log record keys to extract as labels. Defaults to None.
45
+
labels (dict): A dictionary of labels to attach to each log message.
46
+
label_keys (dict, optional): A dictionary of keys to extract from each log message and use as labels. Defaults to None.
47
47
auth (tuple, optional): Basic authentication credentials for the Loki request. Defaults to None.
48
48
additional_headers (dict, optional): Additional headers for the Loki request. Defaults to None.
49
49
message_in_json_format (bool): Whether to format log values as JSON.
50
-
timeout (int, optional): Timeout interval for flushing logs. Defaults to 10 seconds.
51
-
compressed (bool, optional): Whether to compress the logs using gzip. Defaults to True.
52
-
default_formatter (logging.Formatter, optional): Formatter for the log records. If not provided, LoggerFormatter orLoguruFormatter will be used.
53
-
enable_self_errors (bool, optional): Set to True to show Hanlder errors on console. Default False
50
+
timeout (int, optional): Timeout interval for flushing logs in seconds. Defaults to 10 seconds.
51
+
compressed (bool, optional): Whether to compress the logs before sending them using gzip. Defaults to True.
52
+
default_formatter (logging.Formatter, optional): Formatter for the log records. If not provided, `LoggerFormatter` or`LoguruFormatter` will be used.
53
+
enable_self_errors (bool, optional): Set to True to show Handler errors on console. Default False
54
54
enable_structured_loki_metadata (bool, optional): Whether to include structured loki_metadata in the logs. Defaults to False. Only supported for Loki 3.0 and above
55
55
loki_metadata (dict, optional): Default loki_metadata values. Defaults to None. Only supported for Loki 3.0 and above
56
-
loki_metadata_keys (arrray, optional): Specific log record keys to extract as loki_metadata. Only supported for Loki 3.0 and above
56
+
loki_metadata_keys (array, optional): Specific log record keys to extract as loki_metadata. Only supported for Loki 3.0 and above
0 commit comments