Skip to content

Commit

Permalink
add logstash.yml and timeout options
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweilinux committed Oct 9, 2020
1 parent 5477715 commit 37e18b4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/logstash/filters/age.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class LogStash::Filters::Age < LogStash::Filters::Base
# The interval between calls to the limit service given by the url
config :interval, :default => "60s", :validate => :string

# user and password come from the http client mixin
# the password needs to be dereferenced using @password.value
# user and password (and other options) come from the http client mixin
# Note that the password needs to be dereferenced using @password.value

public
def register
Expand Down Expand Up @@ -104,7 +104,9 @@ def filter(event)
def request_limit
begin

options = {auth: {user: @user, password: @password.value}}
# options = {auth: {user: @user, password: @password.value}}
options = {auth: {user: @user, password: @password.value}, request_timeout: @request_timeout, socket_timeout: @socket_timeout, connect_timeout: @connect_timeout, automatic_retries: @automatic_retries}

code, response_headers, response_body = request_http(@url, options)

rescue => e
Expand All @@ -121,6 +123,9 @@ def request_limit
:url => @url, :code => code,
:response => response_body)
else
@logger.info('age request response',
:url => @url, :code => code,
:response => response_body)
process_response(response_body)
end
end
Expand Down
8 changes: 8 additions & 0 deletions testing/config/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ filter {
"limit_path" => "persistent.cluster.metadata.optimizer.sleep_min_seconds"
"user" => "obs_ro"
"password" => "Password!234"
#"request_timeout" => 60
#"socket_timeout" => 10
#"connect_timeout" => 10
#"automatic_retries" => 3
"request_timeout" => 2
"socket_timeout" => 1
"connect_timeout" => 1
"automatic_retries" => 1
}
}

Expand Down
3 changes: 3 additions & 0 deletions testing/config/logstash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#http.host: "0.0.0.0"
xpack.monitoring.enabled: false
#xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ]

0 comments on commit 37e18b4

Please sign in to comment.