﻿# Custom Checks notification events

<!-- Version variant: customchecks_3; default: [/monitoring/custom-checks/notification-events.md](/monitoring/custom-checks/notification-events.md) -->


ServiceControl exposes two integration events related to the Custom Checks plugin.

For information about how to subscribe to ServiceControl integration events, see [Using ServiceControl events](/servicecontrol/contracts.md).

Each custom check begins in an unknown state. Once the custom check executes and reports its status to ServiceControl, it will transition to either `pass` or `fail`. External integration events are raised whenever custom checks transition into new states.

```mermaid
graph TD

U(Unknown)
F[Fail]
P[Pass]

U -. Succeeded .-> P
U -. Failed .-> F

F -- Succeeded --> P
P -- Failed --> F
```


## `CustomCheckFailed`

The `CustomCheckFailed` event is published if a custom check transitions from the unknown or pass state to the fail state.

<!-- snippet: CustomCheckFailed -->

```cs
public class CustomCheckFailed
{
    /// <summary>
    /// The id for the custom check provided by the user.
    /// </summary>
    public string CustomCheckId { get; set; }

    /// <summary>
    /// The custom check category provided by the user.
    /// </summary>
    public string Category { get; set; }

    /// <summary>
    /// The reason provided by the user for the failure.
    /// </summary>
    public string FailureReason { get; set; }

    /// <summary>
    /// The date and time the check failed.
    /// </summary>
    public DateTime FailedAt { get; set; }

    /// <summary>
    /// The name of the endpoint
    /// </summary>
    public string EndpointName { get; set; }

    /// <summary>
    /// The unique identifier for the host that runs the endpoint
    /// </summary>
    public Guid HostId { get; set; }

    /// <summary>
    /// The name of the host
    /// </summary>
    public string Host { get; set; }
}
```

<!-- endsnippet -->

## `CustomCheckSucceeded`

The `CustomCheckSucceeded` event is published if a custom check transitions from the unknown or fail state to the pass state.

<!-- snippet: CustomCheckSucceeded -->

```cs
public class CustomCheckSucceeded
{
    /// <summary>
    /// The id for the custom check provided by the user.
    /// </summary>
    public string CustomCheckId { get; set; }

    /// <summary>
    /// The custom check category provided by the user.
    /// </summary>
    public string Category { get; set; }

    /// <summary>
    /// The date and time the check passed.
    /// </summary>
    public DateTime SucceededAt { get; set; }

    /// <summary>
    /// The name of the endpoint
    /// </summary>
    public string EndpointName { get; set; }

    /// <summary>
    /// The unique identifier for the host that runs the endpoint
    /// </summary>
    public Guid HostId { get; set; }

    /// <summary>
    /// The name of the host
    /// </summary>
    public string Host { get; set; }
}
```

<!-- endsnippet -->
