http_polleredit

This Logstash input plugin allows you to call an HTTP API, decode the output of it into event(s), and send them on their merry way. The idea behind this plugins came from a need to read springboot metrics endpoint, instead of configuring jmx to monitor my java application memory/gc/ etc.

This plugin does not ship with Logstash by default, but it is easy to install by running bin/plugin install logstash-input-http_poller.

Exampleedit

Reads from a list of urls and decodes the body of the response with a codec. The config should look like this:

input {
  http_poller {
    urls => {
      test1 => "http://localhost:9200"
      test2 => {
        # Supports all options supported by ruby's Manticore HTTP client
        method => get
        url => "http://localhost:9200/_cluster/health"
        headers => {
          Accept => "application/json"
        }
        auth => {
          user => "AzureDiamond"
          password => "hunter2"
        }
      }
    }
    request_timeout => 60
    interval => 60
    codec => "json"
    # A hash of request metadata info (timing, response headers, etc.) will be sent here
    metadata_target => "http_poller_metadata"
  }
}

output {
  stdout {
    codec => rubydebug
  }
}

 

Synopsisedit

This plugin supports the following configuration options:

Required configuration options:

http_poller {
    interval => ...
    urls => ...
}

Available configuration options:

Setting Input type Required Default value

add_field

hash

No

{}

automatic_retries

number

No

0

cacert

a valid filesystem path

No

client_cert

a valid filesystem path

No

client_key

a valid filesystem path

No

codec

codec

No

"json"

connect_timeout

number

No

10

cookies

boolean

No

true

follow_redirects

boolean

No

true

interval

number

Yes

keepalive

boolean

No

true

metadata_target

string

No

"@metadata"

pool_max

number

No

50

pool_max_per_route

number

No

25

proxy

<<,>>

No

request_timeout

number

No

60

socket_timeout

number

No

10

tags

array

No

target

string

No

truststore

a valid filesystem path

No

truststore_password

password

No

truststore_type

string

No

"JKS"

type

string

No

urls

hash

Yes

Detailsedit

 

add_fieldedit

  • Value type is hash
  • Default value is {}

Add a field to an event

automatic_retriesedit

  • Value type is number
  • Default value is 0

How many times should the client retry a failing URL? Default is 0

cacertedit

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

If you need to use a custom X.509 CA (.pem certs) specify the path to that here

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.

client_certedit

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

If you’d like to use a client certificate (note, most people don’t want this) set the path to the x509 cert here

client_keyedit

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

If you’re using a client certificate specify the path to the encryption key here

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.

connect_timeoutedit

  • Value type is number
  • Default value is 10

Timeout (in seconds) to wait for a connection to be established. Default is 10s

cookiesedit

  • Value type is boolean
  • Default value is true

Enable cookie support. With this enabled the client will persist cookies across requests as a normal web browser would. Enabled by default

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

follow_redirectsedit

  • Value type is boolean
  • Default value is true

Should redirects be followed? Defaults to true

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)

intervaledit

  • This is a required setting.
  • Value type is number
  • There is no default value for this setting.

How often (in seconds) the urls will be called

keepaliveedit

  • Value type is boolean
  • Default value is true

Turn this on to enable HTTP keepalive support

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.

metadata_targetedit

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

If you’d like to work with the request/response metadata. Set this value to the name of the field you’d like to store a nested hash of metadata.

pool_maxedit

  • Value type is number
  • Default value is 50

Max number of concurrent connections. Defaults to 50

pool_max_per_routeedit

  • Value type is number
  • Default value is 25

Max number of concurrent connections to a single host. Defaults to 25

proxyedit

<li> Value type is <<string,string>>
* There is no default value for this setting.

If you’d like to use an HTTP proxy. This supports multiple configuration syntaxes:

  • Proxy host in form: http://proxy.org:1234
  • Proxy host in form: {host => "proxy.org", port => 80, scheme => 'http', user => 'username@host', password => 'password'}
  • Proxy host in form: {url => 'http://proxy.org:1234', user => 'username@host', password => 'password'}

request_timeoutedit

  • Value type is number
  • Default value is 60

Timeout (in seconds) for the entire request

socket_timeoutedit

  • Value type is number
  • Default value is 10

Timeout (in seconds) to wait for data on the socket. Default is 10s

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.

targetedit

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

Define the target field for placing the received data. If this setting is omitted, the data will be stored at the root (top level) of the event.

truststoreedit

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

If you need to use a custom keystore (.jks) specify that here

truststore_passwordedit

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

Specify the keystore password here. Note, most .jks files created with keytool require a password!

truststore_typeedit

  • Value type is string
  • Default value is "JKS"

Specify the keystore type here. One of JKS or PKCS12. Default is JKS

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.

urlsedit

  • This is a required setting.
  • Value type is hash
  • There is no default value for this setting.

A Hash of urls in this format : "name" => "url". The name and the url will be passed in the outputed event