|
1 | 1 | --- |
2 | 2 | title: ASP.NET Core metrics |
3 | | -description: Metrics for ASP.NET Core apps |
| 3 | +ai-usage: ai-assisted |
4 | 4 | author: tdykstra |
5 | | -ms.author: tdykstra |
| 5 | +description: Metrics for ASP.NET Core apps |
6 | 6 | monikerRange: '>= aspnetcore-8.0' |
7 | | -ms.date: 10/18/2023 |
| 7 | +ms.author: tdykstra |
| 8 | +ms.date: 11/10/2025 |
8 | 9 | ms.topic: article |
9 | 10 | uid: log-mon/metrics/metrics |
10 | 11 | --- |
@@ -256,12 +257,57 @@ The proceeding test: |
256 | 257 |
|
257 | 258 | * Bootstraps a web app in memory with <xref:Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory%601>. `Program` in the factory's generic argument specifies the web app. |
258 | 259 | * Collects metrics values with <xref:Microsoft.Extensions.Diagnostics.Metrics.Testing.MetricCollector%601> |
259 | | - * Requires a package reference to `Microsoft.Extensions.Diagnostics.Testing` |
| 260 | + * Requires a package reference to `Microsoft.Extensions.Diagnostics.Testing`. |
260 | 261 | * The `MetricCollector<T>` is created using the web app's <xref:System.Diagnostics.Metrics.IMeterFactory>. This allows the collector to only report metrics values recorded by test. |
261 | 262 | * Includes the meter name, `Microsoft.AspNetCore.Hosting`, and counter name, `http.server.request.duration` to collect. |
262 | 263 | * Makes an HTTP request to the web app. |
263 | 264 | * Asserts the test using results from the metrics collector. |
264 | 265 |
|
| 266 | +:::moniker range=">= aspnetcore-10.0" |
| 267 | + |
| 268 | +## ASP.NET Core Identity metrics |
| 269 | + |
| 270 | +ASP.NET Core Identity observability help you monitor user management activities and authentication processes. |
| 271 | + |
| 272 | +The metrics are in the `Microsoft.AspNetCore.Identity` meter and are described in the following sections. |
| 273 | + |
| 274 | +### User management metrics |
| 275 | + |
| 276 | +* `aspnetcore.identity.user.create.duration` measures the duration of user creation operations. |
| 277 | +* `aspnetcore.identity.user.update.duration` measures the duration of user update operations. |
| 278 | +* `aspnetcore.identity.user.delete.duration` measures the duration of user deletion operations |
| 279 | +* `aspnetcore.identity.user.check_password_attempts` counts password verification attempts. |
| 280 | +* `aspnetcore.identity.user.generated_tokens` counts tokens generated for users, such as password reset tokens. |
| 281 | +* `aspnetcore.identity.user.verify_token_attempts` counts token verification attempts. |
| 282 | + |
| 283 | +### Authentication metrics |
| 284 | + |
| 285 | +* `aspnetcore.identity.sign_in.authenticate.duration` measures the duration of authentication operations. |
| 286 | +* `aspnetcore.identity.sign_in.check_password_attempts` counts password check attempts during sign-in. |
| 287 | +* `aspnetcore.identity.sign_in.sign_ins` counts successful sign-ins. |
| 288 | +* `aspnetcore.identity.sign_in.sign_outs` counts sign-outs. |
| 289 | +* `aspnetcore.identity.sign_in.two_factor_clients_remembered` counts remembered two-factor clients. |
| 290 | +* `aspnetcore.identity.sign_in.two_factor_clients_forgotten` counts forgotten two-factor clients. |
| 291 | + |
| 292 | +These metrics can be used to: |
| 293 | + |
| 294 | +* Monitor user registration and management. |
| 295 | +* Track authentication patterns and potential security issues. |
| 296 | +* Measure performance of Identity operations. |
| 297 | +* Observe two-factor authentication usage. |
| 298 | + |
| 299 | +### Viewing Identity metrics |
| 300 | + |
| 301 | +You can view these metrics using `dotnet-counters` to monitor them in real-time or export them to Prometheus and visualize them in Grafana using the techniques described earlier in this article. |
| 302 | + |
| 303 | +For example, to monitor all Identity metrics with `dotnet-counters`: |
| 304 | + |
| 305 | +```dotnetcli |
| 306 | +dotnet-counters monitor -n YourAppName --counters Microsoft.AspNetCore.Identity |
| 307 | +``` |
| 308 | + |
| 309 | +:::moniker-end |
| 310 | + |
265 | 311 | ## ASP.NET Core meters and counters |
266 | 312 |
|
267 | 313 | See [ASP.NET Core metrics](/dotnet/core/diagnostics/built-in-metrics-aspnetcore) for a list of ASP.NET Core meters and counters. |
0 commit comments