【问题标题】:logstash output not showing up in kibanalogstash 输出未显示在 kibana 中
【发布时间】:2016-10-18 16:42:44
【问题描述】:

我刚开始学习 Elastic Search 并尝试通过 logstash 将 IIS 日志转储到 ES 并查看它在 Kibana 中的外观。 已成功设置所有 3 个代理,并且它们运行无错误。但是当我在存储的日志文件上运行 logstash 时,日志不会显示在 Kibana 中。 (我使用的是没有“头”_plugin 的 ES5.0)

这是我在 logstash 命令中看到的输出。

    Sending Logstash logs to C:/elasticsearch-5.0.0/logstash-5.0.0-rc1/logs which is now configured via log4j2.properties.
06:28:26.067 [[main]-pipeline-manager] INFO  logstash.outputs.elasticsearch - Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>["http://localhost:9200"]}}
06:28:26.081 [[main]-pipeline-manager] INFO  logstash.outputs.elasticsearch - Using mapping template from {:path=>nil}
06:28:26.501 [[main]-pipeline-manager] INFO  logstash.outputs.elasticsearch - Attempting to install template {:manage_template=>{"template"=>"logstash-*", "version"=>50001, "settings"=>{"index.refresh_interval"=>"5s"}, "mappings"=>{"_default_"=>{"_all"=>{"enabled"=>true, "norms"=>false}, "dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword"}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date", "include_in_all"=>false}, "@version"=>{"type"=>"keyword", "include_in_all"=>false}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}}}
06:28:26.573 [[main]-pipeline-manager] INFO  logstash.outputs.elasticsearch - New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["localhost:9200"]}
06:28:26.717 [[main]-pipeline-manager] INFO  logstash.pipeline - Starting pipeline {"id"=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>5, "pipeline.max_inflight"=>500}
06:28:26.736 [[main]-pipeline-manager] INFO  logstash.pipeline - Pipeline main started
06:28:26.857 [Api Webserver] INFO  logstash.agent - Successfully started Logstash API endpoint {:port=>9600}

但是 kibana 没有显示任何索引。我是这里的新手,不确定内部发生了什么。你能帮我理解这里有什么问题吗?

Logstash 配置文件:

input { 
    file {
        type => "iis-w3c"
        path => "C:/Users/ras/Desktop/logs/logs/LogFiles/test/aug1/*.log"
      }
}
filter {  
    grok {
        match => ["message", "%{TIMESTAMP_ISO8601:log_timestamp} %{WORD:serviceName} %{WORD:serverName} %{IP:serverIP} %{WORD:method} %{URIPATH:uriStem} %{NOTSPACE:uriQuery} %{NUMBER:port} %{NOTSPACE:username} %{IPORHOST:clientIP} %{NOTSPACE:protocolVersion} %{NOTSPACE:userAgent} %{NOTSPACE:cookie} %{NOTSPACE:referer} %{NOTSPACE:requestHost} %{NUMBER:response} %{NUMBER:subresponse} %{NUMBER:win32response} %{NUMBER:bytesSent} %{NUMBER:bytesReceived} %{NUMBER:timetaken}"]
      }
     mutate {
    ## Convert some fields from strings to integers
    #
    convert => ["bytesSent", "integer"]
    convert => ["bytesReceived", "integer"]
    convert => ["timetaken", "integer"]

    ## Create a new field for the reverse DNS lookup below
    #
    add_field => { "clientHostname" => "%{clientIP}" }

    ## Finally remove the original log_timestamp field since the event will
    #   have the proper date on it
    #
    remove_field => [ "log_timestamp"]
  }
}
output {
  elasticsearch { 
        hosts => ["localhost:9200"]
        index => "%{type}-%{+YYYY.MM}"
  }
  stdout { codec => rubydebug }
}

【问题讨论】:

  • 可以使用 kopf 代替 head,与 head 相比,我更喜欢它。但我不知道它是否适用于 ES 5。

标签: elasticsearch logstash kibana


【解决方案1】:

您可以使用 kopf 之类的插件或端点 _cat/indices/ 来检查 Elasticsearch 中存在的索引的名称,您可以通过浏览器直接访问 [ip of ES]:9200/_cat/indices 或通过 curl:curl [ip of ES]:9200/_cat/indices。


使用 Kibana,您必须提供索引名称的模式,默认情况下为 logstash-*,如屏幕截图所示。在 Kibana 中使用此默认值,因为在用于 logstash 的 elasticsearch 输出插件中,默认索引模式为 logstash-%{+YYYY.MM.dd} (cf doc),它将用于命名使用此插件创建的索引。

但在你的情况下,插件配置了index => "%{type}-%{+YYYY.MM}"。所以创建的索引将是iis-w3c-%{+YYYY.MM} 格式。所以你必须在Index name or pattern字段中用iis-w3c-*替换logstash-*

【讨论】:

  • 当我执行 _cat/indices/ 时,我只得到 yellow open .kibana HUMxXPMtS0-MBNQtyj5G6g 1 1 1 0 3.2kb 3.2kb 的文本。我没有看到任何名称为 iis* 创建的索引。
  • @Raghav 所以问题出在 Logstash 上。如果 Logstash 已经读取了该文件(例如,仅使用 stdout),如果您重新启动它,Logstash 将不会再次读取该文件。看看这个答案stackoverflow.com/a/25119894/6113627
猜你喜欢
  • 2022-01-06
  • 1970-01-01
  • 2021-07-02
  • 1970-01-01
  • 2015-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多