Parameter of HTTP callback Alert

Hi everyone

I want to know parameter of HTTP callback Alert for configure php file to Line alert.

This is my php code.

<?php $message=$_POST['check_result']; $sendmsg ="\nMessage=".$message; $accessToken = $_GET['token']; $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,"https://notify-api.line.me/api/notify"); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS, "message=".urlencode($sendmsg)); curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 1); $headers = array( 'Content-type: application/x-www-form-urlencoded', 'Authorization: Bearer '.$accessToken, ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $status = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if($error) { echo 'error: '.curl_error($ch); } else { $result_ = json_decode($status, true); echo "status : ".$result_['status']; echo "message : ". $result_['message']; } ?>

http://docs.graylog.org/en/2.4/pages/streams/alerts.html#http-alert-notification

Hi Jochen

I see already but I don’t understand.

It’s an example of the JSON payload sent via HTTP POST by the Graylog HTTP alarm callback.

You can get the information you need out of that JSON structure.

Hi Jochen

Ok

I will try

Hi Jochen

I have a bit question.

How to get value “matching_messages” such as $dataJson[‘check_result’][‘matching_messages’][‘source’] ?

Please tell me.

matching_messages is an array and you have to iterate over it to access individual messages.

Please tell me for example.
$dataJson[‘check_result’][‘matching_messages’][0]?

Please refer to http://php.net/manual/en/language.types.array.php.

Hi Jochen

Thank you for your information.

if i would like to get title name of alert, Do you have how to?

image

That’s part of the JSON structure you receive from the Graylog HTTP Alarm Callback (“check_result” → “triggered_condition” → “description”).

Ok Thank very much.

:slight_smile:

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