logstash命令行参数详解

在上一节中我们已经对logstash做了简单的安装和测试,这一节我们来看一下logstash的启动命令
我们来看下logstash的启动参数有哪些吧,执行以下命令

[sqczm@sqczm logstash-6.7.1]$ pwd
/opt/logstash-6.7.1
[sqczm@sqczm logstash-6.7.1]$ bin/logstash -h
Usage:
    bin/logstash [OPTIONS]

Options:
    -n, --node.name NAME          Specify the name of this logstash instance, if no value is given
                                  it will default to the current hostname.
                                   (default: "sqczm")
    -f, --path.config CONFIG_PATH Load the logstash config from a specific file
                                  or directory.  If a directory is given, all
                                  files in that directory will be concatenated
                                  in lexicographical order and then parsed as a
                                  single config file. You can also specify
                                  wildcards (globs) and any matched files will
                                  be loaded in the order described above.
    -e, --config.string CONFIG_STRING Use the given string as the configuration
                                  data. Same syntax as the config file. If no
                                  input is specified, then the following is
                                  used as the default input:
                                  "input { stdin { type => stdin } }"
                                  and if no output is specified, then the
                                  following is used as the default output:
                                  "output { stdout { codec => rubydebug } }"
                                  If you wish to use both defaults, please use
                                  the empty string for the '-e' flag.
                                   (default: nil)
    --field-reference-parser MODE Use the given MODE when parsing field
                                  references.
                                  
                                  The field reference parser is used to expand
                                  field references in your pipeline configs,
                                  and will be becoming more strict to better
                                  handle illegal and ambbiguous inputs in a
                                  future release of Logstash.
                                  
                                  Available MODEs are:
                                   - `LEGACY`: parse with the legacy parser,
                                     which is known to handle ambiguous- and
                                     illegal-syntax in surprising ways;
                                     warnings will not be emitted.
                                   - `COMPAT`: warn once for each distinct
                                     ambiguous- or illegal-syntax input, but
                                     continue to expand field references with
                                     the legacy parser.
                                   - `STRICT`: parse in a strict manner; when
                                     given ambiguous- or illegal-syntax input,
                                     raises a runtime exception that should
                                     be handled by the calling plugin.
                                  
                                   The MODE can also be set with
                                   `config.field_reference.parser`
                                  
                                   (default: "COMPAT")
    --modules MODULES             Load Logstash modules.
                                  Modules can be defined using multiple instances
                                  '--modules module1 --modules module2',
                                     or comma-separated syntax
                                  '--modules=module1,module2'
                                  Cannot be used in conjunction with '-e' or '-f'
                                  Use of '--modules' will override modules declared
                                  in the 'logstash.yml' file.
    -M, --modules.variable MODULES_VARIABLE Load variables for module template.
                                  Multiple instances of '-M' or
                                  '--modules.variable' are supported.
                                  Ignored if '--modules' flag is not used.
                                  Should be in the format of
                                  '-M "MODULE_NAME.var.PLUGIN_TYPE.PLUGIN_NAME.VARIABLE_NAME=VALUE"'
                                  as in
                                  '-M "example.var.filter.mutate.fieldname=fieldvalue"'
    --setup                       Load index template into Elasticsearch, and saved searches, 
                                  index-pattern, visualizations, and dashboards into Kibana when
                                  running modules.
                                   (default: false)
    --cloud.id CLOUD_ID           Sets the elasticsearch and kibana host settings for
                                  module connections in Elastic Cloud.
                                  Your Elastic Cloud User interface or the Cloud support
                                  team should provide this.
                                  Add an optional label prefix '

接下来简单对命令行的参数做个说明,因每个参数的后面都有英文介绍,介绍的都很详细,所以我只列出我认为常用的或后续要用到几个参数。

  1. -n
    logstash实例的名称,如果不设置默认为当前的主机名(比如我的主机名为sqczm)。

  2. -f
    配置文件,我们可以指定一个特定的文件,也可以指定一个特定的目录,如果指定的是特定的目录,则logstash会读取该目录下的所有文本文件,将其在内存中拼接成完整的大配置文件,再去执行。

  3. -e
    给定的可直接执行的配置内容,也就是说我们可以不指定-f参数,直接把配置文件中的内容作为字符串放到-e参数后面。

  4. -w
    指定工作线程的个数

  5. -p
    logstash用来加载插件的目录

  6. -l
    日志输出文件,如果不设置,logstash将会把日志发送至标准的output

  7. -t
    检查配置的语法是否正确并退出

  8. -r
    监视配置文件的变化,并且自动重新加载修改后的配置文件

  9. –config.reload.interval RELOAD_INTERVAL
    为了检查配置文件是否改变,而去拉取配置文件的频率

  10. –http.host HTTP_HOST
    Web API绑定的主机,默认为“127.0.0.1”

  11. –http.port HTTP_PORT
    Web API绑定的端口,默认为9600-9700之间

  12. –log.format FORMAT
    logstash写它自身日志的时候使用json还是文本格式,默认是“plain”

  13. –path.settings SETTINGS_DIR
    设置包含logstash.yml配置文件的目录,比如log4j日志配置。也可以设置LS_SETTINGS_DIR环境变量

你可能感兴趣的:(Logstash)