24 Oct 2024 08:50 AM
Hi team,
Is it possible to get the number of currently connected hosts to an ActiveGate using DQL?
The number is in the deployment status page, when you select an ActiveGate under properties, but I was wondering if it is possible to get it via DQL.
The metric dsfm:active_gate.communication.agent_modules.connected gives you the number of connected OneAgent modules but not the hosts.
Thanks in advance!
29 Oct 2024 08:25 AM - edited 29 Oct 2024 08:26 AM
Okay this is not a 100% what you're asking for, but you can summarize the agents/hosts split by network zone, so this would be the same if you only have one ActiveGate per network zone (yea strong assumption here...).
fetch dt.entity.host
| summarize OneAgents=count(), by:{networkZone}
More of a potential workaround/quick fix but maybe it helps.
29 Oct 2024 08:31 AM
Hi Marina,
Thank you for your answer. However, there are more than 1 ActiveGates per Network Zone. What we did in the end is use Javascript:
import { activeGatesClient } from '@dynatrace-sdk/client-classic-environment-v2';
export default async function () {
let nextPageKey;
do {
const config = nextPageKey ? { nextPageKey: nextPageKey } : {
hostname: "AGNAME"
}
const res = await activeGatesClient.getAllActiveGates(config);
nextPageKey = res.nextPageKey;
return res.activeGates[0].connectedHosts;
} while (nextPageKey);
}
29 Oct 2024 08:34 AM - edited 29 Oct 2024 08:48 AM
timeseries by:{dt.active_gate.id}, connected_OneAgents = sum(dt.sfm.active_gate.communication.agent_modules.connected)
|FieldsKeep dt.active_gate.id, connected_OneAgents
?
29 Oct 2024 08:46 AM
The problem here is this metric provides the number of modules connected, not the agents. If the agent has more than one module, the number is much higher.
29 Oct 2024 08:48 AM - edited 29 Oct 2024 09:20 AM
I think this is the closest I can get for now 😞 Maybe if we can append the related entity and make a unique count we could be getting somewhere.