⚠️ 此页面为自动翻译,翻译可能不完美。
blog-post

Integration of Manticore with Vector.dev

介绍

Vector by Datadog 是一个高性能的端到端(代理与聚合器)可观测性数据管道,可让您收集、转换和路由所有日志和指标。此外,它是开源的。虽然它本身可以作为聚合器使用,但人们发现将其与专用数据存储工具(如 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>

配置

以下是 Vector.dev 的配置文件示例,采用 toml 格式:

[sources.test_file]
type = "file"
include = [ "/var/log/dpkg.log" ]

[transforms.modify_test_file]
type = "remap"
inputs = [ "test_file" ]
source = """
.vec_timestamp = del(.timestamp)"""

[sinks.manticore]
type = "elasticsearch"
inputs = [ "modify_test_file" ]
endpoints = ["http://127.0.0.1:9308"]
bulk.index = "dpkg_log"

请注意,在此示例中,我们假设 Manticore 使用其默认的 http 端口 9308。如果您使用自定义 http 端口,请相应地更改 Vector.dev 配置。还请注意,我们向配置中添加了 transforms 部分,以重命名默认的 timestamp 字段,因为它是 Manticore 中的保留字。

结果

现在只需使用上述配置启动 Vector.dev,dpkg 日志中的数据将被传递到 Manticore 并正确索引。
以下是创建的表的结构和插入文档的示例:

mysql> DESCRIBE dpkg_log;
+-----------------+---------+--------------------+
| Field           | Type    | Properties         |
+-----------------+---------+--------------------+
| id              | bigint  |                    |
| file            | text    | indexed stored     |
| host            | text    | indexed stored     |
| message         | text    | indexed stored     |
| source_type     | text    | indexed stored     |
| vec_timestamp   | text    | indexed stored     |
+-----------------+---------+--------------------+


mysql> SELECT * FROM testlog_3 LIMIT 3\G
*************************** 1. row ***************************
id: 7856533729353672195
file: /var/log/dpkg.log
host: logstash-787f68f6f-nhdd2
message: 2023-06-05 14:03:04 startup archives install
source_type: file
vec_timestamp: 2023-08-04T15:32:50.203091741Z
*************************** 2. row ***************************
id: 7856533729353672196
file: /var/log/dpkg.log
host: logstash-787f68f6f-nhdd2
message: 2023-06-05 14:03:04 install base-passwd:amd64 <none> 3.5.47
source_type: file
vec_timestamp: 2023-08-04T15:32:50.203808861Z
*************************** 3. row ***************************
id: 7856533729353672197
file: /var/log/dpkg.log
host: logstash-787f68f6f-nhdd2
message: 2023-06-05 14:03:04 status half-installed base-passwd:amd64 3.5.47
source_type: file
vec_timestamp: 2023-08-04T15:32:50.203814031Z

结论

因此,通过本指南中概述的集成,您现在可以轻松有效地通过将 Manticore 与 Vector by Datadog(一个高性能的端到端可观测性数据管道)协作来索引日志数据。Vector.dev 与 Manticore 之间的这种协同作用不仅为管理日志数据提供了一种简化的途径,还通过允许转换和路由扩展了功能。无论您处理的是简单还是复杂的日志结构,这种集成都提供了一个强大的解决方案,使收集、转换和存储数据的过程更加便捷和高效。

安装Manticore Search

安装Manticore Search