What is the correct way to calculate number of DNS queries/second using Get-DnsServerStatistics?

Viewed 332

I am trying to figure out how to get the number of DNS queries/second for each domain controller using PowerShell Get-DnsServerStatistics. I copied some of the relevant outputs below.

I try to figure out what is the time period of getting 11793847 "TotalQueries" ?

Under section "TimeStatistics," does the field "TimeElapsedSinceLastClearStatisticsBetweenRestart" with value 00:00:28 means 28 seconds? There is another field "TimeElapsedSinceServerStart" has value 34.01:35:21 and I don't understand what it means? maybe 34 days 1 hour 35 min 21 second? But if there are 28 seconds with total 11793847 DNS queries. i.e. 421208 queries/second is seems not true in our environment. Could you please help me out?

TimeStatistics:
==============

**TimeElapsedSinceLastClearedStatisticsBetweenRestart     00:00:28**
LastClearTime                                           9/7/2021 9:33:20 PM
ServerStartTime                                         9/7/2021 9:33:20 PM
TimeElapsedSinceLastClearedStatistics                   34.01:35:21
TimeElapsedSinceServerStartBetweenRestart               00:00:28
**TimeElapsedSinceServerStart                             34.01:35:21**

Query2Statistics:
================

TypeAll                                                 1917
TKeyNego                                                0
TypeOther                                               897431
**TotalQueries                                            11793847**
1 Answers

Your assumptions about the time formats are correct. The *BetweenRestart times are the offline times of your DNS service. The time you are looking for is

TimeElapsedSinceLastClearedStatistics - TimeElapsedSinceLastClearedStatisticsBetweenRestart

This is the timespan in which your DNS service was actually answering queries (34.01:34:53). I recommend to parse the timespans into TimeSpan objects using [System.TimeSpan]::Parse("34.01:35:21"), for example. Then you can easily subtract the timespans like shown above.

The resulting timespan object offers you the TotalSeconds member attribute, which you can use for your ratio calculation (your ratio is about 4 queries/s).

Related