fluent / fluent-logger-python

A structured logger for Fluentd (Python)
http://fluentd.org/
Other
444 stars 138 forks source link

logger.emit() method is not sending the data properly to fluentbit #206

Closed 1999ankitgoyal closed 5 months ago

1999ankitgoyal commented 5 months ago

Docker image used for fluentbit : fluent/fluent-bit:latest. This is fluentbit configuration :

[SERVICE]
    Flush           1
    Daemon          off
    Log_Level       info

[INPUT]
    Name        tcp
    Listen      0.0.0.0
    Port        5140
    Format      json
    Buffer_Size 10240
    Chunk_Size  1024
    Tag         app.*

[OUTPUT]
    Name        stdout
    Match       app.*

Required libraries are already installed. This is python3 code :

import os
import time
import logging
import requests
import socket
import json
import ipaddress 

from logging.handlers import SocketHandler
from pythonjsonlogger import jsonlogger
from fluent import sender, event

fluent_host = '127.0.0.1'
fluent_port = 5140

logger = sender.FluentSender('app', host='127.0.0.1', port=5140)
logger.emit('follow', {"from": "userA", "to": "userB"})

The error I am getting is :

error

But upon running the command from command line terminal, the fluentbit is successfully able to read the message. echo '{"from": "userA", "to": "userB"}' | ncat '127.0.0.1' 5140

Is there some issue with my code or the emit method has some bug ? Could someone please help here. Thank you

methane commented 5 months ago

Use forward, not tcp. https://docs.fluentbit.io/manual/pipeline/inputs/forward