logstash-plugins / logstash-mixin-http_client Goto Github PK
View Code? Open in Web Editor NEWEasily include an HTTP client into your plugin
License: Apache License 2.0
Easily include an HTTP client into your plugin
License: Apache License 2.0
The httpclient library used by this mixin is very conservative when it comes to status code handling, that only does what MUST be done (not what MAY be done) according to the RFC7231.
According to this RFC, requests MAY be automatically redirected but caution should be taken for unsafe methods (safe: GET/HEAD/OPTIONS, unsafe: POST/PUT/DELETE/PATCH).
The existing setRedirectsEnabled flag will only redirect on safe methods, but it may be desirable to redirect on PUT/POST if the users so wishes, by having this behavior behind an "off-by-default" flag.
We should support disabling ssl cert validation, moved from: logstash-plugins/logstash-input-http_poller#32
Would be nice if users could just specify the path to the trusted CA and we just 'do the right thing' if it's PEM, PKCS12, or JKS format. Thoughts?
It makes sense that any user of this library would want to be able to use these helpers.
We should be able to use http proxy to pull data. With manticore client, it should be straightforward to pass proxy URL configs. See: https://github.com/cheald/manticore/blob/master/lib/manticore/client.rb#L11
We should also investigate if we can populate these settings using the HTTP_PROXY
environment variable or through JAVA_OPTS
Doing :validate => :password will wrap the value in an object which resists leaking the password secret by obscuring #to_s and #inspect calls.
Changes:
@truststore_password.value
to get the actual configured value.They just don't do anything. Putting user/password directly in the URL does work.
Fixed here: #2
It's unclear how the automatic_retries setting works, and if it applies to network failures, to non 200 status codes, or both (or neither).
Plugins using this mixin don't have visibility if requests are retried at all.
For example here's an endpoint that returns a 503 and doesn't seem to be retried:
/tmp/logstash-7.11.1
❯ echo 1 | bin/logstash -e "filter { http { url => 'http://httpstat.us/503' automatic_retries => 100 } }"
[..]
[2021-02-19T18:14:38,262][INFO ][logstash.javapipeline ][main] Pipeline started {"pipeline.id"=>"main"}
[2021-02-19T18:14:38,297][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2021-02-19T18:14:38,457][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
[2021-02-19T18:14:39,220][ERROR][logstash.filters.http ][main][bd532599e066920b19b659b8756ad4a5751741b31fc6994b60c993f22fc75bbc] error during HTTP request {:url=>"http://httpstat.us/503", :code=>503, :response=>""}
{
"tags" => [
[0] "_httprequestfailure"
],
"host" => "joaos-mbp.lan",
"message" => "1",
"type" => "stdin",
"@version" => "1",
"@timestamp" => 2021-02-19T18:14:38.288Z
}
[2021-02-19T18:14:39,405][INFO ][logstash.javapipeline ][main] Pipeline terminated {"pipeline.id"=>"main", "uptime"=>1887}
And, here's a dns failure, that doesn't seem to be retried either:
/tmp/logstash-7.11.1
❯ echo 1 | bin/logstash -e "filter { http { url => 'http://httpstat.us/503' automatic_retries => 100 } }"
[2021-02-19T18:15:35,758][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.11.1", "jruby.version"=>"jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 11.0.9+11 on 11.0.9+11 +indy +jit [darwin-x86_64]"}
[2021-02-19T18:15:37,967][INFO ][logstash.javapipeline ][main] Pipeline started {"pipeline.id"=>"main"}
[2021-02-19T18:15:38,006][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2021-02-19T18:15:38,177][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
[2021-02-19T18:15:38,373][ERROR][logstash.filters.http ][main][bd532599e066920b19b659b8756ad4a5751741b31fc6994b60c993f22fc75bbc] error during HTTP request {:url=>"http://httpstat.us/503", :body=>nil, :client_error=>"httpstat.us: nodename nor servname provided, or not known"}
{
"host" => "Joaos-MacBook-Pro.local",
"@timestamp" => 2021-02-19T18:15:37.992Z,
"message" => "1",
"type" => "stdin",
"tags" => [
[0] "_httprequestfailure"
],
"@version" => "1"
}
[2021-02-19T18:15:38,536][INFO ][logstash.javapipeline ][main] Pipeline terminated {"pipeline.id"=>"main", "uptime"=>1252}
[2021-02-19T18:15:38,565][INFO ][logstash.pipelinesregistry] Removed pipeline from registry successfully {:pipeline_id=>:main}
[2021-02-19T18:15:38,597][INFO ][logstash.runner ] Logstash shut down.
Would it be possible to add a verification_mode
parameter similar as in filebeat:
https://www.elastic.co/guide/en/beats/filebeat/current/configuration-ssl.html#_verification_mode
A hack to demonstrate this hard-coded.
--- ./vendor/bundle/jruby/2.5.0/gems/logstash-mixin-http_client-7.0.0/lib/logstash/plugin_mixins/http_client.rb 2021-01-12 14:47:39.000000000 +0000
+++ ./vendor/bundle/jruby/2.5.0/gems/logstash-mixin-http_client-7.0.0/lib/logstash/plugin_mixins/http_client.rb.verify_on 2021-01-12 14:49:57.000000000 +0000
@@ -170,6 +170,9 @@
raise InvalidHTTPConfigError, "You must specify both client_cert and client_key for an HTTP client, or neither!"
end
+ # dirty hack to disable host name verification unconditionally
+ c[:ssl][:verify] = :disable
+
c
end
This should of course be implemented then as a flag, such that the flag could be set in e.g. http-output plugin.
The default should remain enabled so that there is no unexpected security impact as a result of this change.
could you please add support for using a socks5 proxy for http client ?
Add a new ssl_enabled
setting for enabling/disabling the other SSL configurations, so plugins using this mixing can easily be compliant with the Logstash SSL standards.
When disabled, and other ssl_
option are set, it should log a warning message letting users know that those settings won't be used by the client.
It seems that there's a lot of confusion as to which options get set at the root level for this mixin and which ones get set per-URL.
Currently 'extra' options specified per-URL do not generate any errors. They should.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.