Added client environment info to the prometheus metrics as labels.

This commit is contained in:
Erik Brakkee 2024-08-10 14:55:17 +02:00
parent 346996e761
commit 7f6fa31c8a

View File

@ -45,7 +45,15 @@ var (
Name: "agent_info", Name: "agent_info",
Help: "A flexible gauge with dynamic labels, always set to 1", 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( clientInfo = promauto.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
@ -53,7 +61,16 @@ var (
Name: "client_info", Name: "client_info",
Help: "A flexible gauge with dynamic labels, always set to 1", 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, "id": client.ClientId,
"agentid": client.PublicId, "agentid": client.PublicId,
"sessiontype": client.SessionType, "sessiontype": client.SessionType,
"username": client.EnvironmentInfo.Username,
"hostname": client.EnvironmentInfo.Hostname,
"pwd": client.EnvironmentInfo.Pwd,
"os": client.EnvironmentInfo.OS,
"shell": client.EnvironmentInfo.Shell,
} }
} }