Skip to content

Add Agent's Computer Name to metric #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions azure-devops-client/agentpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,17 @@ type AgentPoolAgentList struct {
}

type AgentPoolAgent struct {
Id int64
Enabled bool
MaxParallelism int64
Name string
OsDescription string
ProvisioningState string
Status string
Version string
CreatedOn time.Time
AssignedRequest JobRequest
Id int64
Enabled bool
MaxParallelism int64
Name string
OsDescription string
SystemCapabilities map[string]string
ProvisioningState string
Status string
Version string
CreatedOn time.Time
AssignedRequest JobRequest
}

type JobRequest struct {
Expand Down Expand Up @@ -160,7 +161,7 @@ func (c *AzureDevopsClient) ListAgentPoolAgents(agentPoolId int64) (list AgentPo
c.concurrencyLock()

url := fmt.Sprintf(
"/_apis/distributedtask/pools/%v/agents?includeCapabilities=false&includeAssignedRequest=true",
"/_apis/distributedtask/pools/%v/agents?includeCapabilities=true&includeAssignedRequest=true",
fmt.Sprintf("%d", agentPoolId),
)
response, err := c.rest().R().Get(url)
Expand Down
22 changes: 12 additions & 10 deletions metrics_agentpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (m *MetricsCollectorAgentPool) Setup(collector *collector.Collector) {
"provisioningState",
"maxParallelism",
"agentPoolAgentOs",
"agentPoolAgentComputerName",
"enabled",
"status",
"hasAssignedRequest",
Expand Down Expand Up @@ -183,16 +184,17 @@ func (m *MetricsCollectorAgentPool) collectAgentQueues(ctx context.Context, logg
for _, agentPoolAgent := range list.List {
agentPoolSize++
infoLabels := prometheus.Labels{
"agentPoolID": int64ToString(agentPoolId),
"agentPoolAgentID": int64ToString(agentPoolAgent.Id),
"agentPoolAgentName": agentPoolAgent.Name,
"agentPoolAgentVersion": agentPoolAgent.Version,
"provisioningState": agentPoolAgent.ProvisioningState,
"maxParallelism": int64ToString(agentPoolAgent.MaxParallelism),
"agentPoolAgentOs": agentPoolAgent.OsDescription,
"enabled": to.BoolString(agentPoolAgent.Enabled),
"status": agentPoolAgent.Status,
"hasAssignedRequest": to.BoolString(agentPoolAgent.AssignedRequest.RequestId > 0),
"agentPoolID": int64ToString(agentPoolId),
"agentPoolAgentID": int64ToString(agentPoolAgent.Id),
"agentPoolAgentName": agentPoolAgent.Name,
"agentPoolAgentVersion": agentPoolAgent.Version,
"provisioningState": agentPoolAgent.ProvisioningState,
"maxParallelism": int64ToString(agentPoolAgent.MaxParallelism),
"agentPoolAgentOs": agentPoolAgent.OsDescription,
"agentPoolAgentComputerName": agentPoolAgent.SystemCapabilities["Agent.ComputerName"],
"enabled": to.BoolString(agentPoolAgent.Enabled),
"status": agentPoolAgent.Status,
"hasAssignedRequest": to.BoolString(agentPoolAgent.AssignedRequest.RequestId > 0),
}

agentPoolAgentMetric.Add(infoLabels, 1)
Expand Down