IIS 上的 logstash 和 x-forwarded-for
logstash and x-forwarded-for on IIS
我刚刚在 Windows 上构建了一个 ELK 服务器,所以我是这个过程的新手。我已通读文档,但在解析我的 IIS 高级日志时遇到问题,尤其是 x-forwarded-for 数据,因为我们在负载均衡器后面..
我的高级日志记录设置为输出这样的数据:
$date, $time, $s-ip, $cs-uri-stem, $cs-uri-query, $s-port, $cs-username, $c-ip, $X-Forwarded-For, $csUser-Agent, $cs-Referer, $sc-status, $sc-substatus, $sc-win32-status, $time-taken
我这样设置 logstash.conf:
input {
tcp {
host => "localhost"
type => "iis"
port => 5044
}
}
filter {
if [type] == "iis" {
grok {
match => {"message" => "%{TIMESTAMP_ISO8601:log_timestamp} %{IPORHOST:site} %{URIPATH:page} %{NOTSPACE:query_string} %{NUMBER:port} %{NOTSPACE:username} %{IPORHOST:client_host} %{NOTSPACE:useragent} %{NOTSPACE:referer} %{GREEDYDATA:response} %{NUMBER:httpStatusCode:int} %{NUMBER:scSubstatus:int} %{NUMBER:scwin32status:int} %{NUMBER:timeTakenMS:int}"}
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "iis"
document_type => "main"
}
}
我认为这不正确,因为我没有获取数据。我已经搜索了文档,但仍然遇到问题,并且不确定是否需要采取其他步骤,例如映射字段。
我目前正在使用来自一台服务器的 filebeat 将数据推送到我的 ELK 服务器。我不确定这是否也是最好的方法(也许是 nxlog?)。我们不想在客户端机器上安装 logstash。
有人可以帮我吗?将不胜感激!!
谢谢,
乔治
由于您使用的是 Filebeat,因此您需要使用 beats 输入而不是 tcp 输入。请参阅 how to setup Logstash for Beats.
上的文档
基本上您需要将您的 tcp 输入替换为:
input {
beats {
port => 5044
}
}
并在您的 Filebeat 配置文件中,将 document_type
设置为 iis
以便您的过滤条件匹配。
filebeat:
prospectors:
- paths:
- 'C:\path\to\your\iis\logs\*.log'
document_type: iis
我刚刚在 Windows 上构建了一个 ELK 服务器,所以我是这个过程的新手。我已通读文档,但在解析我的 IIS 高级日志时遇到问题,尤其是 x-forwarded-for 数据,因为我们在负载均衡器后面..
我的高级日志记录设置为输出这样的数据:
$date, $time, $s-ip, $cs-uri-stem, $cs-uri-query, $s-port, $cs-username, $c-ip, $X-Forwarded-For, $csUser-Agent, $cs-Referer, $sc-status, $sc-substatus, $sc-win32-status, $time-taken
我这样设置 logstash.conf:
input {
tcp {
host => "localhost"
type => "iis"
port => 5044
}
}
filter {
if [type] == "iis" {
grok {
match => {"message" => "%{TIMESTAMP_ISO8601:log_timestamp} %{IPORHOST:site} %{URIPATH:page} %{NOTSPACE:query_string} %{NUMBER:port} %{NOTSPACE:username} %{IPORHOST:client_host} %{NOTSPACE:useragent} %{NOTSPACE:referer} %{GREEDYDATA:response} %{NUMBER:httpStatusCode:int} %{NUMBER:scSubstatus:int} %{NUMBER:scwin32status:int} %{NUMBER:timeTakenMS:int}"}
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "iis"
document_type => "main"
}
}
我认为这不正确,因为我没有获取数据。我已经搜索了文档,但仍然遇到问题,并且不确定是否需要采取其他步骤,例如映射字段。
我目前正在使用来自一台服务器的 filebeat 将数据推送到我的 ELK 服务器。我不确定这是否也是最好的方法(也许是 nxlog?)。我们不想在客户端机器上安装 logstash。
有人可以帮我吗?将不胜感激!!
谢谢, 乔治
由于您使用的是 Filebeat,因此您需要使用 beats 输入而不是 tcp 输入。请参阅 how to setup Logstash for Beats.
上的文档基本上您需要将您的 tcp 输入替换为:
input {
beats {
port => 5044
}
}
并在您的 Filebeat 配置文件中,将 document_type
设置为 iis
以便您的过滤条件匹配。
filebeat:
prospectors:
- paths:
- 'C:\path\to\your\iis\logs\*.log'
document_type: iis