|
1 |
| -[[log-correlation]] |
2 |
| -== Log correlation |
| 1 | +[[logs]] |
| 2 | +== Logs |
3 | 3 |
|
4 |
| -Log correlation allows you to navigate to all logs belonging to a particular trace, and vice-versa -- for a specific log, see in which context it has been logged, and which parameters the user provided. |
| 4 | +Elastic Python APM Agent provides the following log features: |
5 | 5 |
|
6 |
| -The Agent provides integrations with both the default Python logging library, |
7 |
| -as well as http://www.structlog.org/en/stable/[`structlog`]. |
| 6 | +- <<log-correlation-ids>> : Automatically inject correlation IDs that allow navigation between logs, traces and services. |
| 7 | +- <<log-reformatting>> : Automatically reformat plaintext logs in {ecs-logging-ref}/intro.html[ECS logging] format. |
8 | 8 |
|
9 |
| -* <<logging-integrations>> |
10 |
| -* <<log-correlation-in-es>> |
| 9 | +Those features are part of {observability-guide}/application-logs.html[Application log ingestion strategies]. |
| 10 | + |
| 11 | +The {ecs-logging-python-ref}/intro.html[`ecs-logging-python`] library can also be used to use the {ecs-logging-ref}/intro.html[ECS logging] format without an APM agent. |
| 12 | +When deployed with the Python APM agent, the agent will provide <<log-correlation-ids,log correlation>> IDs. |
11 | 13 |
|
12 | 14 | [float]
|
13 |
| -[[ecs-logging]] |
14 |
| -=== `ecs-logging` |
| 15 | +[[log-correlation-ids]] |
| 16 | +=== Log correlation |
15 | 17 |
|
16 |
| -The easiest way to integrate your logs with APM is to use the |
17 |
| -https://github.com/elastic/ecs-logging-python[`ecs-logging`] library, which |
18 |
| -is also provided by Elastic. This library provides formatters for both `logging` |
19 |
| -and `structlog` which create ECS-compatible logs and will include the tracing |
20 |
| -information required for log correlation in kibana. Coupled with something like |
21 |
| -https://www.elastic.co/beats/filebeat[Filebeat], it is the easiest way to get |
22 |
| -logs into Elasticsearch. |
| 18 | +{apm-guide-ref}/log-correlation.html[Log correlation] allows you to navigate to all logs belonging to a particular trace |
| 19 | +and vice-versa: for a specific log, see in which context it has been logged and which parameters the user provided. |
23 | 20 |
|
| 21 | +The Agent provides integrations with both the default Python logging library, |
| 22 | +as well as http://www.structlog.org/en/stable/[`structlog`]. |
| 23 | + |
| 24 | +* <<logging-integrations>> |
| 25 | +* <<log-correlation-in-es>> |
24 | 26 |
|
25 | 27 | [float]
|
26 | 28 | [[logging-integrations]]
|
27 |
| -=== Logging integrations |
| 29 | +==== Logging integrations |
28 | 30 |
|
29 | 31 | [float]
|
30 | 32 | [[logging]]
|
31 |
| -==== `logging` |
| 33 | +===== `logging` |
32 | 34 |
|
33 | 35 | For Python 3.2+, we use https://docs.python.org/3/library/logging.html#logging.setLogRecordFactory[`logging.setLogRecordFactory()`]
|
34 | 36 | to decorate the default LogRecordFactory to automatically add new attributes to
|
@@ -66,7 +68,7 @@ your log handlers, as handlers are propagated, along with their attached filters
|
66 | 68 |
|
67 | 69 | [float]
|
68 | 70 | [[structlog]]
|
69 |
| -==== `structlog` |
| 71 | +===== `structlog` |
70 | 72 |
|
71 | 73 | We provide a http://www.structlog.org/en/stable/processors.html[processor] for
|
72 | 74 | http://www.structlog.org/en/stable/[`structlog`] which will add three new keys
|
@@ -174,3 +176,13 @@ Then, you could use a grok pattern like this (for the
|
174 | 176 | ]
|
175 | 177 | }
|
176 | 178 | ----
|
| 179 | + |
| 180 | +[float] |
| 181 | +[[log-reformatting]] |
| 182 | +=== Log reformatting (experimental) |
| 183 | + |
| 184 | +The agent can automatically reformat application to ECS format when the application includes the `ecs-logging-python` library in its dependencies. |
| 185 | + |
| 186 | +Log reformatting is controlled by the <<config-log_ecs_reformatting, `log_ecs_reformatting`>> configuration option, and is disabled by default. |
| 187 | + |
| 188 | +The reformatted logs will include both the <<log-correlation-ids, trace and service correlation>> IDs. |
0 commit comments