irgendwr / TelegramAlert

🔔 Telegram Notification Plugin for Graylog
https://irgendwr.github.io/TelegramAlert/
MIT License
130 stars 18 forks source link

How to get a link to stream with absolute time interval #40

Closed artemkoru closed 3 years ago

artemkoru commented 3 years ago

Hi,

First, thanks for your solution, it really works great. Could you please help me with two questions:

  1. How can I get the permanent link to the message (in a template) that triggered some alert? Or, how to get a link to the stream with absolute time interval? I found this issue https://github.com/irgendwr/TelegramAlert/issues/15 but how can I see it's not actual.

  2. Is there some way to clear the send notification queue?

Additional context Graylog version: 3.3.13+6949772 TelegramAlert version: 2.3.1

Thanks!

irgendwr commented 3 years ago
  1. How can I get the permanent link to the message [...]?

If you take a look at an example permalink you will see something like this: <domain>/messages/graylog_2/<id>, now all you need is to put that into your template with the correct placeholders for the domain and ID:

<a href='${graylog_url}/messages/graylog_2/${message.id}'>see details</a>

The message variable here refers to the items in backlog that you can iterate through with ${foreach backlog message} ... ${end}.

Full template example:

<b>${event.message}</b>${if streams}
Streams:${foreach streams stream} <a href='${stream.url}'>${stream.title}</a>${end}${end}
${if backlog}${foreach backlog message}
<code>${message.message}</code>
<a href='${graylog_url}/messages/graylog_2/${message.id}'>see details</a>
${end}${else}
<i>- no backlog -</i>
${end}

Please note that links do not work inside <code>-blocks, this is why the template is different than the default one.

Or, how to get a link to the stream with absolute time interval? I found this issue #15

That is currently not possible. It was the default once but got removed again accidentally. I'll consider adding this again, but the permalink should work for now.

  1. Is there some way to clear the send notification queue?

I don't know, this is more of a Graylog question rather than a question about this plugin. Try asking in their forum if you can't find anything.

I assume you're asking this because older versions of the plugin tried re-sending messages even if the formatting or length are invalid. I'd suggest updating to the latest plugin version where this issue is fixed. (you may need to update your Graylog server though)

For future questions I have now enabled the GitHub discussion feature: https://github.com/irgendwr/TelegramAlert/discussions