# Dynamic HTTP notifications possible?

**URL:** <https://community.graylog.org/t/dynamic-http-notifications-possible/19969>\
**Category:** Graylog Central (peer support)\
**Created:** [May 26, 2021, 12:23pm UTC](https://community.graylog.org/t/dynamic-http-notifications-possible/19969 "2021-05-26T12:23:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stokvisss](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Stokvisss](https://community.graylog.org/u/Stokvisss)\
**Post date:** [May 26, 2021, 12:23pm UTC](https://community.graylog.org/t/dynamic-http-notifications-possible/19969/1 "2021-05-26T12:23:23Z")

</div>

Is it possible to include message info in a HTTP notification?

I want to dynamically send HTTP notifications by using the message source name. For instance:

URL:  
[http://somesite.com/${message.source}](http://somesite.com/%24%7Bmessage.source%7D)

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![gsmith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/gsmith/32/1222_2.png) [@gsmith](https://community.graylog.org/u/gsmith)\
**Post date:** [May 26, 2021, 9:37pm UTC](https://community.graylog.org/t/dynamic-http-notifications-possible/19969/2 "2021-05-26T21:37:45Z")

</div>

Hello and Welcome,

> [@Stokvisss](#):
>
> Is it possible to include message info in a HTTP notification?

I believe it can be done. I havent used HTTP notifications in my environment but I have done this with Email notifications.

Is this what you refering to as shown below?

> [https://graylog-server.domain.com:9000/messages/${message.index}/${message.id}](https://graylog-server.domain.com:9000/messages/$%7Bmessage.index%7D/$%7Bmessage.id%7D)

This is the Notification configuration.

```
--- [Event Definition] ---------------------------
Title: ${event_definition_title}
Description: ${event_definition_description}
Type: ${event_definition_type}
--- [Event] --------------------------------------
Timestamp: ${event.timestamp}
Message: ${event.message}
Source: ${event.source}
Priority: ${event.priority}
Alert: ${event.alert}
Timestamp Processing: ${event.timestamp}
Timerange Start: ${event.timerange_start}
Timerange End: ${event.timerange_end}
Stream URL: ${event.stream_name}          
${if stream_url}Stream URL: ${stream_url}${end}

${if backlog}
--- [Backlog] ------------------------------------
Last messages accounting for this alert:
${foreach backlog message}
https://graylog-server.domain.com:9000/messages/${message.index}/${message.id}
User: ${message.fields.TargetUserName}
WorkStation Name: ${message.fields.WorkstationName}
Event Time: ${message.fields.EventReceivedTime}
Source: ${message.source}
Logon Type: ${message.LogonType}
---[backlog end]---------------------------------
${end}
${end}

```

Hope that helps

---

<div class="post-metadata">

**Author:** ![Stokvisss](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Stokvisss](https://community.graylog.org/u/Stokvisss)\
**Post date:** [May 27, 2021, 9:24am UTC](https://community.graylog.org/t/dynamic-http-notifications-possible/19969/3 "2021-05-27T09:24:13Z")

</div>

Hello gsmith,

Thanks for your reply. I’m indeed referring to the message info you have replied, but it seems this only works for the e-mail notifications. What I want to do is send HTTP notifications to urls which have message information in them.

So for instance; when there are any rsyslog level 0 messages found I want to send a HTTP notification to the url [http://somesite?msg=lvl\_0\_logs\_found\_from\_${message.source}](http://somesite?msg=lvl_0_logs_found_from_%24%7Bmessage.source%7D). When there are any rsyslog level 1 messages found; a HTTP notification to [http://somesite?msg=lvl\_1\_logs\_found\_from\_${message.source}](http://somesite?msg=lvl_1_logs_found_from_%24%7Bmessage.source%7D) etc.

---

<div class="post-metadata">

**Author:** ![gsmith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/gsmith/32/1222_2.png) [@gsmith](https://community.graylog.org/u/gsmith)\
**Post date:** [May 28, 2021, 4:02am UTC](https://community.graylog.org/t/dynamic-http-notifications-possible/19969/4 "2021-05-28T04:02:18Z")

</div>

Hello,

Have you seen this?

> [@How to pass variables in Alert Configuration](https://community.graylog.org/t/how-to-pass-variables-in-alert-configuration/6809):
>
> hello, I’m trying to pass variables in Alert Configuration. I’ve tried HTTP Callback Alarm in the form Editing alert configuration : Title : Test Alert URL : [http://server/graylog.php?info=${message}](http://server/graylog.php?info=%24%7Bmessage%7D) I try to pass message or id message : I set with the syntax “${message}”… Is there a way to pass the variable please ?

> <https://github.com/Graylog2/graylog2-server/issues/9508>
>
> \[Currently there is no way to change the headers, Method and body of a HTTP POST… notification.\](https://docs.graylog.org/en/3.3/pages/alerts.html)
> 
> This requires the receiving system to do the translation.
> What is needed is an option like the custom E-Mail template.
> 
> 
> 
> It should work pretty much like the E-Mail template
> The input fields should be 
> URL: http|https://Server{:port}/path/key/val.......?junk=val
> HTTP Method: GET|POST|DELETE|...
> Custom Heaaders:
> Header: value
> X-CustomerToken: value
> 
> Body: Same layout as Email Template
> \## Why?
> 
> The receiving system does not accept the default post method body and there is no way to 
> change it.
> 
> Make it just like the Email Template...
> Then I can do something like this:
> 
> \`\`\`
> \<EVENT\>
> \<TITLE\>${event\_definition\_title}\</TITLE\>
> \<Description\>${event\_definition\_description}\</Description\>
> \<EVENTTYPE\>${event\_definition\_type}\</EVENTTYPE\>
> \<Fields\>
> ${foreach event.fields field} \<FIELD\>${field.key}\</FIELD\> \<VALUE\>${field.value}\</VALUE\>
> ${end}
> \</Fields\>
> ...
> ${foreach backlog message}
> \<MESSAGE\>${message}\<MESSAGE\>
> ${end}
> \</MESSAGES\>
> ${end}
> \</EVENT\>
> \`\`\`
> 
> 
> \## Your Environment
> 
> 
> \* Graylog Version: v3.3.8+e223f85, (3.38 OVA)

> <https://github.com/Graylog2/graylog2-server/issues/4569>
>
> Support for HTML email alerts/notifications
> 
> \## Expected Behavior
> 
> Either co…nfigurable or on by default, would be helpful in formatting and general visibility of the alert. As an example, when I want to include the stream URL via ${if stream\_url}${stream\_url}${end}, the URL will be exceptionally long in some cases. It'd be ideal to be able to format with \<a\> tags
> 
> I looked around for some stuff on this and couldnt find anything (requests, posts on community board, etc)
> 
> \## Current Behavior
> 
> HTML is not rendered because the email is sent with the following headers
> 
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 7bit
> 
> \## Possible Solution
> 
> In https://github.com/Graylog2/graylog2-server/blob/master/graylog2-server/src/main/java/org/graylog2/alerts/FormattedEmailAlertSender.java line 171 you could use org.apache.commons.mail.HtmlEmail instead of SimpleEmail. Calling setHtmlMsg and then setTextMsg if users have configured HTML email and their clients dont support it (just an idea)
> 
> Although I am wiling to bet that this may cause issues with JMTE due to format and syntax requirements?
> 
> \## Steps to Reproduce (for bugs)
> 
> 1. Configure an alert/notification
> 2. Use HTML in the template
> 3. Send test email
> 4. Observe that the email header is text/plain and HTML is not rendered 
> 
> \## Context
> 
> 
> 
> \## Your Environment
> 
> 
> \* Graylog Version: 2.4.0
> \* Operating System: CentOS 7.4

[https://docs.graylog.org/en/4.0/pages/plugins/event\_notifications.html#example-event-notification](https://docs.graylog.org/en/4.0/pages/plugins/event_notifications.html#example-event-notification)

---

<div class="post-metadata">

**Author:** ![Stokvisss](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Stokvisss](https://community.graylog.org/u/Stokvisss)\
**Post date:** [May 28, 2021, 8:58am UTC](https://community.graylog.org/t/dynamic-http-notifications-possible/19969/5 "2021-05-28T08:58:57Z")

</div>

Hello gsmith,

Thank you! I had been searching for an answer on the forum already but didn’t find the thread you’ve replied. That fixes it! 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [June 11, 2021, 8:59am UTC](https://community.graylog.org/t/dynamic-http-notifications-possible/19969/6 "2021-06-11T08:59:56Z")

</div>

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