当前位置: 首页 > 知识库问答 >
问题:

将我用filebeat上传的内容发送到索引

翟单弓
2023-03-14

我创建了一个索引映射,就像这样,现在我将使用filebeat向Elasticsearch发送一个json文件,如何确保配置我的filebeat。yml将信息发送到我刚刚创建的新索引映射?

索引映射:

PUT _template/packets
{
  "index_patterns": "packets-*",
  "mappings": {
    "pcap_file": {
      "dynamic": "false",
      "properties": {
        "timestamp": {
          "type": "date"
        },
        "layers": {
          "properties": {
            "frame": {
              "properties": {
                "frame_frame_len": {
                  "type": "long"
                },
                "frame_frame_protocols": {
                  "type": "keyword"
                }
              }
            },
            "ip": {
              "properties": {
                "ip_ip_src": {
                  "type": "ip"
                },
                "ip_ip_dst": {
                  "type": "ip"
                }
              }
            },
            "udp": {
              "properties": {
                "udp_udp_srcport": {
                  "type": "integer"
                },
                "udp_udp_dstport": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  }
}

我的音乐节拍。yml:

###################### Filebeat Configuration Example 
###################### #########################

# This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html

# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- input_type: log
  paths:
    - "/home/manuel/packets.json"
  document_type: "pcap_file"
  json.keys_under_root: true
processors:
 - drop_event:
     when:
       equals:
         index._type: "pcap_file"
enabled: false
# Change to true to enable this prospector configuration.
  # Paths that should be crawled and fetched. Glob based paths.
  # paths:
    #- /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*

  # Exclude lines. A list of regular expressions to match. It drops the lines that are
  # matching any regular expression from the list.
  #exclude_lines: ['^DBG']

  # Include lines. A list of regular expressions to match. It exports the lines that are
  # matching any regular expression from the list.
  #include_lines: ['^ERR', '^WARN']

  # Exclude files. A list of regular expressions to match. Filebeat drops the files that
  # are matching any regular expression from the list. By default, no files are dropped.
  #exclude_files: ['.gz$']

  # Optional additional fields. These fields can be freely picked
  # to add additional information to the crawled log files for filtering
  #fields:
  #  level: debug
  #  review: 1

  ### Multiline options

  # Mutiline can be used for log messages spanning multiple lines. This is common
  # for Java Stack Traces or C-Line Continuation

  # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  #multiline.pattern: ^\[

  # Defines if the pattern set under pattern should be negated or not. Default is false.
  #multiline.negate: false

  # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
  # that was (not) matched before or after or as long as a pattern is not matched based on negate.
  # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
  #multiline.match: after
#============================= Filebeat modules ===============================

filebeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 3
  #index.codec: best_compression
  #_source.enabled: false
setup.template.name: "packets-*"
setup.template.pattern: "packets-*"
#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging


#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here, or by using the `-setup` CLI flag or the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "https://this_is_hidden_and_changed_for_stackoverflow"

#============================= Elastic Cloud ==================================

# These settings simplify using filebeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
cloud.id: "this_is_hidden_and_changed_for_stackoverflow=="

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
cloud.auth: "elastic:this_is_hidden_and_changed_for_stackoverflow"

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["https://this_is_hidden_and_changed_for_stackoverflow"]
  index: "packets"
  template.enabled: false

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  username: "elastic"
  password: "this_is_hidden_and_changed_for_stackoverflow"
#----------------------------- Logstash output --------------------------------
#output.logstash:
  # The Logstash hosts
  #hosts: ["localhost:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

#================================ Logging =====================================

#设置日志级别。默认的日志级别是info.#可用的日志级别包括:错误、警告、信息、调试#日志。级别:调试

# At debug level, you can selectively enable logging only for some `components.`
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publish", "service".
#logging.selectors: ["*"]

#============================== Xpack Monitoring ===============================
# filebeat can export internal metrics to a central Elasticsearch monitoring
# cluster.  This requires xpack monitoring to be enabled in Elasticsearch.  The
# reporting is disabled by default.

# Set to true to enable the monitoring reporter.
#xpack.monitoring.enabled: false

# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well. Any setting that is not set is
# automatically inherited from the Elasticsearch output configuration, so if you
# have the Elasticsearch output configured, you can simply uncomment the
# following line.
#xpack.monitoring.elasticsearch:

我想确保我将用filebeat上传的内容,会正确提交到我之前设置的Elasticsearch映射中,非常感谢我的朋友

共有2个答案

荆钱明
2023-03-14

确保您的filebeat.yml中的模板名称与您在ES中创建的模板名称匹配。您发布的文件显示:

setup.template.name:"Packets-*"

请注意,该值以-*结尾。但是模板的名称是packets,没有-*。将该行更改为:

设置。样板名称:“数据包”

卫寒
2023-03-14

如果您可以直接从FileBeat写入ES,那么它是一个我不知道的功能。

我使用Logstash如下:

~/logs/*.log -> Filebeat --> LogStash --> ElasticSearch

在所有服务节点上安装FileBeat,在监控节点上安装Logstash,并让Logstash与ES对话。其更清晰的分离(Filebeat只将原始数据发送到主机/端口)和LogStash有很多解析功能(如果愿意,可以为数据编写转换),需要在ES中填充合理的索引。

你使用的是索引模板,对吗???(否则会在ES集群中浪费大量空间)

 类似资料:
  • 问题内容: 我有一个运行起来的logstash,它消耗了两个Rabbit队列并发送给elasticsearch。这是我的logstash.conf文件: 现在,我有了另一个队列,但是我想将其内容发送到另一个elasticsearch索引。我的问题是:我如何需要将特定条目重定向到特定索引?还是我需要另一个logstash实例? 提前致谢。 问题答案: 很好的开始。现在,您只需要“键入”每个输入,然后

  • 在我通过Windows 10上的“Windows子系统Linux 2”运行Ubuntu18.04的本地机器上,我运行的是Elastic 7.3、Kibana 7.3和Elastic 7.3 docker容器。 设置成功,Filebeat似乎可以正确监控容器。但是,Kibana没有显示任何日志。 安装程序 要设置Elastic和Kibana,我使用以下命令 在这两个命令之后,容器Kibana日志显示

  • 我是docker和所有这些日志记录的新手,所以可能我犯了一个stuipd错误,所以提前感谢您的帮助。我让麋鹿通过Dockerfile行运行docker容器(6.2.2): 在一个单独的容器中,我通过folling Dockerfile行安装并运行Filebeat: 我的Filebeat配置是: 正如你所看到的,我试图在elasticsearch中创建一个自定义索引,但现在我只是想先让默认索引正常工

  • 我正试图通过控制台将PDF上传到CloudSearch。添加文档时,无法有效搜索内容。控制台生成SDF格式的JSON,如下所示: 当我试图搜索文档内容时,上面可读的文本(PDF、目录)出现,但没有任何有用的文档内容。 我很惊讶地看到: 是而不是,并且 然后,我手工制作了自己的批处理XML文件,尝试同样的方法: 和 有没有可能让CloudSearch在不将PDF转换为文本文件的情况下搜索PDF的“有

  • 问题内容: 我有这样的日志: 我想把他们推到。我正在使用filebeat通过以下配置将数据发送到logstash: 现在使用以下配置,我想更改编解码器类型: 但是,我仍然以字符串格式获取日志: “ message”:“ {\” logId \“:\” 57aaf6c96224b \“,\” clientIp \“:\” 127.0.0.1 \“,\” time \“:\” 03:11:29 pm

  • 问题内容: 我制作了一个html5游戏(使用GameMaker),该游戏由index.html和一个文件夹“ html5game”组成,该文件夹包含游戏的依赖项- javascript代码和资源。问题在于资源非常丰富多样(声音,子画面等),客户需要它们全部发挥作用。 我正在寻找一种无需全部命名就可以全部发送邮件的方法。 我尝试了glob模块: 但是一旦完成,我就找不到使用res.sendFile(