@sanya1995

Почему не отображаются логи в mysql, которые записывает fluentd от nginx в docker?

Подскажите что я неправильно настраиваю. Ошибок нет. Все порты открыты. Контейнеры не падают. Логи nginx в папке /var/log/nginx пишутся.
docker-compose
version: '3'
services:
  nginx:
    build:
      context: nginx
      dockerfile: Dockerfile
    volumes:
      - ./nginx/nginx:/etc/nginx
      - ./nginx/GeoIP:/usr/share/GeoIP
      - ./nginx/logs:/var/log/nginx
    container_name: nginx
    restart: unless-stopped
    ports:
      - 80:80
    links:
      - apache
    depends_on:
      - apache
      - fluentd
    logging:
      driver: fluentd
      options:
        fluentd-address: localhost:24224
        tag: 'docker.nginx'      
    networks:
      - default     
      
  apache:
    build:
      context: apache
      dockerfile: Dockerfile
    volumes:
      - ./html:/var/www/html
      - ./apache/apache:/etc/apache2
      - ./apache/logs:/var/log/apache2
    container_name: apache
    restart: unless-stopped
    networks:
      - default
      
  fluentd:
    build:
      context: fluentd
      dockerfile: Dockerfile
    ports:
      - 24224:24224
      - 24224:24224/udp
    container_name: fluentd
    depends_on:
      - mysql
    networks:
      - default
      
  mysql:
    container_name: mysql
    restart: unless-stopped
    build:
      context: mysql
      dockerfile: Dockerfile
    environment:
      MYSQL_DATABASE: fluentd
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: admin
      MYSQL_PASSWORD: admin
    ports:
      - 3306:3306
    networks:
      - default


networks:
  default:
      driver: bridge

nginx.conf
user  nginx;
worker_processes  auto;
error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;
load_module modules/ngx_http_geoip_module.so;
events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    geoip_country  /usr/share/GeoIP/GeoIP.dat;
    geoip_city     /usr/share/GeoIP/GeoIPCity.dat;
    log_format  main escape=json '{ "timestamp": "$time_iso8601", ' 
                                 '"remote_addr": "$remote_addr", '
                                 '"remote_user": "$remote_user", ' 
                                 '"time_local": "$time_local", ' 
                                 '"request": "$request", '
                                 '"status": "$status", '
                                 '"body_bytes_sent": "$body_bytes_sent", '
                                 '"http_referer": "$http_referer", '
                                 '"http_user_agent": "$http_user_agent", ' 
                                 '"request_time": "$request_time", '
                                 '"upstream_connect_time": "$upstream_connect_time", '
                                 '"upstream_header_time": "$upstream_header_time", '
                                 '"upstream_response_time": "$upstream_response_time", '
                                 '"geoip_country_code": "$geoip_country_code" }';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;
    include /etc/nginx/conf.d/*.conf;
}

default.conf
server {
    listen       80;
    server_name  first.ru;
    location / {
        proxy_pass  'http://apache:81';
    }
}
server {
    listen       80;
    server_name  second.ru;
    location / {
        proxy_pass  'http://apache:82';
    }
}

fluentd.conf
<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>
<match docker.**>
  @type mysql_bulk
  host mysql
  database fluentd
  username admin
  password admin
  column_names timestamp,remote_addr,time_local,request,status,body_bytes_sent,http_referer,http_user_agent,request_time,upstream_connect_time,upstream_header_time,upstream_response_time,geoip_country_code
  table fluentd_logs
  flush_interval 1s
</match>
<match *.*>
  @type stdout
</match>

таблица sql
USE fluentd;
CREATE TABLE fluentd_logs(
  id bigint primary key auto_increment, 
  timestamp nvarchar(1000),
  remote_addr nvarchar(1000),
  remote_user nvarchar(1000),
  time_local nvarchar(1000),
  request nvarchar(1000),
  status nvarchar(1000),
  body_bytes_sent nvarchar(1000),
  http_referer nvarchar(1000),
  http_user_agent nvarchar(1000),
  request_time nvarchar(1000),
  upstream_connect_time nvarchar(1000),
  upstream_header_time nvarchar(1000),
  upstream_response_time nvarchar(1000),
  geoip_country_code nvarchar(1000)
);
  • Вопрос задан
  • 86 просмотров
Пригласить эксперта
Ответы на вопрос 1
@q2digger
никого не трогаю, починяю примус
Потому что например вот тут ошибка
logging:
      driver: fluentd
      options:
        fluentd-address: localhost:24224
        tag: 'docker.nginx'

никакого локалхоста там быть не должно
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы