elasticsearchedit

Read from an Elasticsearch cluster, based on search query results. This is useful for replaying test logs, reindexing, etc.

Example:

input {
  # Read all documents from Elasticsearch matching the given query
  elasticsearch {
    host => "localhost"
    query => '{ "query": { "match": { "statuscode": 200 } } }'
  }
}

This would create an Elasticsearch query with the following format:

curl 'http://localhost:9200/logstash-*/_search?&scroll=1m&size=1000' -d '{
  "query": {
    "match": {
      "statuscode": 200
    }
  }
}'

 

Synopsisedit

This plugin supports the following configuration options:

Required configuration options:

elasticsearch {
}

Available configuration options:

Setting Input typeRequiredDefault value

add_field

hash

No

{}

ca_file

a valid filesystem path

No

codec

codec

No

"json"

docinfo

boolean

No

false

docinfo_fields

array

No

["_index", "_type", "_id"]

docinfo_target

string

No

"@metadata"

hosts

array

No

index

string

No

"logstash-*"

password

password

No

port

number

No

9200

query

string

No

"{\"query\": { \"match_all\": {} } }"

scan

boolean

No

true

scroll

string

No

"1m"

size

number

No

1000

ssl

boolean

No

false

tags

array

No

type

string

No

user

string

No

Detailsedit

 

add_fieldedit

  • Value type is hash
  • Default value is {}

Add a field to an event

ca_fileedit

  • Value type is path
  • There is no default value for this setting.

SSL Certificate Authority file

charset (DEPRECATED)edit

  • DEPRECATED WARNING: This configuration item is deprecated and may not be available in future versions. <li> Value type is string
  • There is no default value for this setting.

The character encoding used in this input. Examples include UTF-8 and cp1252

This setting is useful if your log files are in Latin-1 (aka cp1252) or in another character set other than UTF-8.

This only affects plain format logs since json is UTF-8 already.

codecedit

  • Value type is codec
  • Default value is "json"

The codec used for input data. Input codecs are a convenient method for decoding your data before it enters the input, without needing a separate filter in your Logstash pipeline.

debug (DEPRECATED)edit

  • DEPRECATED WARNING: This configuration item is deprecated and may not be available in future versions.
  • Value type is boolean
  • Default value is false

docinfoedit

  • Value type is boolean
  • Default value is false

If set, include Elasticsearch document information such as index, type, and the id in the event.

It might be important to note, with regards to metadata, that if you’re ingesting documents with the intent to re-index them (or just update them) that the action option in the elasticsearch output want’s to know how to handle those things. It can be dynamically assigned with a field added to the metadata.

Example

input {
  elasticsearch {
    host => "es.production.mysite.org"
    index => "mydata-2018.09.*"
    query => "*"
    size => 500
    scroll => "5m"
    docinfo => true
  }
}
output {
  elasticsearch {
    index => "copy-of-production.%{[@metadata][_index]}"
    document_type => "%{[@metadata][_type]}"
    document_id => "%{[@metadata][_id]}"
  }
}

docinfo_fieldsedit

  • Value type is array
  • Default value is ["_index", "_type", "_id"]

List of document metadata to move to the docinfo_target field To learn more about Elasticsearch metadata fields read http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_document_metadata.html

docinfo_targetedit

  • Value type is string
  • Default value is "@metadata"

Where to move the Elasticsearch document information by default we use the @metadata field.

format (DEPRECATED)edit

  • DEPRECATED WARNING: This configuration item is deprecated and may not be available in future versions.
  • Value can be any of: plain, json, json_event, msgpack_event
  • There is no default value for this setting.

The format of input data (plain, json, json_event)

hostsedit

  • Value type is array
  • There is no default value for this setting.

List of elasticsearch hosts to use for querying.

indexedit

  • Value type is string
  • Default value is "logstash-*"

The index or alias to search.

message_format (DEPRECATED)edit

  • DEPRECATED WARNING: This configuration item is deprecated and may not be available in future versions.
  • Value type is string
  • There is no default value for this setting.

If format is json, an event sprintf string to build what the display @message should be given (defaults to the raw JSON). sprintf format strings look like %{fieldname}

If format is json_event, ALL fields except for @type are expected to be present. Not receiving all fields will cause unexpected results.

passwordedit

  • Value type is password
  • There is no default value for this setting.

Basic Auth - password

portedit

  • Value type is number
  • Default value is 9200

The HTTP port of your Elasticsearch server’s REST interface.

queryedit

  • Value type is string
  • Default value is "{\"query\": { \"match_all\": {} } }"

The query to be executed.

scanedit

  • Value type is boolean
  • Default value is true

Enable the Elasticsearch "scan" search type. This will disable sorting but increase speed and performance.

scrolledit

  • Value type is string
  • Default value is "1m"

This parameter controls the keepalive time in seconds of the scrolling request and initiates the scrolling process. The timeout applies per round trip (i.e. between the previous scan scroll request, to the next).

sizeedit

  • Value type is number
  • Default value is 1000

This allows you to set the maximum number of hits returned per scroll.

ssledit

  • Value type is boolean
  • Default value is false

SSL

tagsedit

  • Value type is array
  • There is no default value for this setting.

Add any number of arbitrary tags to your event.

This can help with processing later.

typeedit

  • Value type is string
  • There is no default value for this setting.

Add a type field to all events handled by this input.

Types are used mainly for filter activation.

The type is stored as part of the event itself, so you can also use the type to search for it in Kibana.

If you try to set a type on an event that already has one (for example when you send an event from a shipper to an indexer) then a new input will not override the existing type. A type set at the shipper stays with that event for its life even when sent to another Logstash server.

useredit

  • Value type is string
  • There is no default value for this setting.

Basic Auth - username