I’m attempting to search via the rest API using a basic invoke command through PowerShell. The issue i am having is that the following search via a specific stream is not returning anything. Doing the same search via the web interface returns results. Removing the stream from the script also returns results.
A few posts have shown a CURL that can be used, and the following works well under a linux host, have also converted it to PowerShell and seems to work ok, but am not sure if its the right way to call via the Graylog REST API.
Here is the PowerShell version of CURL. (Needed to post this separately as i am a new user and wont allow more than two links to be posted at the same time - sorry)
Have you checkout the API browser on the Graylog Node? That should give you a better idea what is needed for an API call if you haven’t already
As for the PowerShell, Have you tested by asking for a single result, using the Invoke-RestMethod cmdlet? It will make the web request and then convert the JSON data returned by the API into a PowerShell object.
Example:
Invoke-RestMethod -Method GET -ContentType “application/json” -Uri “https://graylog.domain.com:9000/api/stream/1”
@gsmith, I do have another question. Using the Invoke method using ‘Post’ returns the following error when using the following API call [/api/views/search/messages].
“Invoke-RestMethod : Unable to export as JSON - Enterprise license is missing or invalid!”
This only occurs when I use “‘application/json’” in the header, but works fine with “text/csv”. Any reason why, is this a licensed feature?
I’m not sure, I would have to research that error. Did you check Graylog log file and/or maybe the device your executing the Invoke-RestMethod? See if you can find more information on why. To be honest.
Hi @gsmith, yeah, checked the logs, and turned on debug mode for a short period and did a tail on /var/log/graylog-server/server.log. Nothing coming up expect below.
----------------------Displayed Error------------------------------------------------------------------
Invoke-RestMethod : Unable to export as JSON - Enterprise license is missing or invalid!
At line:5 char:6