Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to send Fluentd event record

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report