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

Manticore与Vector.dev的集成

介绍

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

结论

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

安装Manticore Search

安装Manticore Search