-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] Including hostname in json logs drops kube_cluster_name tag #14860
Comments
Hi @ryanartecona, thanks for using Datadog. This issue queue is primarily intended for tracking features, bugs and work items associated with the datadog-agent open source project. For your request, please contact our support. |
I confirm this bug. It drops all tags added by the kubernetes datadog agent when the @ryanartecona did you get any reply from the support ? |
After contacting the support, here is the explanation. As described here, by default Therefore the hostname attribute won't have the same value as expected. And this has the consequence of dropping all host related tags because tags are coupled with the hostname, as further explained by the support (screenshot of the complete answer below) (tags are associated to hostname and not sent with logs every time for performance reason, therefore this drop effect happens when the hostname attribute is overriden on logs with a value that does not match the real host where Datadog agents are running on. How to resolve that: get rid of the hostname attribute coming from your json logs, or pass the real host value to a HOSTNAME environment variable to your container to get the correct one. |
- Bunyan, when writing logs in json, always include `hostname` as a field - Bunyan takes the value for that field from the os (you can check it either in `HOSTNAME` env variable, or running the `hostname` command) - On kubernetes hostname in a container resolves to the pod name - Datadog, when receiving logs, tries to match `hostname` field to a name of any host it knows about. If `hostname` field isn't present in logs, it tries to derive it from a kubernetes node, which these logs came from - When `hostname` in logs doesn't match any of the hosts Datadog knows about, Datadog won't assign any extra tags, which those hosts already have - This was creating a problem, when we assigned tags such as `account:crowd` and `cluster_name:crowd-kube-production` to nodes, which weren't propagating to logs coming from these nodes - Without this tag propagation it's impossible to tell which kubernetes cluster the logs came from - To fix that, we just make Bunyan to stop populating `hostname` field in json logs, allowing Datadog to do its magic Similar issue here: DataDog/datadog-agent#14860
- Bunyan, when writing logs in json, always includes `hostname` as a field - Bunyan takes the value for that field from the os (you can check it either in `HOSTNAME` env variable, or running the `hostname` command) - On kubernetes hostname in a container resolves to the pod name - Datadog, when receiving logs, tries to match `hostname` field to a name of any host it knows about. If `hostname` field isn't present in logs, it tries to derive it from a kubernetes node, which these logs came from - When `hostname` in logs doesn't match any of the hosts Datadog knows about, Datadog won't assign any extra tags, which those hosts already have - This was creating a problem, when we assigned tags such as `account:crowd` and `cluster_name:crowd-kube-production` to nodes, which weren't propagating to logs coming from these nodes - Without this tag propagation it's impossible to tell which kubernetes cluster the logs came from - To fix that, we just make Bunyan to stop populating `hostname` field in json logs, allowing Datadog to do its magic Similar issue here: DataDog/datadog-agent#14860
Agent Environment
Running the agent as a k8s daemonset via the helm chart using mostly default values. Logs are enabled with
container_collect_all: true
.Describe what happened:
I have an app printing json logs that are collected by the agent. If a log line includes
hostname
as a top level key in the json object, that value will override what datadog shows in theHost
field for that line, causing it to lose association with the server host the log came from. Also,kube_cluster_name
will not be added as a tag to that log line. This is a similar problem to the one in #14099.Describe what you expected:
Normal log lines behave as expected. Specifically, if a log line does not include
hostname
in the json, datadog will show it as coming from the correct server and will showkube_cluster_name
tag which is automatically added by the agent.Steps to reproduce the issue:
container_collect_all: true
.Additional environment details (Operating System, Cloud provider, etc):
The text was updated successfully, but these errors were encountered: