如何使用reststash httpPoller从RestCall保存authToken并将其放入下一个

时间:2019-01-16 10:46:59

标签: elasticsearch logstash elastic-stack

我有一个authCall帖子,此调用的响应是令牌。我尽快获得令牌,我想调用另一个API以获取更多信息,并在其中使用上述令牌。我已在摘要中发表评论,希望它能解释一些事情。另外,我的第二个API应该安排为每分钟之后调用一次,我不想使用“ authenticate” api来进行。请为这2点提供帮助。

http_poller{
    urls => {
  "authenticate" => {
    url => "http://localhost:5000/api/user/login"
    method => "POST"
    headers => {
      "Accept" => "application/json"
      "Content-Type" => "application/json"
    }
    body => '{"username":"tempUserName","password":"tempPassword"}'
  }
  request_timeout => 60
  schedule => { cron => "* * * * * UTC"}
  codec => "json"
  add_field => {log_type => "http_poller"}
}
//The above api returns a 'token'
//Here i want to call another api like localhost:5000/api/getTodos
//and put the token in there so my Todo rest services recognise's me

0 个答案:

没有答案