# 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.
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
最新资源
- 数据分析-泰坦尼克号幸存者预测
- DataStructure-二叉树的深度
- htt-code-share-圣诞树代码html
- 基于随机森林、LSTM、SVM、线性回归四种机器学习方法预测股价项目源码(高分项目)
- 随机森林、LSTM、SVM、线性回归四种机器学习方法预测股价项目源码(高分大作业)
- 超声波去披锋机3D图纸和工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- 123456445678645
- 点此安装准易云课V2.zip
- 机械设计葡萄采摘机含工程图仿真说明书sw12可编辑非常好的设计图纸100%好用.zip
- 开盘啦5.17.0.0.apk
- 机械设计特斯拉model x汽车电子系统及线束总成 Catia非常好的设计图纸100%好用.zip
- Hadoop技术 期末考核方案(A卷)大数据2301班(1).docx
- 机械设计转盘式全自动卡针焊接机含工程图sw19可编辑非常好的设计图纸100%好用.zip
- 毕业设计基于Python+Django+Vue+MySql开发的前后端分离的贫困生资助管理系统源码+数据库
- 基于STM32单片机的智能空气监测系统源码(高分毕业设计)
- 基于stm32的环境监测系统源码(高分毕业设计).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0