Logstash http_poller request the first request url must be entered in the second parameter request url

I have two URLs (due to security reasons I will explain using a dummy)

 a> https://xyz.company.com/ui/api/token
 b> https://xyz.company.com/request/transaction?date=2016-01-21&token=<tokeninfo>

When you hit the url mentioned in 'a', it will generate a token, let it be a string of 16 characters

Then this token should be used when executing the second request of point "b" in the token parameter


Update

 The second url response is important to me i.e is a JSON response, I need       
 to filter the json data and extract required data and output it to standard 
 output and elastic search.    

is there any way to do this in logstash using the http_poller plugin or any other plugins.

Note: these request URLs must be executed one by one, i.e. point "a" must be executed first, and the URL "b" should be executed next after receiving a new token.

Please offer.

+4
1

, http_poller http.

, :

input {
   # 1. trigger new token requests every hour
   http_poller {
     urls => {
       token => "https://xyz.company.com/ui/api/token"
     }
     interval => 3600
     add_field => {"token" => "%{message}"}
   }
}
filter {
}
output {
   # 2. call the API
   http {
     http_method => "get"
     url => "https://xyz.company.com/request/transaction?date=2016-01-21&token=%{token}"
   }
}

UPDATE

API ES, . cron, script, HTTP- , ES.

Shell script, cron:

#!/bin/sh

# 1. Get the token
TOKEN=$(curl -s -XGET https://xyz.company.com/ui/api/token)

# 2. Call the API with the token and append JSON to file
curl -s -XGET "https://xyz.company.com/request/transaction?date=2016-01-21&token=$TOKEN" >> api_calls.log

script cron, crontab ( ), , .

logstash . api_calls.log ES

input {
    file {
        path => "api_calls.log"
        start_position => "beginning"
    }
}
filter {
    json {
        source => "message"
    }
}
output {
    elasticsearch {
        hosts => ["localhost:9200"]
        index => "my_index"
        document_type" => "my_type"
    }
    stdout {
        codec => "rubydebug"
    }
}
+6

All Articles