From 7f6fa31c8a560703b392ac0b716849a1c63b47d6 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sat, 10 Aug 2024 14:55:17 +0200 Subject: [PATCH] Added client environment info to the prometheus metrics as labels. --- cmd/converge/prometheus.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/cmd/converge/prometheus.go b/cmd/converge/prometheus.go index 3870913..e2cf08e 100644 --- a/cmd/converge/prometheus.go +++ b/cmd/converge/prometheus.go @@ -45,7 +45,15 @@ var ( Name: "agent_info", Help: "A flexible gauge with dynamic labels, always set to 1", }, - []string{"guid", "id", "username", "hostname", "pwd", "os", "shell"}) // Label names + []string{ + "guid", + "id", + "username", + "hostname", + "pwd", + "os", + "shell", + }) clientInfo = promauto.NewGaugeVec( prometheus.GaugeOpts{ @@ -53,7 +61,16 @@ var ( Name: "client_info", Help: "A flexible gauge with dynamic labels, always set to 1", }, - []string{"guid", "id", "agentid", "sessiontype"}, // Label names + []string{"guid", + "id", + "agentid", + "sessiontype", + "username", + "hostname", + "pwd", + "os", + "shell", + }, // Label names ) ) @@ -75,6 +92,11 @@ func clientLabels(client models.Client) prometheus.Labels { "id": client.ClientId, "agentid": client.PublicId, "sessiontype": client.SessionType, + "username": client.EnvironmentInfo.Username, + "hostname": client.EnvironmentInfo.Hostname, + "pwd": client.EnvironmentInfo.Pwd, + "os": client.EnvironmentInfo.OS, + "shell": client.EnvironmentInfo.Shell, } }