社区ID处理器
community_id
处理器用于为网络流元组生成社区ID流哈希值。社区ID流哈希算法在 社区ID规范 中定义。处理器生成的哈希值可用于关联所有相关的网络事件,以便您可以通过哈希值过滤网络流数据或通过对哈希字段进行聚合来生成统计信息。该处理器支持 TCP、UDP、SCTP、ICMP 和 IPv6-ICMP 网络协议。使用 SHA-1 哈希算法生成哈希值。
以下是 community_id
处理器语法
{
"community_id": {
"source_ip_field": "source_ip",
"source_port_field": "source_port",
"destination_ip_field": "destination_ip",
"destination_port_field": "destination_port",
"iana_protocol_number_field": "iana_protocol_number",
"source_port_field": "source_port",
"target_field": "community_id"
}
}
配置参数
下表列出了 community_id
处理器所需和可选的参数。
参数 | 必需/可选 | 描述 |
---|---|---|
source_ip_field | 必需 | 包含源 IP 地址的字段名称。 |
source_port_field | 可选 | 包含源端口地址的字段名称。如果网络协议是 TCP、UDP 或 SCTP,则此字段是必需的。否则,则不是必需的。 |
destination_ip_field | 必需 | 包含目标 IP 地址的字段名称。 |
destination_port_field | 可选 | 包含目标端口地址的字段名称。如果网络协议是 TCP、UDP 或 SCTP,则此字段是必需的。否则,则不是必需的。 |
iana_protocol_number | 可选 | 包含由互联网号码分配机构 (IANA) 定义的协议号的字段名称。支持的值为 1 (ICMP)、6 (TCP)、17 (UDP)、58 (IPv6-ICMP) 和 132 (SCTP)。 |
protocol_field | 可选 | 包含协议名称的字段名称。如果未设置 iana_protocol_number ,则此字段是必需的。否则,则不是必需的。 |
icmp_type_field | 可选 | 包含 ICMP 消息类型的字段名称。当协议为 ICMP 或 IPv6-ICMP 时,此字段是必需的。 |
icmp_code_field | 可选 | 包含 ICMP 消息代码的字段名称。对于某些没有代码的 ICMP 消息类型,该字段是可选的。否则,则是必需的。 |
seed | 可选 | 用于生成社区ID哈希值的种子。该值必须在 0 到 65535 之间。 |
target_field | 可选 | 存储社区ID哈希值的字段名称。默认目标字段是 community_id 。 |
ignore_missing | 可选 | 指定如果缺少一个必需字段,处理器是否应静默退出。默认为 false 。 |
description | 可选 | 处理器的简要描述。 |
if | 可选 | 运行处理器的条件。 |
ignore_failure | 可选 | 如果设置为 true ,则忽略故障。默认为 false 。 |
on_failure | 可选 | 处理器失败时要运行的处理器列表。 |
tag | 可选 | 处理器的标识符标签。有助于调试以区分相同类型的处理器。 |
使用处理器
按照以下步骤在管道中使用处理器。
步骤 1:创建管道
以下查询创建一个名为 community_id_pipeline
的管道,该管道使用 community_id
处理器为网络流元组生成哈希值
PUT /_ingest/pipeline/commnity_id_pipeline
{
"description": "generate hash value for the network flow tuple",
"processors": [
{
"community_id": {
"source_ip_field": "source_ip",
"source_port_field": "source_port",
"destination_ip_field": "destination_ip",
"destination_port_field": "destination_port",
"iana_protocol_number_field": "iana_protocol_number",
"target_field": "community_id"
}
}
]
}
步骤 2(可选):测试管道
建议您在摄入文档之前测试您的管道。
要测试管道,请运行以下查询
POST _ingest/pipeline/commnity_id_pipeline/_simulate
{
"docs": [
{
"_index": "testindex1",
"_id": "1",
"_source": {
"source_ip": "66.35.250.204",
"source_port": 80,
"destination_ip": "128.232.110.120",
"destination_port": 34855,
"iana_protocol_number": 6
}
}
]
}
响应
以下示例响应确认管道按预期工作
{
"docs": [
{
"doc": {
"_index": "testindex1",
"_id": "1",
"_source": {
"community_id": "1:LQU9qZlK+B5F3KDmev6m5PMibrg=",
"destination_ip": "128.232.110.120",
"destination_port": 34855,
"source_port": 80,
"iana_protocol_number": 6,
"source_ip": "66.35.250.204"
},
"_ingest": {
"timestamp": "2024-03-11T02:17:22.329823Z"
}
}
}
]
}
步骤 3:摄取文档
以下查询将文档摄取到名为 testindex1
的索引中
PUT testindex1/_doc/1?pipeline=commnity_id_pipeline
{
"source_ip": "66.35.250.204",
"source_port": 80,
"destination_ip": "128.232.110.120",
"destination_port": 34855,
"iana_protocol_number": 6
}
响应
该请求将文档索引到 testindex1
索引中
{
"_index": "testindex1",
"_id": "1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}
步骤 4(可选):检索文档
要检索文档,请运行以下查询
GET testindex1/_doc/1