Contacts Service Metrics¶
This document details the telemetry metrics exposed by the UpdateContactsInRedisService hosted service. These metrics provide insights into the performance and reliability of the contact data synchronization into the Redis cache.
The primary meter for these metrics is CRMFacade.Contacts.
Service Goal
This service is responsible for periodically fetching all contact data from DataVerse and caching it in Redis. This provides a fast, centralized cache for contact information used throughout the platform.
Metrics¶
| Metric Name | Type | Description |
|---|---|---|
contacts_sync_total |
Counter | Total number of contact sync operations attempted. Incremented on success or when skipped. |
contacts_sync_errors_total |
Counter | Total number of failed contact sync operations. |
contacts_sync_duration_seconds |
Histogram | The duration, in seconds, of each sync operation. |
contacts_last_sync_timestamp |
Observable Gauge | The Unix epoch timestamp of the last successful sync. |
Dimensions¶
These dimensions (tags) can be used to filter and group metric data.
| Metric Name | Dimension Name | Possible Values | Description |
|---|---|---|---|
contacts_sync_total |
operation |
success, skipped |
The outcome of the sync operation. |
reason |
lock_not_acquired |
The reason an operation was skipped (only present if operation=skipped). |
|
contacts_sync_errors_total |
operation |
error |
Indicates a failed operation. |
error_type |
Exception Name (e.g., RedisException) |
The type of exception that caused the failure. | |
contacts_sync_duration_seconds |
operation |
success, error |
The outcome of the operation whose duration was measured. |
Example KQL Queries¶
Here are some example queries you can use in Azure Application Insights to monitor the service.
customMetrics
| where name == "contacts_sync_total"
| where timestamp > ago(1d)
| extend operation = tostring(customDimensions.operation)
| extend reason = tostring(customDimensions.reason)
| summarize Count = sum(value) by operation, reason
| order by Count desc
customMetrics
| where name == "contacts_sync_duration_seconds"
| where timestamp > ago(7d)
| summarize percentiles(value, 95) by bin(timestamp, 1d)
This query can be used to create an alert if the last successful sync is older than a specified threshold (e.g., 2 hours).
customMetrics
| where name == "contacts_last_sync_timestamp"
| summarize LastSync = max(value)
| extend AgeInSeconds = datetime_diff('second', now(), unixtime_seconds_todatetime(LastSync))
| where AgeInSeconds > 7200 // 2 hours
| project readable_time_utc = unixtime_seconds_todatetime(LastSync), AgeInSeconds
Metric Flow Diagram¶
The following diagram illustrates the flow of the UpdateContactsInRedisService job and when each metric is recorded.
graph TD
A[Start Job] --> B{Try Acquire Lock};
B -- Lock Acquired --> C[Call UpdateAllContactsInCache];
B -- Lock Not Acquired --> D["Record: sync_total<br>(skipped, lock_not_acquired)"];
C -- Success --> E["Record: sync_total(success)<br>Record: sync_duration_seconds(success)<br>Update: last_sync_timestamp"];
C -- Failure --> F["Record: sync_errors_total<br>Record: sync_duration_seconds(error)"];