Query against REST API of a third party device

I'm trying to query a storage device via RESTful API. I have to send a POST against the endpoint /auth with User and Password in the header to get a token. This token remains valid for 2hours or 30minutes if no activity. Here the example with curl:
[root@elasticnode1 logstash]# curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Username: superuser' -H 'X-Auth-Password: passw0rd' https://192.168.18.140:7443/rest/auth
and this gives me back:
{"token": "7b0867758147551d57c6a3f758ae40a44820fbb9fd7a529517c43d74f683f4b0"}

Now I need to use this Token in the header of my data request endpoints /rest/ as demonstrated in the following curl example:
*[root@elasticnode1 logstash]# curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token:7b0867758147551d57c6a3f758ae40a44820fbb9fd7a529517c43d74f683f4b0' https://192.168.18.140:7443/rest/lscluster
*
Answers me back:
[{ "id": "00000200604184D6", "name": "Zurich", "location": "local", "partnership": "", "bandwidth": "", "id_alias": "000002006400C582" },
{ "id": "0000020064804138", "name": "Luzern", "location": "remote", "partnership": "fully_configured", "bandwidth": "62", "id_alias": "0000020063A04004" }

as this is the JSON format I need to forward to ES.

I tried to use the "logstash-filter-rest" (https://github.com/lucashenning/logstash-filter-rest) and was able to build a pipeline but no data was gathered. Got some hint that the usage of http input plugin would be a better way. Sorry but I did not find any related example and I'm a new logstash user.
Any help is welcome.

You could put the first POST in an http_poller input then use the resulting token in an http filter.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.