For other versions, see theVersioned plugin docs.
For 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.
This Logstash input plugin allows you to call an HTTP API, decode the output of it into event(s), andsend them on their merry way. The idea behind this plugins came from a need to read springbootmetrics endpoint, instead of configuring jmx to monitor my java application memory/gc/ etc.
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 user => "AzureDiamond" password => "hunter2" url => "http://localhost:9200/_cluster/health" headers => { Accept => "application/json" } } } request_timeout => 60 # Supports "cron", "every", "at" and "in" schedules by rufus scheduler schedule => { cron => "* * * * * UTC"} 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 }}
Using the HTTP poller with custom a custom CA or self signed cert.
If you have a self signed cert you will need to convert your server’s certificate to a valid# .jks
or .p12
file. An easy way to do it is to run the following one-liner, substituting your server’s URL for the placeholder MYURL
and MYPORT
.
openssl s_client -showcerts -connect MYURL:MYPORT </dev/null 2>/dev/null|openssl x509 -outform PEM > downloaded_cert.pem; keytool -import -alias test -file downloaded_cert.pem -keystore downloaded_truststore.jks
The above snippet will create two files downloaded_cert.pem
and downloaded_truststore.jks
. You will be prompted to set a password for the jks
file during this process. To configure logstash use a config like the one that follows.
http_poller { urls => { myurl => "https://myhostname:1234" } truststore => "/path/to/downloaded_truststore.jks" truststore_password => "mypassword" schedule => { cron => "* * * * * UTC"} }
This plugin supports the following configuration options plus the Common Options described later.
Setting | Input type | Required |
---|---|---|
no |
||
No |
||
No |
||
a valid filesystem path |
No |
|
a valid filesystem path |
No |
|
a valid filesystem path |
No |
|
No |
||
No |
||
No |
||
No |
||
a valid filesystem path |
No |
|
No |
||
No |
||
No |
||
No |
||
No |
||
<<,>> |
No |
|
No |
||
No |
||
Yes |
||
No |
||
No |
||
a valid filesystem path |
No |
|
No |
||
No |
||
Yes |
||
No |
Also see Common Options for a list of options supported by allinput plugins.
Username to use with HTTP authentication for ALL requests. Note that you can also set this per-URL.If you set this you must also set the password
option.
Password to be used in conjunction with the username for HTTP authentication.
1
How many times should the client retry a failing URL. We highly recommend NOT setting this valueto zero if keepalive is enabled. Some servers incorrectly end keepalives early requiring a retry!Note: if retry_non_idempotent
is set only GET, HEAD, PUT, DELETE, OPTIONS, and TRACE requests will be retried.
If you need to use a custom X.509 CA (.pem certs) specify the path to that here
If you’d like to use a client certificate (note, most people don’t want this) set the path to the x509 cert here
If you’re using a client certificate specify the path to the encryption key here
10
Timeout (in seconds) to wait for a connection to be established. Default is 10s
true
Enable cookie support. With this enabled the client will persist cookiesacross requests as a normal web browser would. Enabled by default
true
Should redirects be followed? Defaults to true
true
Turn this on to enable HTTP keepalive support. We highly recommend setting automatic_retries
to at leastone with this to fix interactions with broken keepalive implementations.
If you need to use a custom keystore (.jks
) specify that here. This does not work with .pem keys!
Specify the keystore password here.Note, most .jks files created with keytool require a password!
"JKS"
Specify the keystore type here. One of JKS
or PKCS12
. Default is JKS
"@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 nestedhash of metadata.
50
Max number of concurrent connections. Defaults to 50
25
Max number of concurrent connections to a single host. Defaults to 25
If you’d like to use an HTTP proxy . This supports multiple configuration syntaxes:
http://proxy.org:1234
{host => "proxy.org", port => 80, scheme => 'http', user => 'username@host', password => 'password'}
{url => 'http://proxy.org:1234', user => 'username@host', password => 'password'}
60
Timeout (in seconds) for the entire request.
false
If automatic_retries
is enabled this will cause non-idempotent HTTP verbs (such as POST) to be retried.
Schedule of when to periodically poll from the urlsFormat: A hash with + key: "cron" | "every" | "in" | "at" + value: stringExamples: a) { "every" ⇒ "1h" } b) { "cron" ⇒ "* * * * * UTC" }See: rufus/scheduler for details about different schedule options and value string format
10
Timeout (in seconds) to wait for data on the socket. Default is 10s
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.
If you need to use a custom truststore (.jks
) specify that here. This does not work with .pem certs!
Specify the truststore password here.Note, most .jks files created with keytool require a password!
"JKS"
Specify the truststore type here. One of JKS
or PKCS12
. Default is JKS
A Hash of urls in this format : "name" => "url"
.The name and the url will be passed in the outputed event
200
How long to wait before checking for a stale connection to determine if a keepalive request is needed.Consider setting this value lower than the default, possibly to 0, if you get connection errors regularly.
This client is based on Apache Commons' HTTP implementation. Here’s how theApacheCommons documentation describes this option: "Defines period of inactivity inmilliseconds after which persistent connections must be re-validated prior tobeing leased to the consumer. Non-positive value passed to this method disablesconnection validation. This check helps detect connections that have becomestale (half-closed) while kept inactive in the pool."
The following configuration options are supported by all input plugins:
"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.
true
Disable or enable metric logging for this specific plugin instanceby default we record all the metrics we can, but you can disable metrics collectionfor a specific plugin.
Add a unique ID
to the plugin configuration. If no ID is specified, Logstash will generate one.It is strongly recommended to set this ID in your configuration. This is particularly usefulwhen you have two or more plugins of the same type, for example, if you have 2 http_poller inputs.Adding a named ID in this case will help in monitoring Logstash when using the monitoring APIs.
input { http_poller { id => "my_plugin_id" }}
Add any number of arbitrary tags to your event.
This can help with processing later.
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 canalso use the type to search for it in Kibana.
If you try to set a type on an event that already has one (forexample when you send an event from a shipper to an indexer) thena new input will not override the existing type. A type set atthe shipper stays with that event for its life evenwhen sent to another Logstash server.