0

我正在尝试让 kibana-4 地理地图与 ELB 日志一起使用

当我单击发现选项卡时,我可以清楚地看到值为 [lat, lon] 的字段 geoip.location 但是当我单击可视化选项卡 -> 平铺地图 -> 新搜索 -> 地理坐标时,我得到一个错误(不显示任何地方我还检查了 kibana 日志的错误是什么 - 但那里什么也没有)

我检查了检查元素 - 也没有

然后我选择 GeoHash,但该字段为空(当我单击它时,它的空白带有复选图标)

我怎样才能看到错误是什么?如何让这张地图工作?

我的配置是:

    input {
  file {
    path => "/logstash_data/logs/elb/**/*"
    exclude => "*.gz"
    type => "elb"
    start_position => "beginning"
    sincedb_path => "log_sincedb"
  }
}

filter {
    if [type] == "elb" {
      grok {
        match => [
          "message", '%{TIMESTAMP_ISO8601:timestamp} %{NGUSERNAME:loadbalancer} %{IP:client_ip}:%{POSINT:client_port} (%{IP:backend_ip}:%{POSINT:backend_port}|-) %{NUMBER:request_processing_time} %{NUMBER:backend_processing_time} %{NUMBER:response_processing_time} %{POSINT:elb_status_code} %{INT:backend_status_code} %{NUMBER:received_bytes} %{NUMBER:sent_bytes} \\?"%{WORD:method} https?://%{WORD:request_subdomain}.server.com:%{POSINT:request_port}%{URIPATH:request_path}(?:%{URIPARAM:query_string})? %{NOTSPACE}"'
        ]
      }

      date {
        match => [ "timestamp", "ISO8601" ]
        target => "@timestamp"
      }

      if [query_string] {
        kv {
          field_split => "&?"
          source => "query_string"
          prefix => "query_string_"
        }
        mutate {
          remove => [ "query_string" ]
        }
      }

      if [client_ip] {
        geoip {
         source => "client_ip"
         add_tag => [ "geoip" ]
        }
      }

      if [timestamp] {
        ruby { code => "event['log_timestamp'] = event['@timestamp'].strftime('%Y-%m-%d')"}
      }
    }
  }
}

output {
  elasticsearch {
    cluster => "ElasticSearch"
    host => "elasticsearch.server.com"
    port => 9300
    protocol => "node"
    manage_template => true
    template => "/etc/logstash/lib/logstash/outputs/elasticsearch/elasticsearch-template.json"
    index => "elb-%{log_timestamp}"
  }

}
4

2 回答 2

1

geo_ip 索引在我的情况下不起作用,因为我的索引名称没有以 logstash 开头-

如果您希望自定义索引名称获取地理 IP,则必须为该索引名称创建模板

在elasticsearch的输出中使用它

elasticsearch {
      manage_template => true
      template => "/etc/logstash/templates/custom_template.json"
}

你的模板应该是这样的

{
  "template" : "index_name-*",
  "settings" : {
  "index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
   "_all" : {"enabled" : true, "omit_norms" : true},
   "dynamic_templates" : [ {
     "message_field" : {
       "match" : "message",
       "match_mapping_type" : "string",
       "mapping" : {
         "type" : "string", "index" : "analyzed", "omit_norms" : true
       }
     }
   }, {
     "string_fields" : {
       "match" : "*",
       "match_mapping_type" : "string",
       "mapping" : {
         "type" : "string", "index" : "analyzed", "omit_norms" : true,
           "fields" : {
             "raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
           }
       }
     }
   } ],
   "properties" : {
     "@version": { "type": "string", "index": "not_analyzed" },
     "geoip"  : {
       "type" : "object",
         "dynamic": true,
         "properties" : {
           "location" : { "type" : "geo_point" }
         }
      }
   }
 }
}
}
于 2015-07-05T18:59:29.650 回答
0

在我们的地图上,我们指定了 geoip.location 字段,根据文档,该字段由 geoip 过滤器自动创建。

你能在发现中看到那个字段吗?如果没有,您可以尝试将您的 geoip 过滤器修改为

if [client_ip] {
  geoip {
     source => "client_ip"
     add_tag => [ "geoip" ]
     target => "geoip"
  }
}

看看您现在是否可以在新条目中看到 geoip.location?

在创建关联的 geoip 字段时,elasticsearch 模板会查找“geoip”目标。

创建 geoip.location 后,我们可以在 Kibana 4 中按照以下步骤创建新地图。

  1. 点击可视化
  2. Tile Map从可视化类型列表中选择“ ”
  3. 选择新搜索或已保存 - 我们正在使用过滤掉 Apache 条目的已保存搜索,但只要数据包含 geoip.location 就可以了
  4. 选择“ geo coordinates”存储桶类型 -此时您将标记一个错误
  5. 在“ aggregation”下拉列表中,选择“ geohash
  6. 在“ field”下拉列表中,选择“ geoip.location
于 2015-03-30T12:13:46.663 回答