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
Add logging integrations with logging and structlog (#586)
* Add logging integrations with logging and structlog
* Update changelog
* Simplify and make naming consistent
* Add span.id to logging (and pub API) as well
* Fix more refactor leftovers, test against actual ID
* Add the tracing fields under "correct" name as well
* Add log_record_factory and DRY some code
* Automatically install the log_record_factory
Plus add a test
* Update changelog
* Add more documentation about correlation
* s/elasticapm/The Elastic APM agent/
Co-Authored-By: Benjamin Wohlwend <[email protected]>
* Fix project-level import
Co-Authored-By: Benjamin Wohlwend <[email protected]>
* Apply suggestions from code review
Co-Authored-By: Brandon Morelli <[email protected]>
* Fix up tracing fields link
* Apply suggestions from code review
Co-Authored-By: Brandon Morelli <[email protected]>
* Separate log_record_factory tests from client instantiation
Also fix up some imports and assert elasticapm_labels everywhere
* More docs changes from reviews
* Fix another accidental relative import
* Use full link for ecs docs
* Fix for py2 testing
* Fix missing import (inline due to circular import)
* Remove standalone log_record_factory test
Because of the dynamic insertion in Client, this test was failing
on the wider integration tests (perhaps because it had been inserted
on previous test runs? I'm actually not sure). Anyway, we test
that it works with an instantiated Client so I think this test is
unnecessary.
* Apply suggestions from code review
Co-Authored-By: Benjamin Wohlwend <[email protected]>
Co-Authored-By: Andrew Wilkins <[email protected]>
* Implement config doc changes
* Fix structlog processor to skip None values
In order to correlate logs from your app with transactions captured by the
72
+
Elastic APM Python Agent, your logs must contain one or more of the following
73
+
identifiers:
74
+
75
+
* `transaction.id`
76
+
* `trace.id`
77
+
* `span.id`
78
+
79
+
If you're using structured logging, either https://docs.python.org/3/howto/logging-cookbook.html#implementing-structured-logging[with a custom solution]
80
+
or with http://www.structlog.org/en/stable/[structlog] (recommended), then this
81
+
is fairly easy. Throw the http://www.structlog.org/en/stable/api.html#structlog.processors.JSONRenderer[JSONRenderer]
82
+
in, and use {blog-ref}structured-logging-filebeat[Filebeat]
83
+
to pull these logs into Elasticsearch.
84
+
85
+
Without structured logging the task gets a little trickier. Here we
86
+
recommend first making sure your LogRecord objects have the elasticapm
87
+
attributes (see <<logging>>), and then you'll want to combine some specific
88
+
formatting with a Grok pattern, either in Elasticsearch using
89
+
{ref}/grok-processor.html[the grok processor],
90
+
or in {logstash-ref}/plugins-filters-grok.html[logstash with a plugin].
91
+
92
+
Say you have a https://docs.python.org/3/library/logging.html#logging.Formatter[Formatter]
0 commit comments