public static IHealthBuilder ToSlack( this IHealthReportingBuilder healthReportingBuilder, SlackHealthAlertOptions options) { healthReportingBuilder.Using(new SlackIncomingWebHookHealthAlerter(options)); return(healthReportingBuilder.Builder); }
public static IHealthBuilder ToSlack( this IHealthReportingBuilder healthReportingBuilder, Action <SlackHealthAlertOptions> optionsSetup) { var options = new SlackHealthAlertOptions(); optionsSetup(options); healthReportingBuilder.Using(new SlackIncomingWebHookHealthAlerter(options)); return(healthReportingBuilder.Builder); }
public static IWebHost BuildWebHost(string[] args) { ConfigureLogging(); return(WebHost.CreateDefaultBuilder(args) #region App Metrics Health configuration options // To configure ASP.NET core App Metrics hosting options: custom ports and endpoints // .ConfigureAppHealthHostingConfiguration( // options => // { // options.HealthEndpointPort = 2222; // options.HealthEndpoint = "healthchecks"; // }) // To configure App Metrics Health core where an IHealthBuilder is provided with defaults that can be overriden // .ConfigureHealthWithDefaults( // builder => // { // builder.Configuration.Configure( // options => // { // options.Enabled = true; // }); // }) // To configure App Metrics core where an IMetricsBuilder is provided without any defaults set // .ConfigureHealth( // builder => // { // builder.Configuration.Configure( // options => // { // options.Enabled = true; // }); // }) // To configure App Metrics Health endpoints explicity // .UseHealthEndpoints() // To configure all App Metrics Health Asp.Net Core extensions overriding defaults // .UseHealth(Configure()) // To confgiure all App Metrics Asp.Net core extensions using a custom startup filter providing more control over what middleware tracking is added to the request pipeline for example // .UseHealth<DefaultHealthStartupFilter>() #endregion .ConfigureHealthWithDefaults( (context, builder) => { var slackOptions = new SlackHealthAlertOptions(); context.Configuration.GetSection(nameof(SlackHealthAlertOptions)).Bind(slackOptions); builder.HealthChecks.AddProcessPrivateMemorySizeCheck("Private Memory Size", 200); builder.HealthChecks.AddProcessVirtualMemorySizeCheck("Virtual Memory Size", 200); builder.HealthChecks.AddProcessPhysicalMemoryCheck("Working Set", 200); builder.HealthChecks.AddPingCheck("google ping", "google.com", TimeSpan.FromSeconds(10)); builder.HealthChecks.AddHttpGetCheck("github", new Uri("https://github.com/"), TimeSpan.FromSeconds(10)); builder.Report.ToSlack(slackOptions); // TODO: Edit webhook url in appsettings }) .UseHealth() .UseStartup <Startup>() .Build()); }