Integrate the graylog rest api in code

I need to add the integration of Graylog rest API for creating the Streams automation in my typescript code.

So how can I do it

How can I do it using code?

Hello and Welcome @Rishav

Have you tried the Graylog API browser?

Or have you looked here

@gsmith Yes, I know about the Graylog API browser.

But how to use this in the code - should we have to use Graylog npm libraries?

I have no idea how to use it in code please help - can you please share an example with graylog rest API

hey,
Im not sure what code your referring to but I use cURL.

EDIT:
here is and example of curl command

curl -XGET http://192.168.1.100:9200/_cluster/allocation/explain?pretty

You can find more here in the documentation.

https://docs.graylog.org/docs/rest-api

My Methodology is kind of like this:

We have some API services running - we need to the configure alert/notification/Stream for the API’s with Graylog. So, I’m automating this thing - whenever next time I make any new API I have to just call the function(Graylog alert/notification/Stream function ) and the function will create the Stream/rule/Alert automatically for that API

Hello,

Ok… see if I understand this.

You have API’s setup on Graylog and you need to setup the alert/notification/Stream with those API’s?

So you need one API for Alerts, One API for Notification && One API fro a stream

When you stated “function” are you referring to API call?

You can use cURL with a bash script and attach it to CRON, is that something your looking for?

Example:

root# curl -v https://graylog_server:9000/api/alerts/callbacks

curl --insecure -u greg.smith  https://graylog.domain.com:9000/api/alerts/callbacks

Results:

“total”:15,“alarmcallbacks”:[{“id”:“5a502f9cffe8b10359167675”,“type”:"org.graylog2.alarmcallbacks.EmailAlarmCallback “,
configuration”:{“user_receivers”:[“greg.smith”],“body”:"Ticket Manager Instructions: Escalate incidents to contacts
identified starting with contacts on-shift. Attempt to establish contact every 1 hour(s) until ticket is successfully assigned to a technician.
Leave a voice mail or text message once every 1 hour(s) with each attempted contact.\n\n Owner Instructions:
Logs have indicated that a virus was detected on one of VDI instances.
Please decipmpacted, connect to the instance for further investigation. Verify the virus
is currently held in quarantine and delete if applicable.\n\nPrimary Contact:\nSpencer \n(\
n\nSecondary Contact:\nGreg Smith\n(\n\nEscalation Contact:\nChris \n(\n##
#\nTriggered condition: ${check_result.triggeredCondition}\nAlert Description: ${check_result.resultDescriptio

Hey @gsmith
You get it wrong

So I have a service called auth-service for the authentication of the users. This is the backend service which is written in typescript. In the auth-service I have different-different APIs for making tokens have token API /token for verifying that token I have /verify API for making token for the phone numbers I have /opt API - These types of API I have.

I already setup the log monitoring for these API’s with Graylog - and define the log-level as well. But haven’t setup the streams and notifications yet.

Now in my auth-service every API has different-different latency and functionality.
I need to make streams(rules), Notifications, and alerts in Graylog on API level.
For that I’m using the Graylog-rest-API - I wanna make new functionality for Graylog (streams/notification/alert) in auth-service code.

So whenever I make a new API in auth-service I just need to call the functionality which is already in our auth-service and just need to put some parameters. Stream/Notification etc… will automatically create for that API

hello @Rishav

Thank you for the explanation.

I do not know, or use this service auth-service . Only advice I could give you is where and how to use Graylog API system.

Unfortunately since I don’t use auth-service service I’m not going to be any help with the function nor how to use the code for that service, Sorry but maybe someone else here has done that

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