-
Notifications
You must be signed in to change notification settings - Fork 19
1.2 Endpoint registration
Health Monitor offers POST /api/endpoints/register operation to register endpoint in API. The minimal amount of data that is required by that operation is:
- MonitorType - it has to be one of the values returned by GET /api/monitors operation,
- Address - an address of the endpoint that would be understandable by the specified monitor type,
- Group - logical group that endpoint belongs to,
- Name - endpoint name.
Below, there is an example json body of POST /api/endpoints/register, for registering monitoring of http://google.com with http monitor type:
{
"Name": "Google",
"Address": "http://google.com",
"MonitorType": "http",
"Group": "Externals"
}To see the most recent usage of this operation, please navigate to API swagger docs link on the Health Monitor home page.
While it is possible to manually register endpoints in Health Monitor, it would be a best practice to automate that process by either:
- registering the endpoint during it's installation with installation scripts,
- registering the endpoint on it's startup (integration in endpoint code).
Below, there is an example Powershell code that registers endpoint in Health Monitor (but does not break installation if Health Monitor is not reachable):
$body = @{ Name = $Name; Address = $Address; MonitorType = $MonitorType; Group = $ServiceGroup}
try
{
Invoke-RestMethod -Method Post -Uri "$HealthMonitoringUrl/api/endpoints/register" -Body (ConvertTo-Json $body) -ContentType "application/json"
}
catch [Exception]
{
Write-Host -ForegroundColor 'Yellow' "Failed to register endpoint in health monitor: $($_.Exception)"
Write-Host -ForegroundColor 'Yellow' "Skipping registration..."
}Note on automatic registration:
It is safe to call the POST /api/endpoints/register operation multiple times for the same endpoint.
The endpoint is identified by Address and MonitorType fields, and if there is already an endpoint registered with such values, the operation will just update it's metadata (Group, Name, Tags).
Since version 2.1.0 it is possible to tag endpoint with a list of short tags, like owning team code etc. Tags can be used later to filter endpoints displayed on home page or dashboard page.
There are two operations allowing to tag endpoints:
-
POST /api/endpoints/register operation accepting
Tagsfield in request body, which if specified, will register endpoint with tags (or override any existing ones). If tags field is not specified at all and endpoint is already registered, it's current tags will not be updated. - PUT /api/endpoints/{id}/tags operation allowing to update tags of the existing endpoint (always overriding the existing tags with new values).
Since version 2.6.0 it is possible to run multiple monitor processes and associate endpoint to the specific monitor type. The feature is useful if Health Monitor covers multiple networks and given endpoint is available only from the specific location (where one of the running monitor process is).
The POST /api/endpoints/register has been extended to accept the MonitorTag field in request body for that reason. If monitor tag value is not specified, the default tag would be applied if endpoint is registered for a first time, or previous value would be preserved for existing endpoints.
See Health monitoring configuration for details how to configure monitor process with tag.