Last active
July 8, 2022 20:56
-
-
Save dudanogueira/0d629e369cfa9a4e3179d577b643c4e1 to your computer and use it in GitHub Desktop.
A Webhook Script to parse Graylog alert payload.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* exported Script */ | |
/* globals console, _, s */ | |
/** Global Helpers | |
* | |
* console - A normal console instance | |
* _ - An underscore instance | |
* s - An underscore string instance | |
*/ | |
class Script { | |
/** | |
* @params {object} request | |
*/ | |
process_incoming_request({ request }) { | |
// request.url.hash | |
// request.url.search | |
// request.url.query | |
// request.url.pathname | |
// request.url.path | |
// request.url_raw | |
// request.url_params | |
// request.headers | |
// request.user._id | |
// request.user.name | |
// request.user.username | |
// request.content_raw | |
// request.content | |
// console is a global helper to improve debug | |
console.log(request.content); | |
return { | |
content:{ | |
text: request.content.event.message | |
// "attachments": [{ | |
// "color": "#FF0000", | |
// "author_name": "Rocket.Cat", | |
// "author_link": "https://open.rocket.chat/direct/rocket.cat", | |
// "author_icon": "https://open.rocket.chat/avatar/rocket.cat.jpg", | |
// "title": "Rocket.Chat", | |
// "title_link": "https://rocket.chat", | |
// "text": "Rocket.Chat, the best open source chat", | |
// "fields": [{ | |
// "title": "Priority", | |
// "value": "High", | |
// "short": false | |
// }], | |
// "image_url": "https://rocket.chat/images/mockup.png", | |
// "thumb_url": "https://rocket.chat/images/mockup.png" | |
// }] | |
} | |
}; | |
// return { | |
// error: { | |
// success: false, | |
// message: 'Error example' | |
// } | |
// }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment