python添加fluent日志记录
istio默认会进行日志的记录,但是仅仅记录到服务、以及服务之间调用的信息,不记录业务日志。
如:

所以需要添加业务日志记录。
1.python引入package
fluent
msgpack
2.代码中引入相关类,并连接fluent服务
1)Event-Based Interface 发送fluent日志 是对FluentSender的包装
from fluent import sender, event
logger = sender.FluentSender('fluent-python', host='192.168.181.99', port=30224)
对应方法中添加日志记录

2)Python logging.Handler interface 定义日志格式 发送fluent日志
import msgpack
from io import BytesIO
import logging
from fluent import handler
def overflow_handler(pendings):
unpacker = msgpack.Unpacker(BytesIO(pendings))
for unpacked in unpacker:
print(unpacked)
custom_format = {
'host': '%(hostname)s',
'where': '%(module)s.%(funcName)s',
'type': '%(levelname)s',
'stack_trace': '%(exc_text)s'
}
logging.basicConfig(level=logging.INFO)
l = logging.getLogger('fluent.test')
#remote fluent服务
#
h = handler.FluentHandler('fluent-python.log',
host='fluentd-es.logging', port=24224,
buffer_overflow_handler=overflow_handler)
# 本地调用fluent服务
h = handler.FluentHandler('fluent-python.log', host='192.168.181.99', port=30224, buffer_overflow_handler=overflow_handler)
formatter = handler.FluentRecordFormatter(custom_format)
h.setFormatter(formatter)
l.addHandler(h)
对应方法中添加日志记录

3.fluent ui 展现情况
1)event记录日志

2)自定义日志格式

4.事例项目
istio事例项目(jeager-fluent分支)
https://github.com/jiuchongxiao/istio-python-hello-jaeger.git
没加istio事例项目
https://github.com/jiuchongxiao/python-fluent-example.git
python添加fluent日志记录的更多相关文章
- python添加fluent日志记录-aop
python添加fluent日志,aop实现 1.配置fluent相关信息 fluent_config.ini fluent_config.ini [fluent.aop] #is support f ...
- springboot添加fluent日志记录
istio默认会进行日志的记录,但是仅仅记录到服务.以及服务之间调用的信息,不记录业务日志. 如: 所以需要添加业务日志记录. 1.引入依赖 <dependency> <gr ...
- Python开发之日志记录模块:logging
1 引言 最近在开发一个应用软件,为方便调试和后期维护,在代码中添加了日志,用的是Python内置的logging模块,看了许多博主的博文,颇有所得.不得不说,有许多博主大牛总结得确实很好.似乎我再写 ...
- spring/spirng boot添加fluent日志-aop
此项目以aop的形式添加fluent 日志 sample介绍 spring-mvc-aop-helloworld 为spring mvc aop condition toolcommontest 为s ...
- .NET Worker Service 添加 Serilog 日志记录
前面我们了解了 .NET Worker Service 的入门知识[1] 和 如何优雅退出 Worker Service [2],今天我们接着介绍一下如何为 Worker Service 添加 Ser ...
- Yii2如何添加sql日志记录的配置信息
在使用Yii2框架的时候,常常会出现没有sql日志记录的问题.在代码里一句一句的打印sql语句也不现实.所以就要用文件记录起来. 在 config/web.php 里面的 log配置中增加如下配置 [ ...
- Python中的日志记录方案-logging模块&loguru模块
原文链接 原创: 崔庆才 在 Python 中,一般情况下我们可能直接用自带的 logging 模块来记录日志,包括我之前的时候也是一样.在使用时我们需要配置一些 Handler.Formatter ...
- .net 项目如何添加log4net日志记录
1.在项目根目录新建文件log4net.config,此文件中的节点解释还请自动百度. 文件实例: <?xml version="1.0"?><configura ...
- python工具之日志记录
''' 写日志类 日志存放目录为当前应用程序的目录下的log目录中 日志产生规则:每小时产生一个文件 write by :wujf 2017-02-24 ''' import sys import o ...
随机推荐
- 18.struts-执行流程.md
目录 1.流程 2.bean节点 3.package节点 result-type 拦截器 概念 拦截器和过滤器的异同: 问题:拦截器什么时候执行,action类和拦截器的执行顺序 4.常见问题 1.流 ...
- android资讯类软件框架《IT蓝豹》
android资讯类软件框架 android资讯类软件框架,支持侧滑,并且首页viewpager切换tab,tab滑动到最右侧的时候提示滑动结束, 滑动到最左侧的时候切换滑动侧滑menu.左滑和侧滑处 ...
- 学JS的心路历程-Promise(一)
今天在进入Promise代码之前,我们先来用个例子来解释Promise是什么. 未来值 假设我们今天来到快餐店,点了一个汉堡,付钱给店员. 点了餐点并付费,可以理解为我们发送了一个请求,希望得到一个回 ...
- jquery 获取表单的用户输入值的方法
以前的表单中的select input textarea的用户选择输入是通过jQuery的val()方法获取到的,在三一Java前端大拿教我了一个方法可以不用那么麻烦获取数据,只要在这些表单元素上加n ...
- kafka 消费者 timeout 6000
kafka 消费者 timeout 6000 1:查看zookeeper 的状态,kafka默认是自带zookeeper配置,我建议安装单独的zookeeper 服务,并且配置文件也很简单..直接改 ...
- multi_compile
[multi_compile] Used to compile the shader code multiple times with different preprocessor directi ...
- 创建java项目思路
一.搭建 1.创建搭建项目 2.创建分层 二.理解项目(理清总体思路) 1.是否有共同部分(过滤或者拦截) 常用量 (static) 2.搭建单表基本增(是否需要返回值) 删(条件) 查(条 ...
- C library:<cctype>(ctype.h)
1, isalnum(): check whether c is either a decimal digit or an uppercase or lowercase letter. 2, isal ...
- 二进制中1的个数(python)
题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. # -*- coding:utf-8 -*- class Solution: def NumberOf1(self, n): ...
- pta l2-18(多项式A除以B)
题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805060372905984 题意:给定两个多项式,求出其做除法 ...