Haproxy日志分析器,旨在提供对正在发生什么的洞察
项目描述
HAProxy日志分析器
此Python包是HAProxy日志解析器。它以多种方式分析HAProxy日志文件(见下面的命令部分)。
测试和覆盖率
没有测试和良好覆盖率的项目的可信度不高!
文档
请参阅文档和API,位于ReadTheDocs。
命令行界面
当前的--help看起来像这样
usage: haproxy_log_analysis [-h] [-l LOG] [-s START] [-d DELTA] [-c COMMAND] [-f FILTER] [-n] [--list-commands] [--list-filters] [--json] Analyze HAProxy log files and outputs statistics about it optional arguments: -h, --help show this help message and exit -l LOG, --log LOG HAProxy log file to analyze -s START, --start START Process log entries starting at this time, in HAProxy date format (e.g. 11/Dec/2013 or 11/Dec/2013:19:31:41). At least provide the day/month/year. Values not specified will use their base value (e.g. 00 for hour). Use in conjunction with -d to limit the number of entries to process. -d DELTA, --delta DELTA Limit the number of entries to process. Express the time delta as a number and a time unit, e.g.: 1s, 10m, 3h or 4d (for 1 second, 10 minutes, 3 hours or 4 days). Use in conjunction with -s to only analyze certain time delta. If no start time is given, the time on the first line will be used instead. -c COMMAND, --command COMMAND List of commands, comma separated, to run on the log file. See --list-commands to get a full list of them. -f FILTER, --filter FILTER List of filters to apply on the log file. Passed as comma separated and parameters within square brackets, e.g ip[192.168.1.1],ssl,path[/some/path]. See --list- filters to get a full list of them. -n, --negate-filter Make filters passed with -f work the other way around, i.e. if the ``ssl`` filter is passed instead of showing only ssl requests it will show non-ssl traffic. If the ``ip`` filter is used, then all but that ip passed to the filter will be used. --list-commands Lists all commands available. --list-filters Lists all filters available. --json Output results in json. --invalid Print the lines that could not be parsed. Be aware that mixing it with the print command will mix their output.
命令
命令是本身具有特定目的的小程序,可以报告正在分析的日志文件的具体统计数据。使用--list-commands查看所有命令或在线查看https://haproxy-log-analyzer.readthedocs.io/modules.html#module-haproxy.commands。
average_response_time
average_waiting_time
connection_type
counter
http_methods
ip_counter
print
queue_peaks
request_path_counter
每小时请求数
每分钟请求数
服务器负载
慢速请求
慢速请求计数器
状态码计数器
顶级IP
顶级请求路径
过滤器
与命令相反,过滤器是一种减少需要处理的日志行数的方法。
使用 --list-filters 或在线查看 https://haproxy-log-analyzer.readthedocs.io/modules.html#module-haproxy.filters。
后端
前端
HTTP方法
IP
IP范围
路径
响应大小
服务器
慢速请求
SSL
状态码
状态码类别
等待队列
安装
安装后,您将有一个控制台脚本 haproxy_log_analysis。
$ pip install haproxy_log_analysis
待办事项
添加更多命令:(欢迎帮助)
关于服务器连接时间的报告
关于终止状态的报告
关于连接的报告(活动、前端、后端、服务器)
您的想法
考虑一种方式来以有意义的方式显示命令输出
能够指定输出格式。对于任何有意义的命令(例如慢速请求),为每行日志输出给定的字段(例如接受日期、路径、下游服务器、当时负载等)
您的想法
变更记录
5.1.0 (2022-12-03)
只从 X-Forwarded-For 标头获取第一个IP。 [gforcada]
提高测试的鲁棒性。 [gforcada]
修复 top_ips 和 top_request_paths 命令的输出。它们显示所有输出,而不是仅显示前10个。 [gforcada]
将 tests 文件夹移动到顶级。 [gforcada]
5.0.0 (2022-11-27)
停止在 travis-ci 上进行测试。 [gforcada]
使用 GitHub Actions。 [gforcada]
使用 pyupgrade、black 和 isort 格式化代码。 [gforcada]
使用 pip-tools 来锁定依赖项。 [gforcada]
将支持的 Python 版本提升到 3.7-3.11 和 pypy。 [gforcada]
停止支持 Python 3.6(已停止服务)。 [gforcada]
4.1.0 (2020-01-06)
新命令: requests_per_hour。就像 requests_per_minute 一样,但以小时粒度。由 valleedelisle 提出想法并完成首次实现。 [gforcada]
修复解析截断请求。由 vixns 提出想法并完成首次实现。 [gforcada]
4.0.0 (2020-01-06)
重大变更
完全重写,即使对大文件,几乎不使用内存。 [gforcada]
添加并行化以通过并行解析多行来加快解析速度。 [gforcada]
将命令 counter_slow_requests 重命名为 slow_requests_counter,使其与其他所有 _counter 命令保持一致。 [gforcada]
将 counter_invalid 命令更改为新的命令行开关 --invalid。 [gforcada]
常规更改
停止支持 Python 2,并在 Python 3.8 上进行测试。 [gforcada]
移除序列化支持。 [gforcada]
添加 –json 输出命令行选项。 [valleedelisle]
3.0.0 (2019-06-10)
修复拼写错误。 [EdwardBetts]
让 ip_counter 默认使用 client_ip。 [vixns]
彻底改造测试环境。在 Python 3.7 上也进行测试。使用 black 进行格式化。 [gforcada]
2.1 (2017-07-06)
在代码上执行 QA 检查(flake8)。所有代码都已更新以遵循它。 [gforcada]
支持 Python 3.6。 [gforcada]
支持不同的 syslogs 时间戳(至少 NixOS)。 [gforcada]
2.0.2 (2016-11-17)
提高 cmd_print 的性能。 [kevinjqiu]
2.0.1 (2016-10-29)
允许主机名中包含点。 [gforcada]
2.0 (2016-07-06)
处理不可解析的 HTTP 请求。 [gforcada]
仅在 python 2.7 和 3.5 上进行测试。 [gforcada]
2.0b0 (2016-04-18)
在执行除法之前检查除数,以避免出现 ZeroDivisionError 异常。 [gforcada]
2.0a0 (2016-03-29)
主要重构
# 重命名模块和类
haproxy_logline -> line
haproxy_logfile -> logfile
HaproxyLogLine -> Line
HaproxyLogFile -> Log
# 在创建 Log() 时解析日志文件(即在 __init__ 中)
[gforcada]
1.3 (2016-03-29)
新过滤器:filter_wait_on_queues。获取在 HAProxy 队列中等待最长时间为 X 毫秒的所有请求。[gforcada]
代码/文档清理和添加代码分析。[gforcada]
避免使用 eval。[gforcada]
1.2.1 (2016-02-23)
支持 -1 作为状态码 [Christopher Baines]
1.2 (2015-12-07)
允许在 syslog 部分使用主机名(不仅仅是 IP 地址)[danny crasto]
1.1 (2015-04-19)
使 syslog 可选。修复问题 https://github.com/gforcada/haproxy_log_analysis/issues/10。[gforcada]
1.0 (2015-03-24)
修复问题 #9。syslog 部分的日志行过于严格,它期望主机名是字符串,如果是 IP 则失败。[gforcada]
0.0.3.post2 (2015-01-05)
最终真正修复了问题 #7。《namespace_packages》根本不应该出现在 setup.py 中。愚蠢的复制粘贴错误。[gforcada]
0.0.3.post (2015-01-04)
修复 PyPI 上的发布。解决 GitHub 问题 #7。https://github.com/gforcada/haproxy_log_analysis/issues/7 [gforcada]
0.0.3 (2014-07-09)
再次修复 PyPI 上的发布。[gforcada]
0.0.2 (2014-07-09)
修复 PyPI 上的发布。[gforcada]
0.0.1 (2014-07-09)
Pickle :class::.HaproxyLogFile 数据以获得更快的性能。[gforcada]
添加一种方法来否定过滤器,这样就可以输出除了 IP 以外的所有信息,而不仅仅是 IP 信息。[gforcada]
添加许多过滤器:ip、path、ssl、backend、frontend、server、status_code 等。有关完整列表,请参阅 --list-filters。[gforcada]
添加 :method::.HaproxyLogFile.parse_data 方法以从数据流中获取数据。它允许您将其用作库。[bogdangi]
在命令行界面添加 --list-filters 参数。[gforcada]
在命令行界面添加 --filter 参数,灵感来自 Bogdan 的早期设计。[bogdangi] [gforcada]
创建一个新模块 :module::haproxy.filters 来保存所有可用的过滤器。[gforcada]
改进 :method::.HaproxyLogFile.cmd_queue_peaks 输出,不仅显示峰值,还显示请求开始排队和完成的时间以及排队请求的数量。[gforcada]
在没有提供任何参数时显示帮助。[gforcada]
改进文档和文档字符串。[gforcada]
在命令行界面添加 --list-commands 参数。[gforcada]
为 HaproxyLogLine 和 HaproxyLogFile 生成 API 文档。[bogdangi]
创建一个 console_script haproxy_log_analysis 以便于使用。[bogdangi]
添加 Sphinx 文档系统,目前为空。[gforcada]
保持有效日志行的排序,以便保持连接的精确顺序。[gforcada]
添加了很多命令,请参阅 README.rst 获取完整列表。[gforcada]
运行作为参数传递的命令(使用 -c 标志)。[gforcada]
添加 requirements.txt 文件以跟踪依赖项并锁定它们。[gforcada]
添加 travis 和 coveralls 支持。请参阅 README.rst 中的徽章。[gforcada]
为所有参数添加参数解析和自定义验证逻辑。[gforcada]
为 haproxy 日志行(HTTP 格式)和解析 HTTP 请求路径添加正则表达式。添加测试以确保它们按预期工作。[gforcada]
创建分发。 [gforcada]
项目详情
haproxy_log_analysis-5.1.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9eb326250a06145666fa6498c0ecf04f3123ed8a3ffdb472f60612d6b8956ed3 |
|
MD5 | 9bc5aeb47013cf57ee06122182e0c66b |
|
BLAKE2b-256 | 30e4a60383d4b86e462e74c18bbc5a5ae4a6470a1f67dc3814ac10a901fa241f |
haproxy_log_analysis-5.1.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b11a507f69cccdf0b3cf64f6e9f7f2eca2a2d0bd0c69e14ae028214e17cd3123 |
|
MD5 | a27bb97db63d0855563d27673bf7c822 |
|
BLAKE2b-256 | 00d049c3027c08063975da5b541592956b694e432a1b2936fbac8c03d1fae51a |