symptoma / rocketchat-graylog-hook

Add Graylog notifications via a new WebHook in Rocket.Chat
1 stars 4 forks source link

Cannot read property 'triggered_condition' of undefined #1

Open mike-kll opened 3 years ago

mike-kll commented 3 years ago

Hello everybody,

My environment:

I have Integration the Script in Rocket Chat and configured Graylog to send Webhook.

When I send a test message from Graylog I get the following error message.

I20210131-11:22:08.866(1) server.js:204 Integrations ➔ Incoming WebHook.error [Error running Script in Trigger rocketchat-graylog-hook :] I20210131-11:22:08.867(1) server.js:204 Integrations ➔ Incoming WebHook.error var GRAYLOG_URL="https://graylog.xxxx.xx";var createPermalink=function(m,index){var label=index===0?"Display complete message":"#"+(index+1);return""+label+""};var formatMessages=function(messages){var grouped=messages.reduce(function(acc,m){if(!acc.hasOwnProperty(m.message)){acc[m.message]=[]}acc[m.message].push(m);return acc},{});var result=[];for(var mType in grouped){if(grouped.hasOwnProperty(mType)){var line="Message: "+mType+"
Source: "+grouped[mType][0].source+"
"+grouped[mType].map(createPermalink).join(", ");result.push(line)}}return result.join("
-------------
")};var parseText=function(result){if(result.matching_messages.length>0){return formatMessages(result.matching_messages)}else{return result.result_description}};var createAlertMessageEvent=function(result){return":warning: Alert: "+result.triggered_condition.title+"
"+parseText(result)};var makeAttachment=function(text){return{text:text,color:"#e8d612"}};var Script=function(){function Script(){}var _proto=Script.prototype;_proto.process_incoming_request=function process_incoming_request(_ref){var request=_ref.request;return{content:{attachments:[makeAttachment(createAlertMessageEvent(request.content.check_result))]}}};return Script}();

I20210131-11:22:08.869(1) server.js:204 Integrations ➔ Incoming WebHook.error [Stack:] I20210131-11:22:08.870(1) server.js:204 Integrations ➔ Incoming WebHook.error Error: TypeError: Cannot read property 'triggered_condition' of undefined at evalmachine.:11:33 at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40

Does someone have an idea what the problem is?

Greetings

Mike

mike-kll commented 3 years ago

I think the problem is the Payload in Graylog 4 is different to Graylog 3.

https://docs.graylog.org/en/4.0/pages/alerts.html

https://docs.graylog.org/en/3.0/pages/streams/alerts.html?highlight=alerts#http-alert-notification

Can someone help me with this problem?

Greetings

Mike