【发布时间】:2021-06-28 13:49:47
【问题描述】:
我正在 ElasticSearch 6.8 (https://www.elastic.co/guide/en/elasticsearch/reference/6.8/range.html) 中试验 ip_range 字段类型,并努力寻找一种通过 logstash
我能够通过 Kibana 开发工具加载一些示例数据,但无法通过 logstash 找到相同的方法。
索引定义
PUT test_ip_range
{
"mapping": {
"_doc": {
"properties": {
"ip_from_to_range": {
"type": "ip_range"
},
"ip_from": {
"type": "ip"
},
"ip_to": {
"type": "ip"
}
}
}
}
}
添加示例文档:
PUT test_ip_range/_doc/3
{
"ip_from_to_range" :
{
"gte" : "<dotted_ip_from>",
"lte": "<dotted_ip_to>"
}
}
Logstash 配置(从数据库读取)
input {
jdbc {
...
statement => "SELECT ip_from, ip_to, <???> AS ip_from_to_range FROM sample_ip_data"
}
}
output {
stdout { codec => json_lines }
elasticsearch {
"hosts" => "<host>"
"index" => "test_ip_range"
"document_type" => "_doc"
}
}
问题:
如何通过logstash 配置将ip_from 和ip_to DB 字段分别放入gte 和lte 部分??
我知道我也可以以 CIDR 表示法插入 ip 范围,但希望能够同时拥有两种选择 - 以 CIDR 表示法加载和作为范围加载。
【问题讨论】: