我如何覆盖“来源”在运行Docker容器时,在Datadog中?
我有一个docker-compose文件,其中我运行了几个容器,包括datadog代理。 一切正常,除了DataDog在将容器日志发送到DataDog时选择的“源”。
例如,如果我使用官方的nginx映像,则由于docker映像称为“ nginx”,默认情况下,datadog源被选为“ nginx”,使用nginx datadog管道来解析日志。
但是,如果我使用的是称为“ my-account/hello-world”的docker映像,则默认情况下,datadog将源选择为“ hello-world”。如果我的图像受NGINX的启发,并以“ nginx格式”报告日志,我希望能够将DataDog源更改为“ nginx”,因此dataDog默认情况下可以拾取Nginx Logs Pipeline。
我该如何实现?
我试图设置DD_Source环境变量,但没有运气,Datadog仍将图像名称选择为“源”。我还尝试将源设置为标签(dd_tags = source:nginx),但是dataDog不会捡起它。
谢谢!
I have a docker-compose file where I run several containers, including DataDog agent.
Everything is working fine, except the "source" that DataDog picks when sending container logs to DataDog.
There, for example, if I use the official Nginx image, since the docker image is called "nginx", the datadog source is picked by default as "nginx", using the Nginx DataDog pipelines to parse the logs.
But, if I am using a docker image called "my-account/hello-world", then the DataDog picks by default the source as "hello-world". If my image is inspired by Nginx, and reporting the logs in an "nginx format", I would like to be able to change the DataDog source to "nginx", so DataDog can pick up by default the Nginx logs pipeline.
How can I achieve this?
I have tried to set up a DD_SOURCE environment variable, but no luck, DataDog is still picking the image name as "source". I have tried also to set up the source as tag (DD_TAGS=source:nginx), but DataDog does not pick it up.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个特定于Kubernetes的答案...
我有一个类似的问题,我终于解决了。我认为您也可以将此解决方案适应您的案件。
nginx
我正在使用 nginx-ingress-ingress-controller 。两者都由Datadog支持。文档指出,您应该在k8s清单文件中使用此格式:
自 nginx-ingress-controller 默认为容器名称
Controller
我将其用作< container_identifier>
:我的工作最终配置,包括
&lt ; log_config>
并使用部署
而不是pod
更现实,看起来像这样:值得注意的是,没有数组括号<代码> [] 在日志配置周围,日志根本根本不会摄入。
datadog现在自动知道如何解析日志(在之前说
Controller
):< img src =“ https://i.sstatic.net/srykm.png” alt =“ datadog解析日志正确”>
A kubernetes-specific answer...
I had a similar problem which I finally solved. I think you can adapt this solution to your case, too.
nginx
I am using the nginx-ingress-controller. Both are supported by Datadog.The docs state that you should use this format in the k8s manifest file:
Since nginx-ingress-controller defaults to the container name
controller
I used that as<CONTAINER_IDENTIFIER>
:My working final configuration including the
<LOG_CONFIG>
and using aDeployment
instead of aPod
, to be more realistic, looks like this:It might be worth noting that without the array braces
[]
around the log config, logs will simply not be ingested at all.Datadog now automatically knows how to parse the logs (it said
controller
before):另一种方法是在Docker-Compose服务上设置以下标签:
Another way is to set the following label on docker-compose services: