Hello,
I’ve set-up a Graylog cluster and the UI works fine, indexing is fine, but I get a “405 method not allowed” error when I hit the following end-point alone:
http://graylog.test:9000/api/system/metrics/multiple/
The exact error message is:
{“type”:“ApiError”,“message”:“HTTP 405 Method Not Allowed”}
My configuration looks like this:
rest_listen_uri = "http://graylog.test:9000/api/ "
rest_transport_uri = "http://graylog.test:9000/api/ ,
web_listen_uri = “http://graylog.test:9000/ ”
Other API end-points like “/api/system/metrics/” and “/api/system/inputstates” work fine.
I don’t see any error messages in the server log. What could be going wrong?
EDIT:
I’m using Graylog 2.2
Regards,
KN.
maedox
(Pål Nilsen)
March 2, 2017, 1:47pm
2
That’s because it doesn’t want GET requests. (Mine does the same thing and my cluster works fine.)
jochen
(Jochen)
March 2, 2017, 1:58pm
3
What kind of HTTP request (HTTP method, headers, request body) are you sending to http://graylog.test:9000/api/system/metrics/multiple/
?
Shortly after posting my question, I realized that the end-point is probably expecting a POST (I was doing a GET earlier), but when I POST like:
curl -u admin -H 'Content-Type: application/json' -X POST -d '{"metrics":["org.graylog2.buffers.input.usage"]}' http://graylog.test:9000/api/system/metrics/multiple
I’m prompted for a password and when I enter the password, I now get a {"type":"ApiError","message":"HTTP 500 Internal Server Error"}%
response.
EDIT: copy fail - it was a 500 response (updated the post)
Thanks,
KN.
Figured it out. I needed a -H 'Accept: application/json'
as well in addition. I’m sorry for bothering. I hope somebody else finds it helpful.
jochen
(Jochen)
March 2, 2017, 2:55pm
6
As a summary, this curl command is working:
$ curl -u $USER:$PASSWORD \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json'
-d '{"metrics":["org.graylog2.buffers.input.usage"]}' \
'http://127.0.0.1:9000/api/system/metrics/multiple?pretty=true'
{
"total" : 1,
"metrics" : [ {
"full_name" : "org.graylog2.buffers.input.usage",
"metric" : {
"value" : 0
},
"name" : "usage",
"type" : "gauge"
} ]
}