简体   繁体   English

Docker Filebeat Nginx 日志

[英]Docker Filebeat Nginx Logs

I m using filebeat as docker and when ı point my nginx logs in filebeat.yml ı m not able to see nginx logs in kibana here is my filebeat.yml.我将 filebeat 用作 docker 并且当我将我的 nginx 登录到 filebeat.yml 时,我看不到 nginx 登录到 kibana 此处是 myfilebeat.yml。 I have elastichsearch and kibana containers ready to go.我已经准备好用于 go 的 elastichsearch 和 kibana 容器。 When I start filebeat container in the logs it says that given log paths are configured.当我在日志中启动 filebeat 容器时,它表示已配置给定的日志路径。 but ı can not visualize any nginx logs on kibana但我无法在 kibana 上看到任何 nginx 日志

  modules:
    path: ${path.config}/modules.d/*.yml
    reload.enabled: false

# filebeat.autodiscover:
#   providers:
#     - type: docker
#       hints.enabled: true

filebeat.autodiscover:
    providers:
      - type: docker
        hints.enabled: true
        templates:
          - condition:
              contains:
                docker.container.image: nginx
            config:
              - type: docker
                containers.ids:
                    - "${data.docker.container.id}"
              - module: nginx
                access:
                  enabled: true
                  var.paths: ["/var/log/nginx/user_service_access.log"]
                  containers:
                      stream: "stdout"
                error:
                  enabled: true
                  var.paths: ["/var/log/nginx/user_service_access.log"]
                  containers:
                      stream: "stderr"
                      
processors:
- add_cloud_metadata: ~

output.elasticsearch:
  hosts: '${ELASTICSEARCH_HOSTS:ip_address:9200}'

and an example of my nginx site conf以及我的 nginx 站点配置示例


    listen 80;
    listen [::]:80;

    # For https
    # listen 443 ssl;
    # listen [::]:443 ssl ipv6only=on;
    # ssl_certificate /etc/nginx/ssl/default.crt;
    # ssl_certificate_key /etc/nginx/ssl/default.key;

    server_name user_service.test;
    root /var/www/user_service/public;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
        proxy_pass http://ip_address:5601;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }

    error_log /var/log/nginx/user_service_error.log;
    access_log /var/log/nginx/user_service_access.log;
}```

Try running the filebeat in debug mode to check for any failures in filebeat configurations.尝试在调试模式下运行 filebeat 以检查 filebeat 配置中的任何故障。 From the filebeat home, try running:从 filebeat 主页,尝试运行:

filebeat -e -c filebeat.yml -d "*"

autodiscovery config for filebeat 7.9.x looks like this it allows for nginx log parsing from container's streams filebeat 7.9.x 的自动发现配置看起来像这样,它允许从容器的流中解析 nginx 日志

filebeat.autodiscover:
  providers:
    - type: docker
      hints.enabled: true
      templates:
        - condition.contains:
            docker.container.image: nginx
          config:
            - module: nginx
              access.input:
                type: docker
                containers:
                  ids: "${data.docker.container.id}"
                  stream: "stdout"
              error.input:
                type: docker
                containers:
                  ids: "${data.docker.container.id}"
                  stream: "stderr"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM