# logger-to-kibana
[![Build Status](https://dev.azure.com/ismaelmartinez0550/logger-to-kibana/_apis/build/status/IsmaelMartinez.logger-to-kibana?branchName=master)](https://dev.azure.com/ismaelmartinez0550/logger-to-kibana/_build/latest?definitionId=2&branchName=master)
[![DepShield Badge](https://depshield.sonatype.org/badges/IsmaelMartinez/logger-to-kibana/depshield.svg)](https://depshield.github.io)
---
This project is inteded to generate view from the log messages encountered.
The python executable can be found in [https://pypi.org/project/logger-to-kibana/](https://pypi.org/project/logger-to-kibana/)
You will need to install the dependences by running
```bash
pip install -r requirements.txt
```
To get the programs help just type:
```bash
python main.py
```
This returns:
```bash
Usage: main.py [OPTIONS] COMMAND [ARGS]...
Process the file provided according to conditions
Options:
--help Show this message and exit.
Commands:
pommands:
process Process the folder
process_and_generate Process the folder and generate visualization
process_generate_and_send Process the folder, generate visualization and
send
```
## Default settings
The default settings can be found in the [settings.ini](settings.ini) file. You can provide a different settings
file by specifying it as an environment variable LOGGER_TO_KIBANA_CONFIG
## commands
The current available commands are:
### process
Process a folder and prints out the processed functions/logs in the following format:
```bash
[{'type': '<log_type>', 'query': 'message: "<log_filter>"', 'label': '<log_type>: <log_filter>'}]
```
To execute the command run:
```bash
python main.py process -f <folder_location>
```
Check the table under [How does it work] section to get more info about log_type and log_filter.
### process_and_generate
Process a folder (as shown in the process section) and generates a table visualization for kibana.
To execute the command run:
```bash
python main.py process_and_generate -f <folder_location>
```
### process_generate_and_send
Process a folder, generates a table visualization for kibana and send it to kibana (currently in localhost:5601)
To execute the command run:
```bash
python main.py process_and_generate -f <folder_location>
```
### How does it work
By default, it scans for files under the folder specified and with the pattern `app/src/**/*.py`. You can specify another patter in the FilesMatchFilter in the [settings.ini](settings.ini)
This program uses different regex `detectors` to filter logs and files to process.
Those can be changed in the [settings.ini](settings.ini) file.
The current available detectors are:
| Detector | Default Value | Propose |
|---|---|---|
| FilesMatchFilter | app/src/**/*.py | Filter the files to process in the provided folder |
| FunctionMappingDetector | def | Detect a function |
| FunctionMappingFilter | (?<=def ).*?(?=\() | Filter the function name |
| LogDebugDetector | LOG.debug | Detect the log debug message |
| LogDebugFilter | (?<=LOG.debug\(["\']).*?(?=["\']) | Filter the log debug message |
| LogInfoDetector | LOG.info | Detect the log info message |
| LogInfoFilter | (?<=LOG.info\(["\']).*?(?=["\']) | Filter the log info message |
| LogWarnDetector | LOG.warn | Detect the log warn message |
| LogWarnFilter | (?<=LOG.warn\(["\']).*?(?=["\']) | Filter the log warn message |
| LogErrorDetector | LOG.error | Detect the log error message |
| LogErrorFilter | (?<=LOG.error\(["\']).*?(?=["\']) | Filter the log error message |
| LogCriticalDetector | LOG.critical | Detect the log critical message |
| LogCriticalFilter | (?<=LOG.critical\(["\']).*?(?=["\']) | Filter the log critical message |
| LogExceptionDetector | LOG.exception | Detect the log exception message |
| LogExceptionFilter | (?<=LOG.exception\(["\']).*?(?=["\']) | Filter the log exception message |
Other configuration available in the settings.ini file are:
| Type | Value | Propose |
| -- | -- | -- |
| BaseUrl | [http://localhost:5601](http://localhost:5601) | Kibana base url |
| Index | 59676040-e7fd-11e9-9209-1f165c3af176 | Kibana index |
## The process
The commands for the application are done in the following logical order.
```bash
process -> generate -> send
```
As an example, when processing a file in `tests/unit/resources/example.py` with the content:
```python
def lambda_handler(_event: dict, _context):
LOG.debug('Initialising')
LOG.info('Processing')
LOG.warn('Success')
LOG.error('Failure')
LOG.critical('Bananas')
LOG.exception('Exception')
)
```
Will return the next object:
```python
[{'filename': 'tests/unit/resources/example.py', 'function': 'lambda_handler',
'type': 'debug', 'query': 'message: "Initialising"', 'label': 'debug: Initialising'},
{'filename': 'tests/unit/resources/example.py', 'function': 'lambda_handler',
'type': 'info', 'query': 'message: "Processing"', 'label': 'info: Processing'},
{'filename': 'tests/unit/resources/example.py', 'function': 'lambda_handler',
'type': 'warn', 'query': 'message: "Success"', 'label': 'warn: Success'},
{'filename': 'tests/unit/resources/example.py', 'function': 'lambda_handler',
'type': 'error', 'query': 'message: "Failure"', 'label': 'error: Failure'},
{'filename': 'tests/unit/resources/example.py', 'function': 'lambda_handler',
'type': 'critical', 'query': 'message: "Bananas"', 'label': 'critical: Bananas'},
{'filename': 'tests/unit/resources/example.py', 'function': 'lambda_handler',
'type': 'exception', 'query': 'message: "Exception"', 'label': 'exception: Exception'}]
```
Generate, will generate a table visualization with filters for all the logs that have found.
The choise of having a table visualization is for the amount of information available. It is, basically, a good place to start as later we can split the visualizations by file, function or whatever we choose to do so.
You can change the type of visualization generated by modifying the VisualizationType in the [settings.ini](settings.ini). The current available values are metric or table. The default value is table.
To finish, it sends the generated visualization to Kibana with the following name format:
[Generated - <folder_name> ]
## Limitations
Currently, this project does not separate logs per file or function [see #25 as this is in process](#25). For that reason, it was choosen to use the table visualization as it is easy to generate too many filter for the other types of visualizations.
It only generates the visualizations and not the dashboards.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:logger-to-kibana-0.0.9.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源详情
资源评论
资源推荐
收起资源包目录
logger-to-kibana-0.0.9.tar.gz (19个子文件)
logger-to-kibana-0.0.9
PKG-INFO 8KB
logger_to_kibana.egg-info
PKG-INFO 8KB
SOURCES.txt 498B
entry_points.txt 48B
top_level.txt 6B
dependency_links.txt 1B
tests
unit
test_commands.py 2KB
__init__.py 0B
utils
test_table.py 2KB
test_visualization.py 3KB
__init__.py 0B
test_metric.py 2KB
test_file_processor.py 2KB
test_kibana.py 1KB
helpers.py 187B
__init__.py 0B
setup.cfg 38B
setup.py 756B
README.md 6KB
共 19 条
- 1
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- GitBook 教授 Javascript 编程基础知识.zip
- Generation.org 开发的 JAVA 模块练习.zip
- FastDFS Java 客户端 SDK.zip
- etcd java 客户端.zip
- Esercizi di informatica!执行计划,metti alla prova!.zip
- Eloquent JavaScript 翻译 - 2ª edição .zip
- Eclipse Paho Java MQTT 客户端库 Paho 是一个 Eclipse IoT 项目 .zip
- disconf 的 Java 应用程序.zip
- cloud.google.com 上使用的 Java 和 Kotlin 代码示例.zip
- 未命名3(3).cpp
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0