elasticsearch - ElasticSearch-无法获取映射

标签 elasticsearch logstash kibana

我已经建立了一个ELK堆栈来索引我的Akamai日志。我已经在Logstash中创建了一个conf文件,并且在加载Logstash时正在加载它。我的日志文件只是读取

Pipeline main started



但是,我无法在Kibana中创建索引。我看到讯息

Unable to fetch mapping



我通过调试器运行了grok语句,似乎我捕获了所有内容。这是我的配置:
    input {
  file {
    path => "C:\Akamai_Logs\US\*"
    start_position => "beginning"
  }
}

filter {
  grok {
    match => ["message", "%{DATE:date} %{TIME:time} %{IP:client} %{WORD:method} %{URIPATH:URI} %{NUMBER:status} %{NUMBER:bytes} %{NUMBER:time_taken} %{NOTSPACE:refererr} %{QS:user_agent} %{GREEDYDATA:cookie}"]
  }
}


output {
  stdout {codec => rubydebug}
  elasticsearch {
      hosts => ["localhost:9200"]
    }

}

这是其中一个日志的示例行

2016-06-14 14:03:42 1.1.1.1 GET /origin-uri 200 26222 0 "referrer" "user agent" "cookie string"



日志文件中的间距是否会导致索引出现问题?我只是想念其他东西吗?

编辑:忘记添加我的Logstash模板
{
    "template": "logstash-*",
    "settings" : {
        "number_of_shards" : 1,
        "number_of_replicas" : 0,
        "index" : {
            "query" : { "default_field" : "@message" },
            "store" : { "compress" : { "stored" : true, "tv": true } }
        }
    },
    "mappings": {
        "_default_": { 
            "_all": { "enabled": false },
            "_source": { "compress": true },
            "dynamic_templates": [
                {
                    "string_template" : { 
                        "match" : "*",
                        "mapping": { "type": "string", "index": "not_analyzed" },
                        "match_mapping_type" : "string"
                     } 
                 }
             ],
             "properties" : {
                "@date": { "type": "date", "format": "yyyy-MM-dd" },
                "@time": { "type": "time", "format": "hh:mm:ss" },
                "@hostip": {"type": "string","index" : "not_analyzed"},    
                "@method": {"type": "string","index" : "not_analyzed"},
                "@page": {"type": "string","index" : "not_analyzed"},
                "@status": {"type": "integer"},
                "@bytes": {"type": "integer"},
                "@timetaken": {"type": "integer"},
                "@referrer": {"type": "string","index" : "not_analyzed"},
                "@useragent": {"type": "string","index" : "not_analyzed"},
                "@cookie": {"type": "string","index" : "not_analyzed"}              
            }
        }
    }
}

最佳答案

将此输入替换为file输入(使用正斜杠而不是反斜杠),然后它应该可以工作。

input {
  file {
    path => "C:/Akamai_Logs/US/*.*"
    start_position => "beginning"
  }
}

更新

由于您拥有自己的索引模板文件,因此请确保按以下方式修改elasticsearch输出:
output {
    elasticsearch {
        hosts => ["localhost:9200"]
        template => "/path/to/logstash-template.json"
        template_overwrite => true
    }
}

如果您的ES中已经存在一个logstash模板,也可以确保删除它
curl -XDELETE localhost:9200/_template/logstash

关于elasticsearch - ElasticSearch-无法获取映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38056752/

相关文章:

elasticsearch - 响应中未保留的 agg 名称的排序

elasticsearch - 如何按日期周期或大小从elasticsearch中删除文档?

elasticsearch - 使用 quarkuslogging-gelf 扩展和 ELK 堆栈时出现索引错误

elasticsearch - 如何从Web站点使用Elastic&Kibana收集日志和收集日志

elasticsearch - 在Elasticsearch中创建MySQL索引相当于什么?

amazon-web-services - Logstash无法将日志推送到ES

hadoop - 如何用Spark尾部HDFS文件?

elasticsearch - 没有在字段ElasticSearch上声明类型[geo-point]的处理程序

elasticsearch - ES查询忽略时间范围过滤器

ruby-on-rails - 盆景服务器挂了怎么办?