0

我已导入 IIS 日志文件,数据已通过 Logstash (1.4.2) 移动到 ElasticSearch (1.3.1) 中,然后显示在 Kibana 中。

我的过滤器部分如下:

filter {
  grok {
     match => 
        ["message" , "%{TIMESTAMP_ISO8601:iisTimestamp} %{IP:serverIP} %{WORD:method} %{URIPATH:uri} - %{NUMBER:port} - %{IP:clientIP} - %{NUMBER:status} %{NUMBER:subStatus} %{NUMBER:win32Status} %{NUMBER:timeTaken}"]
  }
}

在 Kibana 中使用术语面板并使用“uri”(我从 Logstash 捕获的字段之一)时,它与 URI 中的令牌匹配。因此,它匹配以下项目:

  • '脚本'
  • '/'
  • 'EN

问:如何以完整形式显示“热门 URL”?

问:我如何通知 ElasticSearch 该字段是“not_analysed”。我不介意有 2 个字段,例如:

  • uri - 标记化的 URI
  • uri.raw - 完整的 URL。

这可以在 Logstash 端完成,还是需要在 ElasticSearch 中设置映射?


映射如下:

//http://localhost:9200/iislog-2014.10.09/_mapping?pretty

{
  "iislog-2014.10.09" : {
    "mappings" : {
      "iislogs" : {
        "properties" : {
          "@timestamp" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "@version" : {
            "type" : "string"
          },
          "clientIP" : {
            "type" : "string"
          },
          "device" : {
            "type" : "string"
          },
          "host" : {
            "type" : "string"
          },
          "id" : {
            "type" : "string"
          },
          "iisTimestamp" : {
            "type" : "string"
          },
          "logFilePath" : {
            "type" : "string"
          },
          "message" : {
            "type" : "string"
          },
          "method" : {
            "type" : "string"
          },
          "name" : {
            "type" : "string"
          },
          "os" : {
            "type" : "string"
          },
          "os_name" : {
            "type" : "string"
          },
          "port" : {
            "type" : "string"
          },
          "serverIP" : {
            "type" : "string"
          },
          "status" : {
            "type" : "string"
          },
          "subStatus" : {
            "type" : "string"
          },
          "tags" : {
            "type" : "string"
          },
          "timeTaken" : {
            "type" : "string"
          },
          "type" : {
            "type" : "string"
          },
          "uri" : {
            "type" : "string"
          },
          "win32Status" : {
            "type" : "string"
          }
        }
      }
    }
  }
}
4

2 回答 2

1

在您的 Elasticsearch 映射中:

url: {
  type: "string",
  index: "not_analyzed"
}
于 2014-10-14T09:55:03.580 回答
0

问题是iislog-不符合logstash-格式,因此没有选择模板:

我的索引格式是iislog-YYYY.MM.dd,这没有使用 Logstash 的开箱即用映射。使用logstash-索引格式时,Logstash 会为字符串创建 2 对字段。例如uri是:

  • uri(出现在 Kibana 中)
  • uri.raw(未出现在 Kibana 中)

请注意,uri.raw不会出现在 Kibana 中 - 但它是可查询的。

因此,使用替代索引的解决方案是:

  1. 不要打扰!使用默认的索引格式logstash-%{+YYYY.MM.dd}
  2. 在输入中添加“类型”以file帮助您在 Kibana 中过滤正确的日志(同时使用 logstash-索引格式)

    input { 
      file {
          type => "iislog"
          ....
      }
    }
    
  3. 根据类型在 Kibana 中应用过滤

或者

如果您真的确实想要不同的索引格式:

  1. 默认配置文件复制到一个新文件中,比如说iislog-template.json
  2. 像这样引用配置文件output ==> elasticsearch

    output {    
       elasticsearch_http {
          host => localhost
          template_name => "iislog-template.json"
          template => "<path to template>"
          index => "iislog-%{+YYYY.MM.dd}"   
       }
    }
    
于 2014-10-14T12:48:08.363 回答