Namespace MDC Fields with either labels or tags.
See original GitHub issueI noticed when I was working with the ECS Java loggers that MDC and/or Metadata fields weren’t name spaced.
I can see one of three scenario’s:
- Make the default namespace be
labels
per [https://www.elastic.co/guide/en/ecs/current/ecs-base.html](Base Fields) - Make the default namespace be
tags
per [https://www.elastic.co/guide/en/ecs/current/ecs-base.html](Base Fields) - Allow for a customized namespace via a configuration parameter.
Here’s an example configuration:
<configuration>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="co.elastic.logging.logback.EcsEncoder">
<serviceName>my-application</serviceName>
<serviceNodeName>my-application-cluster-node</serviceNodeName>
<additionalField>
<key>environment</key>
<value>dev</value>
</additionalField>
</encoder>
</appender>
<logger name="co.elastic" level="DEBUG"/>
<root level="WARN">
<appender-ref ref="Console"/>
</root>
</configuration>
and a resulting output:
{
"@timestamp": "2021-08-31T15:57:11.355Z",
"log.level": "DEBUG",
"message": "Example with the default Meta Data fields.",
"ecs.version": "1.2.0",
"service.name": "my-application",
"service.node.name": "my-application-cluster-node",
"event.dataset": "my-application.log",
"process.thread.name": "main",
"log.logger": "co.elastic.DemoApplication",
"environment": "dev"
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:18 (4 by maintainers)
Top Results From Across the Web
Better default mappings for logs · Issue #88777
Ingestion and disk overhead because all fields are indexed by default, ... Namespace MDC Fields with either labels or tags. elastic/ecs-logging-java#142.
Read more >Modular Datacenter (MDC) network introduction
DNS labels are a convenient way for users to reach apps and services hosted in MDC by name. The DNS name label uses...
Read more >Migrating to Material Components for Android
Before you can use MDC, you need to migrate from the Support Library to Android Jetpack. Jetpack uses the new androidx.* namespace and ......
Read more >Java Logging with Mapped Diagnostic Context (MDC)
In this tutorial, we will explore the use of Mapped Diagnostic Context (MDC) to improve the application logging. Mapped Diagnostic Context ...
Read more >Changing the XMP Configuration
The Metadata Configuration (MDC) is used to manage how XMP metadata fields ... Add a field by right-clicking on either a namespace or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was going to make a similar comment that MDC is often used contextual fields that span across all methods within a given flow. For example, if you use distributed tracing that’s something that needs to be present in all log records and the only way to do so is via MDC unless you want to pass that as a direct parameter to all methods.
We, too, are sad to see that MDC values are not namespaced under
labels
anymore. I would even go as far to say that #67 was a very bad change, or at the very least a shortsighted one.labels.
ortags.
to have the values correctly put into the ECS. This makes no sense at all to me. Our developers don’t even know that their applications are logging in the ECS format. This only happens in production where the logging configuration is injected as external configuration by the DevOps team (aka, me). There is just no way I can reliably nudge all our developers to always prefix all their MDC keys withlabels.
(nor do I want to, because the applications shouldn’t be developed against a specific logging format).For the stated reasons, please at least provide an option to restore the previous behavior by making the namespace (and by “namespace” i mean “common key prefix”) for MDC values configurable using the
logback.xml
file.