06 Sep 2023 11:41 PM - last edited on 12 Dec 2023 02:49 PM by Ana_Kuzmenchuk
Running
Get-WmiObject -Query "SELECT * FROM MSFT_NetTCPConnection where localport=443" -namespace "root\StandardCIMV2"
locally gives a list of data that is very big. I have been able to reduce it by grouping:
Get-WmiObject -Query "SELECT * FROM MSFT_NetTCPConnection where localport=443" -namespace "root\StandardCIMV2" | Group-Object LocalPort
Wondering though how can I do it efficiently with the WMI v2 extensions ?
BTW, the idea is to have metrics for the number of established web connections (I'll probably filter additionally by state...).
Solved! Go to Solution.
12 Dec 2023 04:14 PM
You could make the query more manageable by trimming down the query down to just the required properties with something like:
Get-WmiObject -Query "SELECT Name, OwningProcess, LocalPort FROM MSFT_NetTCPConnection where localport=443" -namespace "root\StandardCIMV2"
But unfortunately piping to Group-Object to get a total is not supported by the data source.
Have you looked at the metrics provided by:
Get-WmiObject -query "SELECT ConnectionsActive, ConnectionsEstablished, ConnectionFailures, ConnectionsPassive, ConnectionsReset FROM Win32_PerfFormattedData_Tcpip_TCPv4"
They may not be fine grain enough for what you need though. If they work, they are counter metrics so you need to handle them as such:
metrics:
- key: com.dynatrace.extension.host-observability.network.tcp.connections.active
value: column:ConnectionsActive
type: count