Home

Awesome

Warden Slack Integration

Warden

OPEN SOURCE & CROSS-PLATFORM TOOL FOR SIMPLIFIED MONITORING

getwarden.net

BranchBuild status
mastermaster branch build status
developdevelop branch build status

SlackIntegration can be used for sending messages to the Slack using the webhook integration.

Installation:

Available as a NuGet package.

dotnet add package Warden.Integrations.Slack

Configuration:

SlackIntegration can be configured by using the SlackIntegrationConfiguration class or via the lambda expression passed to a specialized constructor.

Initialization:

In order to register and resolve SlackIntegration make use of the available extension methods while configuring the Warden:

var wardenConfiguration = WardenConfiguration
    .Create()
    .IntegrateWithSlack("https://hooks.slack.com/services/XXX/YYY/ZZZ", cfg =>
    {
        cfg.WithDefaultMessage("Monitoring status")
           .WithDefaultUsername("Warden");
    })
    .SetGlobalWatcherHooks((hooks, integrations) =>
    {
        hooks.OnStart(check => GlobalHookOnStart(check))
             .OnFailure(result => integrations.Slack().SendMessageAsync("Monitoring errors have occured."))
    })
    //Configure watchers, hooks etc..

Custom interfaces:

public interface ISlackService
{
    Task SendMessageAsync(string message, string channel = null, string username = null, 
            TimeSpan? timeout = null, bool failFast = false);
}

ISlackService is responsible for sending the message using Slack Webhook. It can be configured via the WithSlackServiceProvider() method. By default, it is based on the HttpClient library.