Searching for Gray Log 2 API or a way to query ElasticSearch
Graylog2 has a very clear and complete Restful API, that you can browse/test with Swagger.
Go to System -> Nodes and select "API Browser" from a node action dropdown menu.
By default, you can access it at the following url : http://your.graylog2:12900/api-browser
Hope this helps !