hedii / laravel-gelf-logger

A package to send gelf logs to a gelf compatible backend like graylog
MIT License
125 stars 33 forks source link

Can't Receive messages on Graylog #44

Closed faelwar closed 1 year ago

faelwar commented 1 year ago

I'm unable to receive any message from Laravel on Graylog and I don't know what is happening. Here is my config

logging.php

'stack' => [
            'driver' => 'stack',
            'channels' => ['gelf', 'stderr', 'daily'],
            'ignore_exceptions' => false,
        ],
'gelf' => [
            'driver' => 'custom',

            'via' => \Hedii\LaravelGelfLogger\GelfLoggerFactory::class,

            // This optional option determines the processors that should be
            // pushed to the handler. This option is useful to modify a field
            // in the log context (see NullStringProcessor), or to add extra
            // data. Each processor must be a callable or an object with an
            // __invoke method: see monolog documentation about processors.
            // Default is an empty array.
            'processors' => [
                \Hedii\LaravelGelfLogger\Processors\NullStringProcessor::class,
                \Hedii\LaravelGelfLogger\Processors\RenameIdFieldProcessor::class,
                // another processor...
            ],

            // This optional option determines the minimum "level" a message
            // must be in order to be logged by the channel. Default is 'debug'
            'level' => 'debug',

            // This optional option determines the channel name sent with the
            // message in the 'facility' field. Default is equal to app.env
            // configuration value
            'name' => 'my-custom-name',

            // This optional option determines the system name sent with the
            // message in the 'source' field. When forgotten or set to null,
            // the current hostname is used.
            'system_name' => null,

            // This optional option determines if you want the UDP, TCP or HTTP
            // transport for the gelf log messages. Default is UDP
            'transport' => 'udp',

            // This optional option determines the host that will receive the
            // gelf log messages. Default is 127.0.0.1
            'host' => 'graylog',

            // This optional option determines the port on which the gelf
            // receiver host is listening. Default is 12201
            'port' => 12111,

            // This optional option determines the path used for the HTTP
            // transport. When forgotten or set to null, default path '/gelf'
            // is used.
            'path' => null,

            // This optional option enable or disable ssl on TCP or HTTP
            // transports. Default is false.
            'ssl' => false,

            // If ssl is enabled, the following configuration is used.
            'ssl_options' => [
                // Enable or disable the peer certificate check. Default is
                // true.
                'verify_peer' => true,

                // Path to a custom CA file (eg: "/path/to/ca.pem"). Default
                // is null.
                'ca_file' => null,

                // List of ciphers the SSL layer may use, formatted as
                // specified in ciphers(1). Default is null.
                'ciphers' => null,

                // Whether self-signed certificates are allowed. Default is
                // false.
                'allow_self_signed' => false,
            ],

            // This optional option determines the maximum length per message
            // field. When forgotten or set to null, the default value of 
            // \Monolog\Formatter\GelfMessageFormatter::DEFAULT_MAX_LENGTH is
            // used (currently this value is 32766)
            'max_length' => null,

            // This optional option determines the prefix for 'context' fields
            // from the Monolog record. Default is null (no context prefix)
            'context_prefix' => null,

            // This optional option determines the prefix for 'extra' fields
            // from the Monolog record. Default is null (no extra prefix)
            'extra_prefix' => null,

            // This optional option determines whether errors thrown during
            // logging should be ignored or not. Default is true.
            'ignore_error' => true,

        ],

docker-compose.yml

version: '2'

services:
  redis:
    image: redis:7
    command: redis-server --requirepass
    hostname: redis
    ports:
      - '6379:6379'
  local:
    tty: true
    image: docker.io/bitnami/laravel:9
    environment:
      - DB_HOST=db-app
      - DB_USERNAME=${DB_USERNAME}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_DATABASE=${DB_DATABASE}
      - APP_NAME=Laravel
      - APP_ENV=local
      - APP_KEY=base64:
      - APP_DEBUG=true
      - APP_URL=http://localhost
      - SERVER_PORT=3000
      - LOG_CHANNEL=stack
      - LOG_LEVEL=debug
      - DB_CONNECTION=mysql
      - BROADCAST_DRIVER=log
      - CACHE_DRIVER=none
      - FILESYSTEM_DISK=local
      - SESSION_DRIVER=file
      - SESSION_LIFETIME=120
      - MEMCACHED_HOST=127.0.0.1
      - REDIS_CLIENT=predis
      - REDIS_HOST=redis
      - REDIS_PASSWORD=
      - REDIS_PORT=6379
      - SES_KEY="{AWS_ACCESS_KEY_ID}"
      - SES_SECRET="{AWS_SECRET_ACCESS_KEY}"
      - SES_REGION=us-east-1
      - MAIL_ENCRYPTION=tls
      - MAIL_FROM_ADDRESS=
      - MAIL_FROM_NAME="${APP_NAME}"
      - AWS_ACCESS_KEY_ID="{AWS_ACCESS_KEY_ID}"
      - AWS_SECRET_ACCESS_KEY="{AWS_SECRET_ACCESS_KEY}"
      - AWS_DEFAULT_REGION=us-east-1
      - AWS_BUCKET=
      - AWS_USE_PATH_STYLE_ENDPOINT=true
      - PUSHER_APP_ID=
      - PUSHER_APP_KEY=
      - PUSHER_APP_SECRET=
      - PUSHER_APP_CLUSTER=mt1
      - MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
      - MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
      - BITNAMI_DEBUG=true
      - CONTAINER_ROLE=app
      - QUEUE_CONNECTION=sync
      - MONOPOLY_API_URL="${MONOPOLY_API_URL}"
      - MONOPOLY_API_KEY="${MONOPOLY_API_KEY}"
      - MONOPOLY_API_DEBUG=true
    ports:
      - 1230:8000
    volumes:
      - ./:/app
    depends_on:
      - redis
      - db-app
  db-app:
    image: 'mysql'
    ports:
      - '3306:3306'
    volumes:
      - '../dbentrypoint:/docker-entrypoint-initdb.d'
      - '../databasedump:/var/lib/mysql'
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_DATABASE=
  mongodb:
    image: mongo:4.2
    volumes:
      - mongo_data:/data/db
    restart: unless-stopped

  elasticsearch: # ElasticSearch service
    restart: unless-stopped
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2 # Version of elasticsearch image
    volumes:
      - es_data:/usr/share/elasticsearch/data # Persisted elasticsearch data
    environment:
      - http.host=0.0.0.0
      - transport.host=localhost
      - network.host=0.0.0.0
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 1g

  graylog:
    image: graylog/graylog:4.2 # Version of Graylog docker image
    volumes:
      - graylog_data:/usr/share/graylog/data # Persisted Graylog data
    environment:
      - GRAYLOG_PASSWORD_SECRET=segredonaotaosecreto
      # Password: admin
      - GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
      - GRAYLOG_HTTP_EXTERNAL_URI=http://127.0.0.1:9000/
      - GRAYLOG_WEB_ENDPOINT_URI=http://127.0.0.1:9000/api
    entrypoint: /usr/bin/tini -- wait-for-it elasticsearch:9200 --  /docker-entrypoint.sh
    links:
      - mongodb:mongo
      - elasticsearch
    restart: unless-stopped
    depends_on:
      - mongodb
      - elasticsearch
    ports:
      - "9000:9000"
      # Syslog TCP
      - "1514:1514"
      # Syslog UDP
      - "1514:1514/udp"
      # GELF TCP
      - "12201:12201"
      # GELF UDP
      - "12111:12111/udp"

volumes:
  mongo_data:
  es_data:
  graylog_data:

Any help on what I did wrong?

hedii commented 1 year ago

No idea, also i don't know nothing about docker...