Skip to content

Instantly share code, notes, and snippets.

@joschi
Last active April 25, 2016 09:11
Show Gist options
  • Save joschi/72fb7e75b171c10d3717 to your computer and use it in GitHub Desktop.
Save joschi/72fb7e75b171c10d3717 to your computer and use it in GitHub Desktop.
Graylog session login
# HTTP POST to /system/sessions with username and password to acquire a valid session ID
$ curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' 'http://127.0.0.1:12900/system/sessions' -d '{"username":"USER", "password":"SECRET", "host":""}'
X-Graylog-Node-ID: cd03ee44-b2a7-4824-be16-bb7456149dbd
Content-Type: application/json
Date: Tue, 23 Feb 2016 10:27:09 GMT
Content-Length: 98
{"valid_until":"2016-02-23T18:27:09.726+0000","session_id":"fdf31c3c-037b-4ff3-ba32-893e06e17c4a"}
# Use the acquired session in a Graylog REST API request (Basic Auth credentials: username==$SESSION_ID, password=="session")
$ curl -i -u 'fdf31c3c-037b-4ff3-ba32-893e06e17c4a:session' -X GET -H 'Accept: application/json' 'http://127.0.0.1:12900/count/total'
HTTP/1.1 200 OK
X-Graylog-Node-ID: cd03ee44-b2a7-4824-be16-bb7456149dbd
X-Runtime-Microseconds: 43242
Content-Type: application/json
Date: Tue, 23 Feb 2016 10:28:07 GMT
Content-Length: 17
{"events":212068}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment