【问题标题】:Fluentd Elasticsearch Kibana logs dynamic index GEOPOINT mappingFluentd Elasticsearch Kibana 记录动态索引 GEOPOINT 映射
【发布时间】:2019-07-04 14:37:41
【问题描述】:

我正在使用 EFK 日志堆栈,并设法设置了 fluentd 过滤器和匹配配置,以便在 Kibana 中收集的 tomcat 访问日志所有需要的字段都在那里:IP、纬度、经度、城市、国家代码等。

我有curl -XPUT -H "Content-Type: application/json" --data @fluentd_mapping.json http://$host/fluentd/fluentd/_mapping,但它只影响流利的索引。不是动态创建的每日日志索引<foo>.access.logs.*

所以我的问题是如何应用映射,以便 geo_point 类型对每日日志索引有效?谢谢。

我重新启动了 ES 容器 curl -XPUT 以下 mapping.json 被 fluentd 索引而不是日常日志索引拾取:

{
    "fluentd": {
        "location_array": {
          "type": "geo_point"
        },
        "location_properties": {
          "type": "geo_point"
        },
        "location_string": {
          "type": "geo_point"
        },
    }
}

现有模板:

                "dynamic_templates": [{
    "kibana_index_template:.kibana": {
                "dynamic_templates": [{
    "security-index-template": {
                "dynamic_templates": [{
                        "path_match": "result\\.(input(\\..+)*|(transform(\\..+)*)|(actions\\.transform(\\..+)*))\\.search\\.request\\.(body|template)",
    "logstash-index-template": {

现有索引模式:

        "index_patterns": [".monitoring-logstash-6-*"],
        "index_patterns": [".monitoring-kibana-6-*"],
        "index_patterns": [".ml-anomalies-*"],
        "index_patterns": [".kibana"],
        "index_patterns": [".ml-state"],
        "index_patterns": [".watches*"],
        "index_patterns": [".monitoring-beats-6-*"],
        "index_patterns": [".monitoring-es-6-*"],
        "index_patterns": [".security_audit_log*"],
        "index_patterns": [".ml-meta"],
        "index_patterns": [".security-*"],
        "index_patterns": [".triggered_watches*"],
        "index_patterns": [".watcher-history-9*"],
        "index_patterns": [".monitoring-alerts-6"],
        "index_patterns": [".ml-notifications"],
        "index_patterns": [".logstash"],

我添加了以下模板但无济于事:

        "fluentd": {
                "order": 0,
                "index_patterns": ["myapp.access.logs*"],
                "settings": {},
                "mappings": {
                        "fluentd": {
                                "properties": {
                                        "location_array": {
                                                "type": "geo_point"
                                        },
                                        "location_properties": {
                                                "type": "geo_point"
                                        },
                                        "location_string": {
                                                "type": "geo_point"
                                        }
                                }
                        }
                },
                "aliases": {}
        },

myapp.access.logs 没有接收到它-

【问题讨论】:

  • 在您添加的模板中,只需将“fluentd”更改为“_doc”即可。

标签: elasticsearch kibana fluentd geopoints


【解决方案1】:

为清楚起见,请指定 fluentd_mapping.json 的内容,但看起来索引具有不同的名称模式,这就是映射不适用于所有索引的原因。

您应该使用 elasticsearch 模板来配置 geoip 映射。在模板中查看描述索引匹配条件的“index_patterns”。 https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

一旦 index_patterns 正则表达式将匹配您需要的所有索引(包括访问日志索引),然后 GEOIP 映射和所有其余部分将按预期应用。

【讨论】:

  • 我的 fluentd 映射并不重要,因为我在 fluentd 索引中看到了这一点。动态/自动创建的每日日志索引使用该映射,但奇怪的是 geo_point 出现在流利的索引中,而不是每日日志索引映射。
  • 如何更改 index_patterns?它似乎是全球性的。
  • 您对那些每日索引使用索引模板吗?你能粘贴模板和索引映射吗?我认为您没有正确的每日索引映射,这就是未检测到 geo_point 的原因
  • 请注意,您无法更改现有索引中的映射(如果请求的字段已经存在映射),因此您必须:1.设置正确的模板,2.创建一个新索引,其模式与模板匹配。
  • 我不明白你对那些每日索引的索引模板的意思。我重新启动 ES 容器 curl -XPUT mapping.json 并看到 fluentd 拾取了该容器,但没有看到每日日志索引。
猜你喜欢
  • 1970-01-01
  • 2012-08-31
  • 2022-08-12
  • 1970-01-01
  • 2014-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-08
相关资源
最近更新 更多