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. 数字图像处理的Matlab实现(3)—灰度变换与空间滤波

    第3章 灰度变换与空间滤波(1) 3.1 简介 空间域指的是图像平面本身,这类方法是以对图像像素直接处理为基础的.本章主要讨论两种空间域处理方法:亮度(灰度)变换与空间滤波.后一种方法有时涉及到邻域处 ...

  2. C++ 11 snippets , 2

    <1>auto ,initializer_list<T>,auto指向函数指针的简易,和typdef 定义的类型执行函数指针有多复杂. #include <iostrea ...

  3. ansible 常见指令表

    Play 指令 说明 accelerate 开启加速模式 accelerate_ipv6 是否开启ipv6 accelerate_port 加速模式的端口 always_run   any_error ...

  4. Efuse--芯片存储

    1.Efuse是什么 Efuse类似于EEPROM,是一次性可编程存储器,在芯片出场之前会被写入信息,在一个芯片中,efuse的容量通常很小,一些芯片efuse只有128bit. 2.efuse的作用 ...

  5. centos6.8安装httpd后无法访问

    1.打开 httpd.conf 将里面的 #ServerName localhost:80 注释去掉 2.修改SELinux状态: 1)/usr/sbin/sestatus -v      ##如果S ...

  6. Linux内核之内存管理

    Linux内核之内存管理 Linux利用的是分段+分页单元把逻辑地址转换为物理地址; RAM的某些部分永久地分配给内核, 并用来存放内核代码以及静态内核数据结构; RAM的其余部分称动态内存(dyna ...

  7. 002_性能测试工具wrk安装与使用

    介绍 今天给大家介绍一款开源的性能测试工具 wrk,简单易用,没有Load Runner那么复杂,他和 apache benchmark(ab)同属于性能测试工具,但是比 ab 功能更加强大,并且可以 ...

  8. svn:Item ‘XXXXXX’ is out of date

    问题描述:     工作副本没有更新到最新版本 svn: 提交失败(细节如下): svn: 目录 "D:\develop\workspace\gxcjx\src\main\resources ...

  9. 如何在eclipse中对项目进行重新编译

    有时由于eclipse异常关闭,当我们重启Eclipse,在启动项目时,会报错,说:ClassNotFound类似的错误,引起这种问题的原因可能是由于,Eclipse异常关闭引起的. 解决:在一个项目 ...

  10. 【原创】运维基础之Docker(5)docker部署airflow

    部署方式:docker+airflow+mysql+LocalExecutor 使用airflow的docker镜像 https://hub.docker.com/r/puckel/docker-ai ...