http_poller

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.

Example

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
  }
}

 

Synopsis

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

1

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

keystore

a valid filesystem path

No

keystore_password

password

No

keystore_type

string

No

"JKS"

metadata_target

string

No

"@metadata"

pool_max

number

No

50

pool_max_per_route

number

No

25

proxy

<<,>>

No

request_timeout

number

No

60

retry_non_idempotent

boolean

No

false

socket_timeout

number

No

10

ssl_certificate_validation

boolean

No

true

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

validate_after_inactivity

number

No

200

Details

 

add_field

  • Value type is hash
  • Default value is {}

Add a field to an event

automatic_retries

  • Value type is number
  • Default value is 1

cacert

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

client_cert

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

client_key

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

codec

  • 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_timeout

  • Value type is number
  • Default value is 10

cookies

  • Value type is boolean
  • Default value is true

follow_redirects

  • Value type is boolean
  • Default value is true

interval

  • 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

keepalive

  • Value type is boolean
  • Default value is true

keystore

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

keystore_password

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

keystore_type

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

metadata_target

  • 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_max

  • Value type is number
  • Default value is 50

pool_max_per_route

  • Value type is number
  • Default value is 25

proxy

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

request_timeout

  • Value type is number
  • Default value is 60

retry_non_idempotent

  • Value type is boolean
  • Default value is false

socket_timeout

  • Value type is number
  • Default value is 10

ssl_certificate_validation

  • Value type is boolean
  • Default value is true

tags

  • 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.

target

  • 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.

truststore

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

truststore_password

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

truststore_type

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

type

  • 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.

urls

  • 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

validate_after_inactivity

  • Value type is number
  • Default value is 200