input {
kafka {
bootstrap_servers => "127.0.0.1:9092"
client_id => "log"
auto_offset_reset => "latest"
consumer_threads =>
decorate_events => true
topics => ["nginx_access_log_test"]
codec => "json"
type => "nginx_log"
}
} filter {
mutate {
gsub => ["message", "\\x22", '"']
gsub => ["message", "\\x09", '']
}
json {
source => "message"
remove_field=>["message","beat","@version"]
} ruby {
code => '
file = File.open("/usr/local/logstash/config/white.txt", "r")
text = file.read
file.close if !text.include?(event.get("request_uri")) then
event.set("es_flag","")
else
event.set("es_flag","")
end
'
}
} output {
if [es_flag] ==""
{
elasticsearch
{
hosts => "127.0.0.1:9200"
index => "nginx_access_log_test"
} }
else
{
elasticsearch
{
hosts => "127.0.0.1:9200"
index => "nginx_access_log_test2"
} }
stdout {
codec => rubydebug
}
}

复杂点的生产环境配置:

input{
kafka {
bootstrap_servers => "127.0.0.1:9092"
client_id => "nginxaccesslog"
auto_offset_reset => "latest"
consumer_threads =>
decorate_events => true
topics => ["nginx_access_log"]
codec => "json"
type => "nginx_log"
}
kafka {
bootstrap_servers => "127.0.0.1:9092"
client_id => "database"
auto_offset_reset => "latest"
consumer_threads =>
decorate_events => true
topics => ["dsideal_db"]
codec => "json"
type => "dsideal_db"
}
kafka {
bootstrap_servers => "127.0.0.1:9092"
client_id => "devops_real"
auto_offset_reset => "latest"
consumer_threads =>
decorate_events => true
topics => ["devopsrealinfo"]
codec => "json"
type => "devopsrealinfo"
}
kafka {
bootstrap_servers => "127.0.0.1:9092"
client_id => "devops_base"
auto_offset_reset => "latest"
consumer_threads =>
decorate_events => true
topics => ["devopsbaseinfo"]
codec => "json"
type => "devopsbaseinfo"
}
}
filter{
mutate {
gsub => ["message", "\\x22", '"']
gsub => ["message", "\\x09", '']
}
json {
source => "message"
remove_field=>["message","beat","@version","@timestamp"]
}
if [type] == "nginx_log" {
ruby {
code => '
file = File.open("/usr/local/logstash/config/white.txt", "r")
text = file.read
file.close if !text.include?(event.get("request_uri")) then
event.set("es_flag","")
else
event.set("es_flag","")
end '
}
} } output {
if [type] == "nginx_log" {
if [es_flag] =="" {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "nginx-access-log"
}
}
else {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "nginx-access-log-other"
}
}
}
if [type] == "dsideal_db" {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "%{table_name}"
document_id => "%{id}"
}
}
if [type] == "devopsbaseinfo" {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "devopsbaseinfo"
document_id => "%{id}"
}
}
if [type] == "devopsrealinfo" {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "devopsrealinfo"
}
}
}

logstash配置白名单决定去哪个index的更多相关文章

  1. servlet过滤器配置白名单、黑名单

    1.web.xml配置 <filter> <description>过滤是否登陆</description> <filter-name>encoding ...

  2. Confluence 6 配置白名单

    Confluence 管理员可以通过添加 URLs 到白名单选择出入的链接和使用 RSS 宏,HTML 包含宏和小工具中的内容. 如果一个内容被添加到 Confluence 系统中,但是这个 URLs ...

  3. ubuntu apache2.4.7配置白名单

    1.仅允许192.168.1.1访问,此处需要注意apache2.2和2.4版本之后白名单配置的方法是不一样的 <Directory /var/www/> Options FollowSy ...

  4. nginx配置白名单

    配置如下: http模块: http { include mime.types; default_type application/octet-stream; #log_format main '$r ...

  5. 【Azure Redis 缓存 Azure Cache For Redis】在创建高级层Redis(P1)集成虚拟网络(VNET)后,如何测试VNET中资源如何成功访问及配置白名单的效果

    当使用Azure Redis高级版时候,为了能更好的保护Redis的安全,启用了虚拟网路,把Redis集成在Azure中的虚拟网络,只能通过虚拟网络VENT中的资源进行访问,而公网是不可以访问的.但是 ...

  6. axios 封装 跨域 实现 (后端跨域配置白名单)

    1. 始vue化项目 vue init webpack deaxios # 使用脚手架创建项目 deaxios(项目名,随便取得) cd deaxios # 进入项目cnpm install npm ...

  7. nginx 配置白名单

    在http 模块 增加 geo $remote_addr $ip_whitelist{ default 0; include white_ip.conf; } 在location 模块 增加 (注意i ...

  8. mysql配置白名单

    1. 测试是否允许远程连接 $ telnet 192.168.1.8 3306 host 192.168.1.4 is not allowed to connect to this mysql ser ...

  9. xinetd黑/白名单配置教程(以telnet为例)

    对于诸如telnet等托管于xinetd的服务,当请求到来时由于是通过xinetd进行通知,所以可以直接在xinetd上配置白名单允许和拒绝哪些ip连接服务. 本文主要参考xinetd.conf的ma ...

随机推荐

  1. json文件解析

    场景 读取json文件,读取子域名扫描结果 实现 >>> import json >>> with open("C:\\Users\\Windows32\ ...

  2. 【转】实习小记-python 内置函数__eq__函数引发的探索

    [转]实习小记-python 内置函数__eq__函数引发的探索 乱写__eq__会发生啥?请看代码.. >>> class A: ... def __eq__(self, othe ...

  3. python zip文件压缩和解压

    压缩 import shutil zipOutputName = "1234" # 输出1234.zip fileType = "zip" # 文件类型zip ...

  4. Web QQ 协议 登录加密算法 —— VC++实现

    BOOL ToHexStr(const CHAR * lpStr, int nSrcLen, CHAR * lpHex, int nDestLen) { const CHAR cHexTable[]  ...

  5. unity提示can't add script解决办法

    1.脚本有误没有继承unity类. 2.类名文件名不一致. 3.内部逻辑代码有误.

  6. <TCP/IP>DHCP动态主机配置协议

    坚持是一种好习惯 大家都知道,为了上网我们是需要提交一些配置信息的,如IP地址,子网掩码,DNS服务器等,这些是一个主机能够在Internet上运行并给用户提供常用服务(比如web和Email)的基本 ...

  7. bootstrap简单使用布局、栅格系统、modal标签页等常用组件入门

    <!DOCTYPE html> <html> <head> <title>bootstrap</title> <!-- 引入boots ...

  8. zabbix-3.0.4添加对windows 2008r2的监控

    zabbix-3.0.4添加对windows 2008r2的监控 一.windows客户端的配置关闭windows防火墙或者开通10050和10051端口(1).关闭防火墙(不推荐直接关闭,测试可以这 ...

  9. docker里面运行jenkins详解

    需求:将jenkins运行在docker中 思路:1.安装docker,并启动docker 服务            2.下载jenkins的docker镜像,然后运行. 前提知识:1.dockde ...

  10. UVA 1395 MST

    给你一个图, 求一个生成树, 边权Max – Min 要最小,输出最小值, 不能构成生成树的 输出 -1: 思路: Keuksal 算法, 先排序边, 然后枚举 第一条边, 往后加入边, 直到有 n- ...