- Logstash Reference: other versions:
- Logstash Introduction
- Getting Started with Logstash
- How Logstash Works
- Setting Up and Running Logstash
- Setting Up X-Pack
- Breaking changes
- Upgrading Logstash
- Configuring Logstash
- Data Resiliency
- Working with Filebeat Modules
- Transforming Data
- Deploying and Scaling Logstash
- Performance Tuning
- Monitoring Logstash
- Working with plugins
- Input plugins
- Beats input plugin
- Cloudwatch input plugin
- Couchdb_changes input plugin
- Dead_letter_queue input plugin
- Drupal_dblog input plugin
- Elasticsearch input plugin
- Eventlog output plugin
- Exec input plugin
- File input plugin
- Ganglia input plugin
- Gelf input plugin
- Gemfire input plugin
- Generator input plugin
- Github input plugin
- Google_pubsub input plugin
- Graphite input plugin
- Heartbeat input plugin
- heroku input plugin
- Http input plugin
- Http_poller input plugin
- Imap input plugin
- Irc input plugin
- Jdbc input plugin
- Jms input plugin
- Jmx input plugin
- Kafka input plugin
- Kinesis input plugin
- Log4j input plugin
- Lumberjack input plugin
- Meetup input plugin
- Pipe input plugin
- Puppet_facter input plugin
- Rabbitmq input plugin
- rackspace input plugin
- Redis input plugin
- Relp input plugin
- Rss input plugin
- S3 input plugin
- Salesforce input plugin
- Snmptrap input plugin
- Sqlite input plugin
- Sqs input plugin
- Stdin input plugin
- Stomp input plugin
- Syslog input plugin
- Tcp input plugin
- Twitter input plugin
- Udp input plugin
- Unix input plugin
- Varnishlog input plugin
- Websocket input plugin
- Wmi input plugin
- Xmpp input plugin
- Zenoss input plugin
- Zeromq input plugin
- Output plugins
- Boundary output plugin
- Circonus output plugin
- Cloudwatch output plugin
- Csv output plugin
- Datadog output plugin
- Datadog_metrics output plugin
- Elasticsearch output plugin
- Email output plugin
- Exec output plugin
- File output plugin
- Ganglia output plugin
- Gelf output plugin
- Google_bigquery output plugin
- Google_cloud_storage output plugin
- Graphite output plugin
- Graphtastic output plugin
- Hipchat output plugin
- Http output plugin
- Influxdb output plugin
- Irc output plugin
- Jira output plugin
- Jms output plugin
- Juggernaut output plugin
- Kafka output plugin
- Librato output plugin
- Loggly output plugin
- Lumberjack output plugin
- Metriccatcher output plugin
- Mongodb output plugin
- Nagios output plugin
- Nagios_nsca output plugin
- Newrelic output plugin
- Opentsdb output plugin
- Pagerduty output plugin
- Pipe output plugin
- Rabbitmq output plugin
- Rackspace output plugin
- Redis output plugin
- Redmine output plugin
- Riak output plugin
- Riemann output plugin
- S3 output plugin
- Sns output plugin
- Solr_http output plugin
- Sqs output plugin
- Statsd output plugin
- Stdout output plugin
- Stomp output plugin
- Syslog output plugin
- Tcp output plugin
- Udp output plugin
- Webhdfs output plugin
- Websocket output plugin
- Xmpp output plugin
- Zabbix output plugin
- Zeromq output plugin
- Filter plugins
- Aggregate filter plugin
- Alter filter plugin
- Anonymize filter plugin
- Cidr filter plugin
- Cipher filter plugin
- Clone filter plugin
- Collate filter plugin
- Csv filter plugin
- Date filter plugin
- De_dot filter plugin
- Dissect filter plugin
- Dns filter plugin
- Drop filter plugin
- Elapsed filter plugin
- Elasticsearch filter plugin
- Environment filter plugin
- Extractnumbers filter plugin
- Fingerprint filter plugin
- Geoip filter plugin
- Grok filter plugin
- I18n filter plugin
- Jdbc_streaming filter plugin
- Json filter plugin
- Json_encode filter plugin
- Kv filter plugin
- Metaevent filter plugin
- Metricize filter plugin
- Metrics filter plugin
- Mutate filter plugin
- Oui filter plugin
- Prune filter plugin
- Punct filter plugin
- Range filter plugin
- Ruby filter plugin
- Sleep filter plugin
- Split filter plugin
- Syslog_pri filter plugin
- Throttle filter plugin
- Tld filter plugin
- Translate filter plugin
- Truncate filter plugin
- Urldecode filter plugin
- Useragent filter plugin
- Uuid filter plugin
- Xml filter plugin
- Yaml filter plugin
- Zeromq filter plugin
- Codec plugins
- Avro codec plugin
- Cef codec plugin
- Cloudfront codec plugin
- Cloudtrail codec plugin
- Collectd codec plugin
- Compress_spooler codec plugin
- Dots codec plugin
- Edn codec plugin
- Edn_lines codec plugin
- Es_bulk codec plugin
- Fluent codec plugin
- Graphite codec plugin
- Gzip_lines codec plugin
- Json codec plugin
- Json_lines codec plugin
- Line codec plugin
- Msgpack codec plugin
- Multiline codec plugin
- Netflow codec plugin
- Nmap codec plugin
- Oldlogstashjson codec plugin
- Plain codec plugin
- Protobuf codec plugin
- Rubydebug codec plugin
- Contributing to Logstash
- How to write a Logstash input plugin
- How to write a Logstash input plugin
- How to write a Logstash codec plugin
- How to write a Logstash filter plugin
- Contributing a Patch to a Logstash Plugin
- Logstash Plugins Community Maintainer Guide
- Submitting your plugin to RubyGems.org and the logstash-plugins repository
- Glossary of Terms
- Release Notes
Kv filter plugin
editKv filter plugin
edit- Plugin version: v4.0.1
- Released on: 2017-06-23
- Changelog
Getting Help
editFor questions about the plugin, open a topic in the Discuss forums. For bugs or feature requests, open an issue in Github. For the list of Elastic supported plugins, please consult the Elastic Support Matrix.
Description
editThis filter helps automatically parse messages (or specific event fields)
which are of the foo=bar
variety.
For example, if you have a log message which contains ip=1.2.3.4
error=REFUSED
, you can parse those automatically by configuring:
filter { kv { } }
The above will result in a message of ip=1.2.3.4 error=REFUSED
having
the fields:
-
ip: 1.2.3.4
-
error: REFUSED
This is great for postfix, iptables, and other types of logs that
tend towards key=value
syntax.
You can configure any arbitrary strings to split your data on,
in case your data is not structured using =
signs and whitespace.
For example, this filter can also be used to parse query parameters like
foo=bar&baz=fizz
by setting the field_split
parameter to &
.
Kv Filter Configuration Options
editThis plugin supports the following configuration options plus the Common Options described later.
Setting | Input type | Required |
---|---|---|
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
string, one of |
No |
|
string, one of |
No |
|
No |
||
No |
||
No |
Also see Common Options for a list of options supported by all filter plugins.
allow_duplicate_values
edit- Value type is boolean
-
Default value is
true
A bool option for removing duplicate key/value pairs. When set to false, only one unique key/value pair will be preserved.
For example, consider a source like from=me from=me
. [from]
will map to
an Array with two elements: ["me", "me"]
. To only keep unique key/value pairs,
you could use this configuration:
filter { kv { allow_duplicate_values => false } }
default_keys
edit- Value type is hash
-
Default value is
{}
A hash specifying the default keys and their values which should be added to the event in case these keys do not exist in the source field being parsed.
filter { kv { default_keys => [ "from", "logstash@example.com", "to", "default@dev.null" ] } }
exclude_keys
edit- Value type is array
-
Default value is
[]
An array specifying the parsed keys which should not be added to the event. By default no keys will be excluded.
For example, consider a source like Hey, from=<abc>, to=def foo=bar
.
To exclude from
and to
, but retain the foo
key, you could use this configuration:
filter { kv { exclude_keys => [ "from", "to" ] } }
field_split
edit- Value type is string
-
Default value is
" "
A string of characters to use as delimiters for parsing out key-value pairs.
These characters form a regex character class and thus you must escape special regex
characters like [
or ]
using \
.
Example with URL Query Strings
For example, to split out the args from a url query string such as
?pin=12345~0&d=123&e=foo@bar.com&oq=bobo&ss=12345
:
filter { kv { field_split => "&?" } }
The above splits on both &
and ?
characters, giving you the following
fields:
-
pin: 12345~0
-
d: 123
-
e: foo@bar.com
-
oq: bobo
-
ss: 12345
include_brackets
edit- Value type is boolean
-
Default value is
true
A boolean specifying whether to treat square brackets, angle brackets, and parentheses as value "wrappers" that should be removed from the value.
filter { kv { include_brackets => true } }
For example, the result of this line:
bracketsone=(hello world) bracketstwo=[hello world] bracketsthree=<hello world>
will be:
- bracketsone: hello world
- bracketstwo: hello world
- bracketsthree: hello world
instead of:
- bracketsone: (hello
- bracketstwo: [hello
- bracketsthree: <hello
include_keys
edit- Value type is array
-
Default value is
[]
An array specifying the parsed keys which should be added to the event. By default all keys will be added.
For example, consider a source like Hey, from=<abc>, to=def foo=bar
.
To include from
and to
, but exclude the foo
key, you could use this configuration:
filter { kv { include_keys => [ "from", "to" ] } }
prefix
edit- Value type is string
-
Default value is
""
A string to prepend to all of the extracted keys.
For example, to prepend arg_ to all keys:
filter { kv { prefix => "arg_" } }
recursive
edit- Value type is boolean
-
Default value is
false
A boolean specifying whether to drill down into values and recursively get more key-value pairs from it. The extra key-value pairs will be stored as subkeys of the root key.
Default is not to recursive values.
filter { kv { recursive => "true" } }
remove_char_key
edit- Value type is string
- There is no default value for this setting.
A string of characters to remove from the key.
These characters form a regex character class and thus you must escape special regex
characters like [
or ]
using \
.
Contrary to trim option, all characters are removed from the key, whatever their position.
For example, to remove <
>
[
]
and ,
characters from keys:
filter { kv { remove_char_key => "<>\[\]," } }
remove_char_value
edit- Value type is string
- There is no default value for this setting.
A string of characters to remove from the value.
These characters form a regex character class and thus you must escape special regex
characters like [
or ]
using \
.
Contrary to trim option, all characters are removed from the value, whatever their position.
For example, to remove <
, >
, [
, ]
and ,
characters from values:
filter { kv { remove_char_value => "<>\[\]," } }
source
edit- Value type is string
-
Default value is
"message"
The field to perform key=value
searching on
For example, to process the not_the_message
field:
filter { kv { source => "not_the_message" } }
target
edit- Value type is string
- There is no default value for this setting.
The name of the container to put all of the key-value pairs into.
If this setting is omitted, fields will be written to the root of the event, as individual fields.
For example, to place all keys into the event field kv:
filter { kv { target => "kv" } }
transform_key
edit-
Value can be any of:
lowercase
,uppercase
,capitalize
- There is no default value for this setting.
Transform keys to lower case, upper case or capitals.
For example, to lowercase all keys:
filter { kv { transform_key => "lowercase" } }
transform_value
edit-
Value can be any of:
lowercase
,uppercase
,capitalize
- There is no default value for this setting.
Transform values to lower case, upper case or capitals.
For example, to capitalize all values:
filter { kv { transform_value => "capitalize" } }
trim_key
edit- Value type is string
- There is no default value for this setting.
A string of characters to trim from the key. This is useful if your keys are wrapped in brackets or start with space.
These characters form a regex character class and thus you must escape special regex
characters like [
or ]
using \
.
Only leading and trailing characters are trimed from the key.
For example, to trim <
>
[
]
and ,
characters from keys:
filter { kv { trim_key => "<>\[\]," } }
trim_value
edit- Value type is string
- There is no default value for this setting.
Constants used for transform check A string of characters to trim from the value. This is useful if your values are wrapped in brackets or are terminated with commas (like postfix logs).
These characters form a regex character class and thus you must escape special regex
characters like [
or ]
using \
.
Only leading and trailing characters are trimed from the value.
For example, to trim <
, >
, [
, ]
and ,
characters from values:
filter { kv { trim_value => "<>\[\]," } }
value_split
edit- Value type is string
-
Default value is
"="
A non-empty string of characters to use as delimiters for identifying key-value relations.
These characters form a regex character class and thus you must escape special regex
characters like [
or ]
using \
.
For example, to identify key-values such as
key1:value1 key2:value2
:
filter { kv { value_split => ":" } }
Common Options
editThe following configuration options are supported by all filter plugins:
Setting | Input type | Required |
---|---|---|
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
No |
add_field
edit- Value type is hash
-
Default value is
{}
If this filter is successful, add any arbitrary fields to this event.
Field names can be dynamic and include parts of the event using the %{field}
.
Example:
filter { PLUGIN_NAME { add_field => { "foo_%{somefield}" => "Hello world, from %{host}" } } }
# You can also add multiple fields at once: filter { PLUGIN_NAME { add_field => { "foo_%{somefield}" => "Hello world, from %{host}" "new_field" => "new_static_value" } } }
If the event has field "somefield" == "hello"
this filter, on success,
would add field foo_hello
if it is present, with the
value above and the %{host}
piece replaced with that value from the
event. The second example would also add a hardcoded field.
add_tag
edit- Value type is array
-
Default value is
[]
If this filter is successful, add arbitrary tags to the event.
Tags can be dynamic and include parts of the event using the %{field}
syntax.
Example:
filter { PLUGIN_NAME { add_tag => [ "foo_%{somefield}" ] } }
# You can also add multiple tags at once: filter { PLUGIN_NAME { add_tag => [ "foo_%{somefield}", "taggedy_tag"] } }
If the event has field "somefield" == "hello"
this filter, on success,
would add a tag foo_hello
(and the second example would of course add a taggedy_tag
tag).
enable_metric
edit- Value type is boolean
-
Default value is
true
Disable or enable metric logging for this specific plugin instance by default we record all the metrics we can, but you can disable metrics collection for a specific plugin.
id
edit- Value type is string
- There is no default value for this setting.
Add a unique ID
to the plugin instance, this ID
is used for tracking
information for a specific configuration of the plugin.
output { stdout { id => "ABC" } }
If you don’t explicitely set this variable Logstash will generate a unique name.
periodic_flush
edit- Value type is boolean
-
Default value is
false
Call the filter flush method at regular interval. Optional.
remove_field
edit- Value type is array
-
Default value is
[]
If this filter is successful, remove arbitrary fields from this event. Fields names can be dynamic and include parts of the event using the %{field} Example:
filter { PLUGIN_NAME { remove_field => [ "foo_%{somefield}" ] } }
# You can also remove multiple fields at once: filter { PLUGIN_NAME { remove_field => [ "foo_%{somefield}", "my_extraneous_field" ] } }
If the event has field "somefield" == "hello"
this filter, on success,
would remove the field with name foo_hello
if it is present. The second
example would remove an additional, non-dynamic field.
remove_tag
edit- Value type is array
-
Default value is
[]
If this filter is successful, remove arbitrary tags from the event.
Tags can be dynamic and include parts of the event using the %{field}
syntax.
Example:
filter { PLUGIN_NAME { remove_tag => [ "foo_%{somefield}" ] } }
# You can also remove multiple tags at once: filter { PLUGIN_NAME { remove_tag => [ "foo_%{somefield}", "sad_unwanted_tag"] } }
If the event has field "somefield" == "hello"
this filter, on success,
would remove the tag foo_hello
if it is present. The second example
would remove a sad, unwanted tag as well.
On this page
- Getting Help
- Description
- Kv Filter Configuration Options
allow_duplicate_values
default_keys
exclude_keys
field_split
include_brackets
include_keys
prefix
recursive
remove_char_key
remove_char_value
source
target
transform_key
transform_value
trim_key
trim_value
value_split
- Common Options
add_field
add_tag
enable_metric
id
periodic_flush
remove_field
remove_tag