-
Notifications
You must be signed in to change notification settings - Fork 114
Spec service.environment for logs #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
85a0d70
add environment + move to log-correlation
SylvainJuge 6b9968f
just mention container.id
SylvainJuge 2159735
enforce clear separation between fields
SylvainJuge d8a0d71
Apply suggestions from code review
SylvainJuge c5cc952
remove the MDC that is too java-specific
SylvainJuge 47dc07f
remove 'span.id' for now
SylvainJuge fbde920
clarify 'container.id'
SylvainJuge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,64 @@ | ||
## Log correlation | ||
|
||
Agents should provide instrumentation/hooks for popular logging libraries in order to decorate structured log records with trace context. In particular, logging that occurs within the context of a transaction should add the fields `trace.id` and `transaction.id`; logging that occurs within a span should add the fields `trace.id`, `span.id`, and optionally `transaction.id`. | ||
Agents should provide instrumentation/hooks for popular logging libraries in order to decorate structured log records with trace context. | ||
In particular, logging that occurs within the context of a transaction should add the fields `trace.id` and `transaction.id`; | ||
logging that occurs within a span should add the fields `trace.id` and optionally `transaction.id`. | ||
|
||
By adding trace context to log records, users will be able to move between the APM UI and Logs UI. | ||
|
||
See also the [log-reformatting](log-reformatting.md) spec. | ||
Logging frameworks and libraries may provide a way to inject key-value pairs in log messages, | ||
this allows to reuse those fields in log message formats (for example in plain text). | ||
|
||
Log correlation relies on two sets of fields: | ||
- [metadata fields](#service-correlation-fields) | ||
- They allow to build the per-service logs view in UI. | ||
- They are implicitly provided when using log-sending by the agent metadata. | ||
- When using ECS logging, they might be set by the application. | ||
- [per-log-event fields](#trace-correlation-fields): `trace.id`, `transaction.id` and `error.id` | ||
- They allow to build the per-trace/transaction/error logs view in UI. | ||
- They are added to the log event | ||
- They must be written in each log event document | ||
|
||
The values for those fields can be set in two places: | ||
- when using [ecs-logging](https://github.com/elastic/ecs-logging) directly in the application | ||
- when the agent reformats a log event | ||
|
||
The values set at the application level have higher priority than the values set by agents. | ||
Agents must provide fallback values if they are not explicitly set by the application. | ||
|
||
In case the values set in the application and agent configuration differ, the resulting log | ||
messages won't correlate to the expected service in UI. In order to prevent such inconsistencies | ||
agents may issue a warning when there is a mis-configuration. | ||
|
||
### Service correlation fields | ||
|
||
They allow to build the per-service logs view in UI. | ||
They are implicitly provided when using log-sending by the agent metadata. | ||
When using ECS logging, they might be set by the application in ECS logging configuration. | ||
|
||
- `service.name`: | ||
- used to filter/link log messages to a given service. | ||
- must be provided even if there is no active transaction | ||
- `service.version`: | ||
- only used for service metadata correlation | ||
- must be provided even if there is no active transaction | ||
- `service.environment`: | ||
- allows to filter/link log messages to a given service/environment. | ||
- must be provided even if there is no active transaction | ||
|
||
|
||
The `container.id` field can also be used as a fallback to provide service-level correlation in UI, however agents ARE NOT expected to set it: | ||
|
||
- log collector (filebeat) is expected to do that when ingesting logs. | ||
- all data sent through agent intake implicitly provides `container.id` through metadata, which also includes the log events that may be sent to apm-server. | ||
|
||
### Trace correlation fields | ||
|
||
They allow to build the per-trace/transaction/error logs view in UI. | ||
They allow to navigate from the log event to the trace/transaction/error in UI. | ||
They should be added to the log event. | ||
They must be written in each log event document they relate to, either reformatted or sent by the agent. | ||
|
||
- `trace.id` | ||
- `transaction.id` | ||
- `error.id` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.