Skip to content

Commit 93c172c

Browse files
snow-jallenclaude
andcommitted
An alert when matches run slow: more than 100 tick overruns in 5 minutes
netrts-slow-ticks is a log alert on netrts-insights that sums netrts.tick.overruns every 5 minutes and emails the netrts-alerts action group past 100. In the last week ordinary play topped out at 25; the 16-player Formics load test before the pathfinding fix made 595 and 239, the only windows that would have fired. It's in deploy/monitoring/main.bicep and already created in rg-netrts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8fdNFMnkyDNTFoKqQyD6L
1 parent a5796a2 commit 93c172c

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

‎deploy/monitoring/main.bicep‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// ▼
77
// Metric alert: 2 regions failing ──► action group ──► email (and an "is resolved" email after)
88
//
9+
// Log alert (every 5 min): more than 100 ticks overran their interval ──► the same action group
10+
//
911
// Cost: standard tests are $0.0005 per run per region: 3 regions every 5 minutes is about $13 a month.
1012
// Fewer regions or a longer interval costs less (failedLocations must stay at most the region count).
1113

@@ -115,5 +117,49 @@ resource down 'Microsoft.Insights/metricAlerts@2018-03-01' = {
115117
}
116118
}
117119

120+
@description('Ticks over their interval, summed over all matches in 5 minutes, before the slow-ticks alert fires.')
121+
param overrunThreshold int = 100
122+
123+
// Matches falling behind their tick rate: the server is short of CPU. Ticks that overrun are counted by
124+
// netrts.tick.overruns. In the week this was added, ordinary play topped out at 25 in 5 minutes; a load
125+
// test of four 16-player Formics matches before the pathfinding fix made 595.
126+
resource slow 'Microsoft.Insights/scheduledQueryRules@2023-12-01' = {
127+
name: 'netrts-slow-ticks'
128+
location: location
129+
properties: {
130+
displayName: 'netrts-slow-ticks'
131+
description: 'More than ${overrunThreshold} ticks in 5 minutes took longer than their match\'s tick interval: matches are running slow. Check live matches (netrts-insights > Metrics: netrts.tick.duration) and the plan\'s CPU.'
132+
severity: 2
133+
enabled: true
134+
scopes: [
135+
insights.id
136+
]
137+
evaluationFrequency: 'PT5M'
138+
windowSize: 'PT5M'
139+
criteria: {
140+
allOf: [
141+
{
142+
query: 'customMetrics | where name == "netrts.tick.overruns" | summarize overruns = sum(valueSum)'
143+
timeAggregation: 'Total'
144+
metricMeasureColumn: 'overruns'
145+
operator: 'GreaterThan'
146+
threshold: overrunThreshold
147+
failingPeriods: {
148+
numberOfEvaluationPeriods: 1
149+
minFailingPeriodsToAlert: 1
150+
}
151+
}
152+
]
153+
}
154+
autoMitigate: true
155+
actions: {
156+
actionGroups: [
157+
email.id
158+
]
159+
}
160+
}
161+
}
162+
118163
output testId string = healthTest.id
119164
output alertId string = down.id
165+
output slowTicksAlertId string = slow.id

‎deploy/monitoring/setup.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
2-
# Creates (or updates) the uptime test on netrts.snowse.io/health and the alert that emails when it
3-
# fails. Safe to run again. See docs/deploying.md, "Health and uptime alerts".
2+
# Creates (or updates) the uptime test on netrts.snowse.io/health, the alert that emails when it
3+
# fails, and the alert for matches running slow. Safe to run again. See docs/deploying.md, "Health and uptime alerts".
44
#
55
# ALERT_EMAIL=you@example.edu deploy/monitoring/setup.sh
66
#

‎docs/deploying.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ every match in progress. Instead:
394394
emails again when it's resolved. About $13 a month ($0.0005 a run, per region). Create or update it
395395
with `ALERT_EMAIL=<address> deploy/monitoring/setup.sh`; the address isn't kept in the repo. Results
396396
are under `netrts-insights` → **Availability**.
397+
- **Slow ticks alert.** `netrts-slow-ticks` (a log alert on `netrts-insights`, checked every 5 minutes)
398+
emails the same action group when more than 100 ticks in 5 minutes took longer than their match's
399+
tick interval (`netrts.tick.overruns`): the server is short of CPU and matches are running slow.
400+
Ordinary play stays under about 25; a 16-player Formics load test before the pathfinding fix made 595.
401+
`deploy/monitoring/setup.sh` creates it too (`overrunThreshold` in `main.bicep`). About $1.50 a month.
397402
- **After each deploy.** The `deploy` job waits up to 10 minutes for `/health` to report the commit it
398403
deployed as Healthy or Degraded, and fails otherwise. The image is built with
399404
`-p:SourceRevisionId=<commit>`, which is where `commit` comes from.

0 commit comments

Comments
 (0)