# Integration of Manticore with Fluentbit

An example of how one can use the Fluentbit agent together with Manticore

## 介绍

[Fluent Bit](https://fluentbit.io/) 是一个开源的多平台工具，用于日志处理和分发。
如今数据来自各种来源，Fluent Bit 可以帮助您聚合和处理所有日志数据。
现在，Manticore 也支持使用 Fluent Bit 作为处理管道。这允许收集和转换后的数据发送到 Manticore。

让我们检查一个简单的示例，用于索引 `dpkg.log`，这是 Debian 包管理器的标准日志文件。日志本身具有简单的结构，如下所示：
```
2023-05-31 10:42:55 status triggers-awaited ca-certificates-java:all 20190405ubuntu1.1
2023-05-31 10:42:55 trigproc libc-bin:amd64 2.31-0ubuntu9.9 <none>
2023-05-31 10:42:55 status half-configured libc-bin:amd64 2.31-0ubuntu9.9
2023-05-31 10:42:55 status installed libc-bin:amd64 2.31-0ubuntu9.9
2023-05-31 10:42:55 trigproc systemd:amd64 245.4-4ubuntu3.21 <none>
```

## 配置

以下是一个可以与 Manticore 一起使用的 Fluent 配置文件示例：
``` ini
[SERVICE]
	flush    	1
	daemon   	On
	log_level	info

[INPUT]
	name tail
	path /var/log/dpkg.log
	inotify_watcher false
	read_from_head true

[OUTPUT]
	name es
	match *
	host 127.0.0.1
	port 9308
	index  dpkg_log
```
请注意，我们的示例旨在在 Docker 中运行，因此我们以守护进程模式启动 FluentBit，并禁用 INPUT inotify_watcher 选项，以避免与 Docker 环境可能引发的问题，这可能导致错误。此外，我们假设 Manticore 在默认的 http 端口 9308 上启动。

## 结果

现在您可以使用上面的配置运行 Fluentbit。来自 dpkg 日志的数据将被传递到 Manticore 并正确索引。

以下是创建的表的模式和插入的文档示例：
``` sql
mysql> DESCRIBE dpkg_log;
+-------------+--------+----------------+
| Field       | Type   | Properties     |
+-------------+--------+----------------+
| id          | bigint |                |
| @timestamp  | text   | indexed stored |
| log         | text   | indexed stored |
+-------------+--------+----------------+

mysql> SELECT * FROM dpkg_log LIMIT 3\G
*************************** 1. row ***************************
id: 7856533729353662465
@timestamp: 2023-08-04T15:09:21.191Z
log: 2023-06-05 14:03:04 startup archives install
*************************** 2. row ***************************
id: 7856533729353662466
@timestamp: 2023-08-04T15:09:21.191Z
log: 2023-06-05 14:03:04 install base-passwd:amd64 <none> 3.5.47
*************************** 3. row ***************************
id: 7856533729353662467
@timestamp: 2023-08-04T15:09:21.191Z
log: 2023-06-05 14:03:04 status half-installed base-passwd:amd64 3.5.47
```

## 结论

Manticore 与 Fluent Bit 的集成提供了一种强大且高效的解决方案，用于处理和索引日志数据，使其更易于各种应用程序访问和管理。通过提供的简单配置和清晰示例，即使是对这些工具不熟悉的人也可以快速入门，并从 Manticore 和 Fluent Bit 协同工作的强大功能中受益。无论您处理的是标准日志还是更复杂的数据源，这种合作简化了流程，并为有效的数据管理开辟了新的可能性。
