Skip to content

MaceWindu/Seq.App.Teams.AdaptiveCard

Repository files navigation

Seq.App.Teams.AdaptiveCard Build Status NuGet License

Seq alerting application for Microsoft Teams with AdaptiveCard support. Based on Seq.App.Teams application.

Notes

To connect application instance to Teams you need to provide Teams Webhook url. You can find required instructions here.

Because Teams currently doesn't support AdaptiveCard templating, it is done on application side using AdaptiveCards.Templating library.

Context

Default template source: default-template.json. Used when no template specified.

Payload Examples

Those examples could be used with AdaptiveCard designer.

Event Payload

{
    "Id": "event-4f3bb930732008db0733010000000000",
    "TimeStamp": "2023-06-22T12:58:00.8518960Z",
    "Level": "Warning",
    "MessageTemplate": "Some event {@data}",
    "Message": "Some event 123",
    "Exception": null,
    "Properties": {
        "#ProcessID": 11860,
        "#ThreadID": 88
    },
    "EventType": 2739387145,
    "AppTitle": "teams app",
    "InstanceName": "",
    "BaseUri": "http://localhost:80"
}

Alert Payload

{
    "Id": "event-988d8be0732108db0000000000000000",
    "TimeStamp": "2023-06-22T13:07:13.3585376Z",
    "Level": "Warning",
    "MessageTemplate": "Alert condition triggered by {NamespacedAlertTitle}",
    "Message": "Alert condition triggered by \"admin/New Alert\"",
    "Exception": null,
    "Properties": {
        "NamespacedAlertTitle": "admin/New Alert",
        "Alert": {
            "Id": "alert-463",
            "Title": "New Alert",
            "Url": "http://localhost:80/#/alerts/alert-463",
            "OwnerUsername": "admin",
            "SignalExpressionDescription": null,
            "Query": "select count(*) as count from stream group by time(1m) having count > 0 limit 100 for background",
            "HavingClause": "count > 0",
            "TimeGrouping": "1 minute"
        },
        "Source": {
            "RangeStart": "2023-06-22T13:05:43.3585376Z",
            "RangeEnd": "2023-06-22T13:06:43.3585376Z",
            "ResultsUrl": "http://localhost:80/#/events?q=select%20count%28%2A%29%20as%20count%20from%20stream%20group%20by%20time%281m%29%20having%20count%20%3E%200%20limit%20100%20for%20background&from=2023-06-22T13:05:43.3585376Z&to=2023-06-22T13:06:43.3585376Z",
            "Results": [
                [ "time", "count" ],
                [ "2023-06-22T13:05:43.3585376Z", 19 ]
            ],
            "ContributingEvents": [
                [ "id", "timestamp", "message" ],
                [ "event-6d291458732108db9333010000000000", "2023-06-22T13:06:00.5580888Z", "event message 1" ],
                [ "event-6d291458732108db9433010000000000", "2023-06-22T13:06:00.5580888Z", "event message 2" ]
            ]
        },
        "SuppressedUntil": "2023-06-22T13:08:13.3585376Z",
        "Failures": null
    },
    "EventType": 2716299265,
    "AppTitle": "teams app",
    "InstanceName": "",
    "BaseUri": "http://localhost:80"
}

Custom Functions

In addition to standard AdaptiveTemplate functions, application implements several custom functions:

  • _nomd(param): this function takes single parameter of any type and in case of string escapes all supported markdown control sequences. Function is useful when rendered text could contain markdown-like character sequences as AdaptiveCard doesn't provide option to disable markdown from template.
  • _jsonPrettify(param): same as built-in jsonStringify(), but JSON rendered indented and null values are omitted
  • _colorUri(hex_rgb): generates data uri with one-pixel image of specified color. Parameter must be string with hex color in RRGGBB form. Because AdaptiveCard doesn't support background color but supports background image, this function could be used to emulate background color using background image.

Extra Links

Configuration

Additional repositories

Templating language