Hey! I have been working on windows metrics for quite some time now. The collection process has already been debugged, and details are starting to disappear from memory, and therefore it is time to transfer the knowledge gained, so to speak, to paper. The article will be about what happened, what was delivered, how to work with it, what rakes and crutches will be for them. Along the way, we'll touch on .net clr, asp.net, wcf, iis, signalr, etw and something else. An article for those who are in the subject, well, or almost ...
At the moment, metrics in windows can be divided into two systems: performance counters (let it be legacy) and event counters (fashionable and youthful).
Performance counters are not just a sandwich, but a whole salad of different ingredients and tons of entry points to work with them.
And as you can see from the diagram, everything is reduced to one PDH point, although you can poll the components at any level: be it advapi, registry or perflib.
, , , ( prometheus), ( PDH) - , , , - ... , grafana , , , : w3wp#101, _LM_W3SVC_1001_ROOT, --62, C400001640000001, Service@||Service.svc. - . - - . , :
Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance
On the Edit menu, click New , and then click DWORD Value .
Right-click New Value #1 , click Rename , and then type ProcessNameFormat to name the new value.
Right-click ProcessNameFormat , and then click Modify .
In the Data value box, type one of the following values, and then click OK :
1 : Disables PID data. This value is the default value.
2 : Enables PID data.
Right-click New Value #1 , click Rename , and then type ProcessNameFormat to name the new value. Right-click ProcessNameFormat , and then click Modify.
1 : Disables PID data. This value is the default value.
2 : Enables PID data.
: PID_ProcessName. , , - ( ), . "".
, ...
Process
, , , IIS (w3wp), - w3wp#101 . - ID Process, PID`a . ...
-, ( ), , , : 100 150, , , , .. 150 149 (w3wp#149).
-, performance NtQueryInformationProcess ( ), , , - .
[
"\\\\localhost\\Process(w3wp#100)\\ID Process",
"\\\\localhost\\Process(w3wp#101)\\ID Process",
...
]
, , . .net ETW. , , ( , ). .
ASP.NET Applications
_LM_W3SVC_1001_ROOT, 1001 - IIS. , , , , PID, ID . , ( ).
IIS. : xml, - , . XmlDocument. ...
const string section = "/configuration/system.applicationHost/sites/site"
XmlNodeList nodes = doc.DocumentElement.SelectNodes(section);
foreach (XmlNode node in nodes)
{
w3svcs.TryAdd($"_LM_W3SVC_{node.Attributes["id"].Value}_ROOT", node.Attributes["name"].Value);
}
ServiceModelService 4.0.0.0
WCF , - , . , SVC , . - , , , . . , grafana.
HTTP Service Url Groups
- C400001640000001. , . - , . , :
netsh http show servicestate view=requestq verbose=no
Request queue name: Request queue is unnamed.
Version: 2.0
State: Active
Request queue 503 verbosity level: Basic
Max requests: 1000
Number of active processes attached: 1
Process IDs:
33800
URL groups:
URL group ID: C400001640000001
State: Active
Request queue name: Request queue is unnamed.
Number of registered URLs: 1
Registered URLs:
HTTP://+:80/health/
Server session ID: EF00001020000031
Version: 2.0
State: Active
: URL group ID ( ) Process IDs, .
, API URL groups, (Server session ID), , , .
, . , , , "@"Process\sIDs:[^\d]?(\d+).?URL\sgroup\sID:\s([a-zA-Z0-9]+)", - , , .
SignalR
performance counters. , . "" : , . .
The performance counters system is full of mysteries and mysteries. It is not easy to work with it, and, unfortunately, many new products (in fact, like microsoft itself) continue to actively use it. The article turned out to be not small, many things may seem incomprehensible, and the implementation details are not disclosed.
Event Counters I decided to move to another part ... Questions are welcome !!!