ELK Packetbeat 协议和进程配置项(16th)


Packetbeat 协议部分包含支持每个协议的配置项,如ports, send_request, send_response 和 特定的协议选项。

目前Packetbeat支持以下协议:

  • DNS
  • HTTP
  • Mysql
  • PostgreSQL
  • Redis
  • Thrift-RPC
  • MongoDB
  • Memcache

配置如下:

protocols:  dns:    ports: [53]  http:    ports: [80, 8080, 8000, 5000, 8002]  memcache:    ports: [11211]  mysql:    ports: [3306]  redis:    ports: [6379]  pgsql:    ports: [5432]  thrift:    ports: [9090]

通用协议选项

下面的选项可用于所有协议:

ports

Packetbeat以该端口捕获具体协议流量。 Packetbeat 基于这个端口安装一个BPF过滤器。如果数据包不匹配该过滤器直接丢弃。Packetbeat还使用该端口以确定每个数据包使用哪个分析器解析。

send_request

如果启用了,请求的信息(request字段)将发送到elasticsearch。默认是 false。 如果想索引整个请求该选项要启用。注意对于HTTP,请求体默认不包含,仅仅是HTTP头部。

send_response

如果启用了,响应的信息(response字段)将发送到elasticsearch。默认是 false。 如果想索引整个请求该选项要启用。注意对于HTTP,请求体默认不包含,仅仅是HTTP头部。

如下图

transaction_timeout

每个协议事务超时时间。过期事务将不再关联输入响应,但是立即发送到elasticsearch。

DNS配置选项

配置实例如下:

protocols:  dns:    ports: [53]    # include_authorities controls whether or not the dns.authorities field    # (authority resource records) is added to messages.    # Default: false    include_authorities: true    # include_additionals controls whether or not the dns.additionals field    # (additional resource records) is added to messages.    # Default: false    include_additionals: true

include_authorities

如果启用, dns.authority 字段 (权威资源记录) 将加入到DNS 事件。默认false。

include_additionals

如果启用,dns.additionals字段 (额外资源记录) 将加入到DNS 事件。默认false。

HTTP 配置选项

配置实例如下:用的最多是这个,注意看

protocols:  http:    # Configure the ports where to listen for HTTP traffic. You can disable    # the http protocol by commenting the list of ports.    ports: [80, 8080, 8000, 5000, 8002]    # Uncomment the following to hide certain parameters in URL or forms attached    # to HTTP requests. The names of the parameters are case insensitive.    # The value of the parameters will be replaced with the 'xxxxx' string.    # This is generally useful for avoiding storing user passwords or other    # sensitive information.    hide_keywords: ["pass", "password", "passwd"]    # Uncomment the following to export a list of extra HTTP headers. By    default is none sent.    send_headers: ["User-Agent", "Cookie", "Set-Cookie"]    # Uncomment the following to export Cookie or Set-Cookie headers. By    # default is false.    split_coookie: true    # Configure the HTTP header that contains the real IP address.    real_ip_header: "X-Forwarded-For"

hide_keywords

查询参数列表,Packetbeat将自动审查已存的事务。与这些参数相关的值将被替代成 'xxxxx'。默认情况下,是不会更改HTTP信息的。

Packetbeat 有这个选项,是因为不同于 SQL 流量只含有密码的hash值,HTTP 流量可能包含敏感的数据。为了降低安全风险,可配置此选项避免HTTP POST发送特定的参数。

redact_authorization

当启用该选项, Packetbeat 隐藏  Authorization值和 Proxy-Authorization HTTP头部,并检查响应的字符串。

如果使用Basic Authentication验证,应该启用该选,因为可能包含base64未加密的用户名和密码。

send_headers

捕获一系列头部名并发送到 Elasticsearch。这些头部以json格式放在headers字典里。

send_all_headers

发送头部白名单到 Elasticsearch,如果要发送所有头部,该选项设置为TRUE。默认是false。

include_body_for

列出内容类型列表,Packetbeat 将在response字段包含完整的HTTP有效载荷。该选项要和send_response选项一起使用。

如:

protocols:  http:    ports: [80, 8080]    send_response: true    include_body_for: ["text/html"]

如果Cookie 或者 Set-Cookie 头部被发送, 该选项控制是否把它们分割成独自值。默认false。例如,设置了该选项, HTTP 响应将成下面的json格式结果:

"response": {  "code": 200,  "headers": {    "connection": "close",    "content-language": "en",    "content-type": "text/html; charset=utf-8",    "date": "Fri, 21 Nov 2014 17:07:34 GMT",    "server": "gunicorn/19.1.1",    "set-cookie": {       "csrftoken": "S9ZuJF8mvIMT5CL4T1Xqn32wkA6ZSeyf",      "expires": "Fri, 20-Nov-2015 17:07:34 GMT",      "max-age": "31449600",      "path": "/"    },    "vary": "Cookie, Accept-Language"  },  "phrase": "OK"}

real_ip_header

提取真实IP地址。该信息用于 real_ip 和 client_location 索引字段。

Memcache 配置选项

实例如下:

memcache:    ports: [11211]    parseunknown: false    maxvalues: 0    maxbytespervalue: 100    transaction_timeout: 200    udptransactiontimeout: 200

parseunknown

当启用该选项,迫使memcache文本协议分析器接受未知的命令。

maxvalues

信息(multi-get)存储值的最大数量。所有值base64编码。可能值如下:

  • maxvalue: -1, 存储所有值 (基于文本协议 multi-get)
  • maxvalue: 0, 不存储值 (默认)
  • maxvalue: N, 最多可存 N 值

maxbytespervalue

复制每个值元素的最大字节数。值以base64编码,因此JSON文档中的实际大小将是maxbytespervalue的4倍。

udptransactiontimeout

事务的超时时间。默认 10000 毫秒。

MySQL 和 PgSQL 配置选项

max_rows

发送到elasticsearch的SQL信息的最大行数。默认10行。

max_row_length

发送到elasticsearch的SQL信息的最大字节。默认1024 字节。

Thrift 配置选项

socket用的比较多,注意看。

实例如下:

thrift:    transport_type: socket    protocol_type: binary    idl_files: ["tutorial.thrift", "shared.thrift"]    string_max_size: 200    collection_max_size: 20    capture_reply: true    obfuscate_strings: true    drop_after_n_struct_fields: 100

transport_type

Thrift 传输类型。 默认是 socket。

protocol_type

Thrift 协议类型。 只接受二进制的TBinary协议, 这是默认的Thrift 协议。

idl_files

Thrift 接口描述语言 (IDL)文件,Packetbeat 所监控的。 可选的,因为Thrift信息包含足够的信息去解码而无需IDL文件。 然而,提供 IDL使 Packetbeat 可包含参数和异常名字。

string_max_size

参数或返回值的字符串最大长度。如果超过该值,将会被自动截断,Packetbeat在字符串后面加上个点,标示被截断。默认200。

collection_max_size

Thrift list, set, map 或者 structure 最大元素个数。如果超过这个值,Packetbeat只捕获指定元素的个数。 Packetbeat 在集合后面添加一个虚拟的元素... 标明被截断。默认15。

capture_reply

如果设置为false, Packetbeat 解码来自应答的方法名称,对剩余的响应信息简单的跳过。该选项对性能、磁盘使用情况或者数据保留很有用。默认TRUE。

obfuscate_strings

如果设置为TRUE, Packetbeat 将以"*"字符串取代方法参数、返回码或者异常结构发现的字符串。

drop_after_n_struct_fields

Packetbeat忽略整个事务前,可保留的最大字段数。这是个内存保护机制,不至于Packetbeat内存无限增长。因此通常设置为一个相对高的值。默认500。

MongoDB 配置选项

用的也比较多,注意看

实例如下:

mongodb:    send_request: true    send_response: true    max_docs: 0    max_doc_length: 0

下面两个设置用于限制Packetbeat索引中的response字段的数据量。

max_docs

响应索引中的response字段最大的文档数。默认10。 可以设置为0,不限制文档数。

Packetbeat 在最后添加 [...] 一行标明未保存其它文档,是因为该设置。

max_doc_length

单个文档索引中的response字段的最大字符数。默认5000。 可以设置为0不限制。

如果因为该设置文档被修剪,Packetbeat在文档末尾添加... 字符串以标示。

注意,以该方式限制文档意味着它们将不再是正确的json格式对象了。

维护网络拓扑的实时状态

Packetbeat知道每个事务的源服务器和目标服务器的名称。这个之前说过的,会维护主机名、ip映射的。不清楚的看前面文章。

Packetbeat存储拓扑信息到elasticsearch索引。要保持网络拓扑,使用elasticsearch作为输出,并设置save_topology为TRUE。

进程 (可选)

可选的。捕获进程的通讯包。默认情况下,进程匹配是禁用的。只支持Linux系统。

procs:  enabled: true  monitored:    - process: mysqld      cmdline_grep: mysqld    - process: pgsql      cmdline_grep: postgres    - process: nginx      cmdline_grep: nginx    - process: app      cmdline_grep: gunicorn

process

指定进程名称,可随意定义以便可识。

cmdline_grep

该名字用于识别正在运行的进程名。定期扫描进程表与之匹配,一旦匹配从 /proc/<pid>/cmdline读取信息。

Log4j漏洞威胁升级:非联网本地系统也存在被攻击风险

在过去的一周时间里,对于 IT 管理员来说无疑是非常忙碌的,他们正在争分夺秒地应对影响世界各地系统的 Log4j 漏洞。随着安全专家不断发现日志工具中的更多漏洞,IT 管理员不知疲倦地工作,以确定和关闭任何可能使漏洞被利用的潜在访问。不幸的是,一个新发现的载体...
漏洞服务器安全网络安全log4j网络攻击

Cisco网络防火墙配置方法

由于网络防火墙默认禁止所有的通信,因为,只有对其进行适当配置后,才能实现正常的网络通信。1.进入全局配置模式ciscoasa# configure terminal2.选择欲作为网络防火墙外部接口的网络接口ciscoasa(config)# interface...
服务器安全网络防火墙cisco

新装的Ubuntu 14.04 LTS系统需要做的5件事

Ubuntu 14.04 LTS是最新的Ubuntu长期支持版本,拥有多项改进并添加了新版本软件。如果你已升级至Ubuntu 14.04,在体验新版本的同时还需要知道5件事。1、禁用集成的Amazon搜索Ubuntu Dash集成了Amazon搜索结果,当你在...
ubuntuLTS

最新DataGrip2020.2.x破解版激活码的步骤详解(支持Mac/Windows/Linux)

datagrip是数据库管理工具,操作数据库非常方便!本教程提供了datagrip2020激活码、datagrip2020破解版和datagrip2020安装包,可以完美激活和破解所有2020版本(2020.2/2020 . 2 . 1/2020 . 2 . ...
数据库技术DataGripdatagrip激活码datagrip破解版