Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Samples

Send Metrics data to ServiceControl

NuGet Package: NServiceBus.Metrics.ServiceControl (4.x)
Target Version: NServiceBus 8.x

The NServiceBus.Metrics.ServiceControl component enables sending monitoring data gathered with NServiceBus.Metrics to a ServiceControl.Monitoring service.

Configuration

After adding the package to the project, metrics are sent to ServiceControl once enabled.

It can be enabled via:

const string SERVICE_CONTROL_METRICS_ADDRESS = "particular.monitoring";

var metrics = endpointConfiguration.EnableMetrics();

metrics.SendMetricDataToServiceControl(
    serviceControlMetricsAddress: SERVICE_CONTROL_METRICS_ADDRESS,
    interval: TimeSpan.FromMinutes(1),
    instanceId: "INSTANCE_ID_OPTIONAL");

Service Control Metrics Address

The default instance name is particular.monitoring which is also used as the input queue for ServiceControl monitoring.

Interval

Specifies the maximum delay between sending metrics report messages.

The metrics plugin has a buffer and when that overflows a metric report message is sent and the buffer is cleared. When an endpoint instance is idle it will send metrics report messages at this interval to indicate it is idle. When the endpoint is under load the interval between metric messages will be much shorter as this buffer fills faster.

The recommended value is between 10 and 60 seconds.

  1. Smaller values result in ServiceControl monitoring view to be updated faster, especially on the 1-minute timescale
  2. Larger values result in less frequent ServiceControl monitoring view updates only when an instance is not under heavy load. This isn't affecting the monitoring view with 10-minutes or larger timescales

It is recommended to use higher values for systems that can have many endpoint instances or use a transport that might be affected by rate limiting (often cloud-based).

Example:

If the system has 500 instances and the interval is set to 5 seconds an idle system will send on average 6.000 metric messages per minute (500 * 6) / 100 per second.

Time To Be Received

By default, messages sent to the monitoring instance of ServiceControl have Time To Be Received set to 7 days. This value can be overridden when needed using following API:

metrics.SetServiceControlMetricsMessageTTBR(TimeSpan.FromHours(1));

Instance ID

An override for $.diagnostics.hostid and $.diagnostics.hostdisplayname.

It is recommended to override the host id and host display name via NServiceBus core and to use the API without the InstanceId argument. By default, the monitoring plug-in will use these values to identify the monitored endpoint instances in the user-interface.

A human readable value is being passed in the following example:

const string SERVICE_CONTROL_METRICS_ADDRESS = "particular.monitoring";

var endpointName = "MyEndpoint";
var machineName = $"{Dns.GetHostName()}.{IPGlobalProperties.GetIPGlobalProperties().DomainName}";
var instanceIdentifier = $"{endpointName}@{machineName}";

var metrics = endpointConfiguration.EnableMetrics();

metrics.SendMetricDataToServiceControl(
    serviceControlMetricsAddress: SERVICE_CONTROL_METRICS_ADDRESS,
    interval: TimeSpan.FromMinutes(1),
    instanceId: instanceIdentifier);

Samples