Skip to content
4 changes: 3 additions & 1 deletion source/Scrapers/TeamCityCompatibleAgentsScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ protected override async Task Scrape(CancellationToken stoppingToken)
.Where(qb => qb.WaitReason != null)
.ToArray();

// Track builds with no compatible agents
// Track builds with no compatible agents that have been queued for over 30 minutes
var thirtyMinutesAgo = DateTime.UtcNow.AddMinutes(-30);
var buildsNoCompatibleAgents = queuedBuilds
.Where(qb => qb.WaitReason == "There are no idle compatible agents which can run this build")
.Where(qb => qb.CompatibleAgents?.Agent == null || qb.CompatibleAgents.Agent.Count == 0)
.Where(qb => qb.QueuedDate <= thirtyMinutesAgo)
.ToArray();

var noAgentsGauge = metricFactory.CreateGauge("queued_builds_no_compatible_agents", "Queued builds waiting with no compatible agents available", "buildTypeId", "buildId", "queuedDateTime");
Expand Down