Skip to content

Add connected agents metric

Tiger Watson requested to merge update-agent-usage-metrics into master

What does this MR do and why?

Adds a new metric to count the number of currently connected agents.

Query changes

The following queries are generated by distinct_count. All queries are able to use the existing index_cluster_agent_tokens_on_agent_id_status_last_used_at:

Min - explain:

SELECT 
  MIN(
    "cluster_agent_tokens"."agent_id"
  ) 
FROM 
  "cluster_agent_tokens" 
WHERE 
  "cluster_agent_tokens"."status" = 0 
  AND (
    last_used_at > '2023-08-07 02:13:14.220756'
  )

Max - explain:

SELECT 
  MAX(
    "cluster_agent_tokens"."agent_id"
  ) 
FROM 
  "cluster_agent_tokens" 
WHERE 
  "cluster_agent_tokens"."status" = 0 
  AND (
    last_used_at > '2023-08-07 02:13:14.220756'
  )

Batch - explain:

SELECT 
  COUNT(
   "cluster_agent_tokens"."agent_id"
  ) 
FROM 
  "cluster_agent_tokens" 
WHERE 
  "cluster_agent_tokens"."status" = 0 
  AND (
    last_used_at > '2023-08-22 03:10:04'
  ) 
  AND "cluster_agent_tokens"."agent_id" >= 0 
  AND "cluster_agent_tokens"."agent_id" < 10000

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to gitlab-org/configure/general#297

Edited by Tiger Watson

Merge request reports