如果需要对IIS日志进行分析可以使用logstash从文件中抓取出来进行分析;

输入部分:

input {
file {
type => "iis_log_monitor"
path => ["D:/k/iislog/monitor*/W3SVC4/*.log"]
start_position => "beginning"
sincedb_path => "../config-demo/log/iis_log_monitor.log"
sincedb_write_interval => 5
discover_interval => 2
}
file {
type => "iis_log_weixin"
path => ["D:/k/iislog/weixin*/W3SVC18/*.log"]
start_position => "beginning"
sincedb_path => "../config-demo/log/iis_log_weixin.log"
sincedb_write_interval => 5
discover_interval => 2
}
file {
type => "iis_log_imagedas"
path => ["D:/k/iislog/imagedas/*.log"]
start_position => "beginning"
sincedb_path => "../config-demo/log/iis_log_imagedas.log"
sincedb_write_interval => 5
discover_interval => 2
}
}

input中可以支持多个数据源的。

筛选部分:

filter{if [message] =~ "^#" {
drop {}
}
grok {
match => ["message", "%{TIMESTAMP_ISO8601:log_timestamp} (%{IPORHOST:s-ip}|-) (%{WORD:cs-method}|-) %{NOTSPACE:cs-uri-stem} %{NOTSPACE:cs-uri-query} (%{NUMBER:s-port}|-) (%{WORD:cs-username}|-) (%{IPORHOST:c-ip}|-) %{NOTSPACE:cs-useragent} (%{NUMBER:sc-status}|-) (%{NUMBER:sc-substatus}|-) (%{NUMBER:sc-win32-status}|-) (%{NUMBER:time-taken}|-)"]
}
date {
match => [ "log_timestamp", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Asia/Shanghai"
}
useragent {
source=> "cs-useragent"
}
}

筛选的流程是:

  1. 删除以“#”开头的记录、
  2. 使用grok格式化日志
  3. 使用日志的时间作为logstash的@timestamp
  4. 解析出用户的ua信息

输出到es:

output{
# stdout{
# codec => rubydebug
# }
elasticsearch {
hosts => ["xxx.xxx.xxx.xxx:9200"]
index => "iislog"
document_type => "iisloginfo"
workers => 1
template => "../config-demo/templates/iislog.json"
template_name => "iislog"
template_overwrite => true
}
}

logstash 抓取IIS日志文件写入Elasticsearch的更多相关文章

  1. 【Azure 应用服务】App Service For Linux 如何在 Web 应用实例上住抓取网络日志

    问题描述 在App Service For Windows的环境中,我们可以通过ArmClient 工具发送POST请求在Web应用的实例中抓取网络日志,但是在App Service For Linu ...

  2. 【应用服务 App Service】App Service中抓取网络日志

    问题描述 众所周知,Azure App Service是一种PaaS服务,也就是说,IaaS层面的所有内容都由平台维护,所以使用App Service的我们根本无法触碰到远行程序的虚拟机(VM), 所 ...

  3. Iis 日志文件默认路径

    Iis 日志文件默认路径: C:\WINDOWS\system32\LogFiles

  4. python爬虫:抓取下载电影文件,合并ts文件为完整视频

    目标网站:https://www.88ys.cc/vod-play-id-58547-src-1-num-1.html 反贪风暴4 对电影进行分析 我们发现,电影是按片段一点点加载出来的,我们分别抓取 ...

  5. IIS日志文件清理

    如何清除IIS日志以释放空间 打开“我的电脑”发现10GB容量的C盘只剩余355MB“可用空间”,已经严重不够用.如下图: 如果服务器的管理员并没有在C盘存储大容量文件,而IIS中站点的访问量又非常大 ...

  6. 日志文件写入失败(permission denied)

    用过Laravel的小伙伴一开始安装完框架后可能都遇到过daily 日志文件写入失败的问题,接下来我们就来详细说下日志文件写入失败的原因以及对应的解决方案. 在讲这个问题之前可能需要简单介绍下Linu ...

  7. 定期删除IIS日志文件

    服务器中由于监控的需要会经常生成很多日志文件,比如IIS日志文件(C:\inetpub\logs\LogFiles),一个稍微有流量的网站,其日志每天可以达到上百兆,这些文件日积月累会严重的占用服务器 ...

  8. IIS日志文件越来越大导致C盘空间变小处理方法

    问题概述 C:\inetpub\logs\LogFiles\W3SVC文件夹越来越大,IIS日志会消耗大量的硬盘空间,有潜在写满整个硬盘空间的风险,为了解决这个问题很多用户会选择关闭日志,但显然IIS ...

  9. 【ELK】抓取AWS-ELB日志的logstash配置文件

    前言 ELK搭建没有难度,难的是logstash的配置文件,logstash主要分为三个部分,input,filter和output. input,输入源可选的输入源由很多,详情见ELK官网,这里我们 ...

随机推荐

  1. 获取各种编码(Unicode,UTF8等)的识别符

    下面是常用编码的识别符, 在 Delphi(2009) 中如何获取呢?Unicode: FF FE; BigEndianUnicode: FE FF; UTF8: EF BB BF var   bs: ...

  2. Java面试题和解答(二)

    1.字符流和字节流的区别,使用场景是什么,相关类有哪些 http://blog.csdn.net/zj8692286/article/details/126507312.线程安全的概念,实现线程安全的 ...

  3. C#基础加强(9)之对象序列化(二进制)

    介绍 对象序列化是将对象转换为二进制数据(字节流),反序列化是将二进制数据还原成对象.对象的非持久态的,不仅在程序重启.操作系统重启会造成对象的丢失,就是退出函数范围等都可能造成对象的消失,而序列化与 ...

  4. monent API详解

    参考链接:https://www.jianshu.com/p/9c10543420de

  5. 【Solution】MySQL 5.8 this is incompatible with sql_mode=only_full_group_by

    [42000][1055] Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colu ...

  6. 【Common】-NO.122.common.1 - pv、uv、ip,tps、qps、rps术语

    Style:Mac Series:Java Since:2018-09-10 End:2018-09-10 Total Hours:1 Degree Of Diffculty:5 Degree Of ...

  7. JS全选反选功能

    总选框:<input type="checkbox" class="all" name="all"> 子选框: <inpu ...

  8. 使用MyEclipse新建maven项目时报An internal error occurred during: "Retrieving archetypes:". GC overhead limit

    前几天在上手maven时,遇到了一个十分头疼的问题,我的myeclipse配置的是自己安装的插件 ,总是报 " An internal error occurred during: &quo ...

  9. CDI services--Scope(生命周期)&&EL.(Sp El)

    一.EL/SpEL 1.EL语言(CDI与表达式语言(EL)集成,允许在JavaServer Faces页面或JavaServer Pages页面中直接使用任何组件) 1)概述:EL是JSP内置的表达 ...

  10. PHP----------linux下安装opcache.

    1.首先查看是否安装了opcache扩展,使用php -m 命令查看安装的扩展(没有添加环境变量就使用:/usr/local/php/bin/php -m). 添加opcache扩展.(我自己封装的s ...