如何在google日志记录中使用日志文件名作为日志名。
我在google云操作系统代理/config.yaml上有这个
logging:
receivers:
nginx_access:
type: nginx_access
nginx_error:
type: nginx_error
nginx_access_files:
type: files
include_paths: [/var/log/nginx/*access*.log]
service:
pipelines:
nginx:
receivers:
- nginx_access
- nginx_error
- nginx_access_files
metrics:
receivers:
nginx:
type: nginx
stub_status_url: http://127.0.0.1:80/status
service:
pipelines:
nginx:
receivers:
- nginx
问题是,文件夹/var/log/nginx/access.log .log中的所有日志都显示在google上作为一个实体"nginx_access_files“。该文件夹有数百个具有站点名称的访问日志。我也希望在日志控制台上将该日志文件名作为日志名称。
我现在在Google日志控制台上看到了这一点:
我需要设置它,以便文件名在日志控制台上显示。与默认情况一样,Nginx错误也适用于OPS代理。或者是否有另一种方式将所有访问日志路由到带有文件名的google日志记录?
发布于 2022-05-31 16:05:23
不需要配置nginx_access_files
接收器,如果您使用access.log文件的默认路径,则代理会自动提取日志并将它们发送到云日志记录。
代理yaml文件应该如下所示:
logging:
receivers:
nginx_access:
type: nginx_access
nginx_error:
type: nginx_error
service:
pipelines:
nginx:
receivers:
- nginx_access
- nginx_error
metrics:
receivers:
nginx:
type: nginx
stub_status_url: http://127.0.0.1:80/status
service:
pipelines:
nginx:
receivers:
- nginx
在nginx_access
日志名称下,您将看到生成的所有访问日志,因为它们是以实例名称作为标签生成的,因此可以使用它来筛选它们:
如果您的access.log文件不在默认路径中,那么您可以指定它在哪里,但是不需要为此创建一个新的接收器,下面是一个示例:
logging:
receivers:
nginx_access:
type: nginx_access
include_paths: [/your/log/path/access.log]
nginx_error:
type: nginx_error
service:
pipelines:
nginx:
receivers:
- nginx_access
- nginx_error
metrics:
receivers:
nginx:
type: nginx
stub_status_url: http://127.0.0.1:80/status
service:
pipelines:
nginx:
receivers:
- nginx
最后,我建议您看看NGINX云日志记录集成教程。
https://stackoverflow.com/questions/72435159
复制相似问题