kafka中的原始数据格式(1条数据)

{
    "body": {
        "cwd": "/home/test/",
        "monitor": {
            "proc_num": 2,
            "procs": [{
                "cmd": "",
                "cpu_usage_rate": 2.0,
                "mem_usage_rate": 3.0,
                "pid": 4976,
                "procname": "test-name"
            }, {
                "cmd": "/home/test2",
                "cpu_usage_rate": 5.0,
                "mem_usage_rate": 6.0,
                "pid": 4977,
                "procname": "test-name2"
            }],
            "timestamp": 1547124214814
        },
        "os_tag": "Linux",
        "system": {
            "connection": {
                "haddr": "00:50:56:B3:7E:7A",
                "ip": "192.168.21.80",
                "name": "ens160"
            },
            "cpu": ["Intel Xeon", "Intel Xeon", "Intel Xeon", "Intel Xeon"],
            "memory": {
                "swap_total": "7918841856",
                "total": "15600787456"
            },
            "uname": "Linux Linux 3.10.0-862.el7.x86_64 x86_64 x86_64",
            "vendor": "CentOS 7.5.1804"
        }
    },
    "meta": {
        "request_id": "3-14865"
    }
}

logstash处理后的数据格式(2条数据)

{
    "hostname": "test",
    "procs": {
      "mem_usage_rate": 2.0,
      "cpu_usage_rate": 3.0,
      "pid": 4976,
      "cmd": "",
      "procname": "test-name"
    },
    "@timestamp": "2019-01-11T02:08:57.225Z",
    "memory": {
      "total": "3975188480",
      "swap_total": "4177522688"
    },
    "connection": {
      "ip": "192.168.31.182",
      "name": "ens160",
      "haddr": "00:50:56:B3:7E:35"
    },
    "proc_num": 4
  }

{
    "hostname": "test",
    "procs": {
      "mem_usage_rate": 5.0,
      "cpu_usage_rate": 6.0,
      "pid": 4976,
      "cmd": "test",
      "procname": "test-name"
    },
    "connection": {
      "ip": "192.168.31.182",
      "name": "ens160",
      "haddr": "00:50:56:B3:7E:35"
    },
    "proc_num": 4
  }

logstash的配置

input {
    kafka {
        bootstrap_servers=> "192.168.31.92:9092,192.168.31.93:9092,192.168.31.94:9092"
        group_id => "test_group"
        topics =>"test_topic"
        auto_offset_reset => "earliest"
        type => "test_type"
        consumer_threads => 1
        codec => "json"
    }
}

filter{

    if !([body][monitor][procs]) {
        drop { }
    }

    mutate {
    remove_field => ["body[cwd]","body[os_tag]","body[system][filesystem]","body[system][cpu]","body[system][disk]",
    "body[system][has_docker]","body[system][if]","body[system][uname]","body[system][vendor]","meta","url","body[configuration]"]
  }

    date {
        match => ["body[monitor][timestamp]","UNIX_MS"]

        remove_field => ["body[monitor][timestamp]"]
    }

    mutate {
        add_field => {
            "client_id" => "%{params[client_id]}"
            "system" => "%{body[system]}"
            "monitor" => "%{body[monitor]}"
        }
        remove_field => ["body","params"]
    }

    json {
        source => "system"
        remove_field => ["system"]
    }

    json {
        source => "monitor"
        remove_field => ["monitor"]
    }

    if ([procs]) {
        split {
            field => "procs"
        }
    }
}

output {
    elasticsearch {
        hosts => ["192.168.21.80:9200"]
        index => "test_index"
        codec => "json"
    }
}

logstash split插件的使用(将一个事件拆分成多个事件)的更多相关文章

  1. 【jquery】【ztree】节点添加自定义按钮、编辑和删除事件改成自己定义事件

    setting添加 edit: { drag: { isCopy: false, isMove: true }, enable: true,//设置是否处于编辑状态 showRemoveBtn: sh ...

  2. 切割数组 - 将一个数组拆分成多个长度为n的数组

    有时候接口返回的数据很长,而前端显示需要分组显示这些数据,这个时候就需要将数组拆分: datas = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; var arrLen ...

  3. oracle将一个字段拆分成多个值 (regexp_substr函数)

    select regexp_substr(p.attributename, '[^,]+',1,level) c1from tablename p connect by level <= len ...

  4. mysql将一个表拆分成多个表(一)(转载)

    转载 直接根据数据量进行拆分 有一个5000条数据的表,要把它变成没1000条数据一个表的5等份. 假设:表名:xuesi 主键:kidxuesi共有5000条数据,kid从1到5000自动增长题目: ...

  5. Pycharm使用技巧:Split Vertically/Horizontally(垂直/水平拆分窗口)

    Split Vertically或者Split Horizontally可以把当前编辑窗口垂直或者水平拆分成两个. 使用: 在编辑窗口中打开你要展示的两个文件(如图中的  "郭靖" ...

  6. ElasticSearch7.3学习(三十二)----logstash三大插件(input、filter、output)及其综合示例

    1. Logstash输入插件 1.1 input介绍 logstash支持很多数据源,比如说file,http,jdbc,s3等等 图片上面只是一少部分.详情见网址:https://www.elas ...

  7. logstash过滤器插件filter详解及实例

    1.logstash过滤器插件filter 1.1.grok正则捕获 grok是一个十分强大的logstash filter插件,他可以通过正则解析任意文本,将非结构化日志数据弄成结构化和方便查询的结 ...

  8. [Swift]LeetCode842. 将数组拆分成斐波那契序列 | Split Array into Fibonacci Sequence

    Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like ...

  9. logstash常用插件解析

    官方地址:https://www.elastic.co/guide/en/logstash-versioned-plugins/current/index.html 配置文件写法: # 日志导入inp ...

随机推荐

  1. UCI 人口收入数据分析(python)

    一.项目介绍 UCI上有许多免费的数据集可以拿来练习,可以在下面的网站找寻 http://archive.ics.uci.edu/ml/datasets.html 这次我使用的是人口收入调查,里面会有 ...

  2. SpringBoot入门(一)

    1 简介 Spring Boot是快速搭建Spring工程的脚手架,简化配置与依赖关系(约定大于配置),让我们把精力集中在业务部分 2 简单入门事例 创建一个Hello World的Web工程 2.1 ...

  3. Scala实践8

    1.1继承类 使用extends关键字,在定义中给出子类需要而超类没有的字段和方法,或者重写超类的方法. class Person { var name = "zhangsan" ...

  4. 一个动态扩展表格控件列和行的 jQuery 插件

    一个动态扩展表格控件列和行的 jQuery 插件 不过这并不影响使用鸭! 看这里:https://github.com/zhuwansu/table-ext.js 一个简单的示范 html <t ...

  5. light题目讲解 7.25模拟赛T1

    心得:这一道题其实就是自己打暴力打出来的 没有想到正解真的就是暴力枚举 我的做法是这样的 就是枚举A字符串中长度为x的子串 看它是不是B串的子序列 接下来是我的绝望考试代码(100分AC) //lig ...

  6. 【UEFI】---关于BIOS,EIST和PState&CState和CPU主频变化得关系

    Intel处理器都支持Turbo和EIST,且一般情况下,各家厂商在BIOS中都会设置EIST和PState的开关,那么这些开关与CPU的频率的关系是什么呢?今天对此做个总结: 按照国际惯例,本次梳理 ...

  7. Redis常用命令详细介绍

    一.字符串 字符串键是Redis最基本的键值对类型,将一个单独的键和一个单独的值关联起来.通过字符串键,不仅可以存储和读取字符串,如果输入能被解释为整数和浮点数,还能执行自增或自减操作. 1.SET: ...

  8. Qt Installer Framework翻译(5-0)

    创建安装程序 创建离线和在线安装程序,需要执行以下步骤: 为可安装组件创建一个package文件夹.有关更多信息,请参见包文件夹章节. 在config文件夹中创建一个名为config.xml的配置文件 ...

  9. Elasticsearch系列---结构化搜索

    概要 结构化搜索针对日期.时间.数字等结构化数据的搜索,它们有自己的格式,我们可以对它们进行范围,比较大小等逻辑操作,这些逻辑操作得到的结果非黑即白,要么符合条件在结果集里,要么不符合条件在结果集之外 ...

  10. 创建模仿存储库 Making a Mock Repository 精通ASP-NET-MVC-5-弗瑞曼 Listing 7-5