Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Python to send Fluentd event record

Shulou Source: shulou.com Published: 2022-06-02 07:03:09 10月04日 Update

This article introduces the knowledge of "how to use Python to send Fluentd event record". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Json is used as the event carrier inside Fluentd. If you want to send data directly to Fluentd, you can use the Fluentd client program to do so.

Fluentd officially provides many language implementations of client programs, including: Java, Ruby, Python, Perl, PHP, Nodejs, Scala. This article briefly introduces the use of the Python client.

Fluent-logger-python is the Fluentd client implemented by Python, which can send record to Fluentd from the application.

Use requirements

Python 2.7 or 3.4 +

Msgpack-python

Fluentd configuration

Fluentd needs to use the forward input plug-in to receive client data.

@ type forward port 24224 @ type stdout

Usage

Installation

Pip install fluent-logger

Sample code

# test.pyfrom fluent import senderfrom fluent import eventsender.setup ('fluentd.test', host='localhost', port=24224) event.Event (' follow', {'from':' userA', 'to':' userB'})

It's relatively simple.

Configure the tag and Fluentd server address of the event through sender, and create and send the event through event.

That's all for "how to use Python to send Fluentd event record". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Events customers clients programs content data more knowledge configuration practicality learning and then code usage dilemma address official actually that is the application Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Microsoft Shulou Tech Info Huawei