|
1 | 1 | :::moniker range=">= aspnetcore-10.0" |
2 | 2 |
|
3 | 3 | This article describes the metrics built-in for ASP.NET Core produced using the |
4 | | -<xref:System.Diagnostics.Metrics?displayProperty=nameWithType> API. For a listing of metrics based on the older [EventCounters](/dotnet/core/diagnostics/event-counters) API,see [Available counters](/dotnet/core/diagnostics/available-counters). |
| 4 | +<xref:System.Diagnostics.Metrics?displayProperty=nameWithType> API. For a listing of metrics based on the older [EventCounters](/dotnet/core/diagnostics/event-counters) API, see [Available counters](/dotnet/core/diagnostics/available-counters). |
5 | 5 |
|
6 | 6 | See [Using ASP.NET Core metrics](xref:log-mon/metrics/metrics) for information about how to collect, report, enrich, and test ASP.NET Core metrics |
7 | 7 |
|
@@ -400,4 +400,98 @@ As this metric is tracking the connection duration, and ideally SignalR connecti |
400 | 400 | | `signalr.transport` | string | [SignalR transport type](https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md) | `web_sockets`; `long_polling` | Always | |
401 | 401 |
|
402 | 402 | . |
| 403 | + |
| 404 | +## `Microsoft.AspNetCore.Authorization` |
| 405 | + |
| 406 | +The `Microsoft.AspNetCore.Authorization` metrics report information about [Authorization attempts](xref:security/authorization/introduction) in ASP.NET Core apps: |
| 407 | + |
| 408 | +#### Metric: `aspnetcore.authorization.attempts` |
| 409 | + |
| 410 | +| Name | Instrument Type | Unit (UCUM) | Description | |
| 411 | +| -------- | --------------- | ----------- | -------------- | |
| 412 | +| `aspnetcore.authorization.attempts` <!--(https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-aspnetcore-metrics/)--> | Counter | `{request}` | The total number of requests for which authorization was attempted. | |
| 413 | + |
| 414 | +| Attribute | Type | Description | Examples | Presence | |
| 415 | +|---|---|---|---|---| |
| 416 | +| `user.is_authenticated` | boolean | Whether the request came from an authenticated user | `true` | `Required` | |
| 417 | +| `aspnetcore.authorization.policy` | string | The name of the authorization policy. | `AtLeast21`; `EmployeeOnly` | `Conditionally required` if an authorization policy is used | |
| 418 | +| `aspnetcore.authorization.result` | string | Whether the authorization succeeded or failed. | `success`; `failure` | `Conditionally Required` if an exception is not thrown during authorization | |
| 419 | +| `error.type` | string | The full name of the exception type. | `System.InvalidOperationException`; `Contoso.MyException` | `Conditionally Required` if the request has ended with an error | |
| 420 | + |
| 421 | +. |
| 422 | + |
| 423 | +## `Microsoft.AspNetCore.Authentication` |
| 424 | + |
| 425 | +The `Microsoft.AspNetCore.Authentication` metrics report information about [Authentication](xref:security/authentication/index) in ASP.NET Core apps: |
| 426 | + |
| 427 | +- [`aspnetcore.authentication.authenticate.duration`](#metric-aspnetcoreauthenticationauthenticateduration) |
| 428 | +- [`aspnetcore.authentication.challenges`](#metric-aspnetcoreauthenticationchallenges) |
| 429 | +- [`aspnetcore.authentication.forbids`](#metric-aspnetcoreauthenticationforbids) |
| 430 | +- [`aspnetcore.authentication.sign_ins`](#metric-aspnetcoreauthenticationsign_ins) |
| 431 | +- [`aspnetcore.authentication.sign_outs`](#metric-aspnetcoreauthenticationsign_outs) |
| 432 | + |
| 433 | +#### Metric: `aspnetcore.authentication.authenticate.duration` |
| 434 | + |
| 435 | +| Name | Instrument Type | Unit (UCUM) | Description | |
| 436 | +| -------- | --------------- | ----------- | -------------- | |
| 437 | +| `aspnetcore.authentication.authenticate.duration` <!--(https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-aspnetcore-metrics/)--> | Histogram | `s` | The authentication duration for a request. | |
| 438 | + |
| 439 | +| Attribute | Type | Description | Examples | Presence | |
| 440 | +|---|---|---|---|---| |
| 441 | +| `aspnetcore.authentication.result` | string | The authentication result. | `success`; `failure`; `none`; `_OTHER` | `Conditionally Required` if the request did not end with an error | |
| 442 | +| `aspnetcore.authentication.scheme` | string | The name of the authentication scheme. | `Bearer`; `Cookies` | `Conditionally Required` if the request did not end with an error | |
| 443 | +| `error.type` | string | The full name of the exception type. | `System.InvalidOperationException`; `Contoso.MyException` | `Conditionally Required` if authentication failed or the request has ended with an error | |
| 444 | + |
| 445 | +. |
| 446 | + |
| 447 | +#### Metric: `aspnetcore.authentication.challenges` |
| 448 | + |
| 449 | +| Name | Instrument Type | Unit (UCUM) | Description | |
| 450 | +| -------- | --------------- | ----------- | -------------- | |
| 451 | +| `aspnetcore.authentication.challenges` <!--(https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-aspnetcore-metrics/)--> | Counter | `{request}` | The total number of times a scheme is challenged. | |
| 452 | + |
| 453 | +| Attribute | Type | Description | Examples | Presence | |
| 454 | +|---|---|---|---|---| |
| 455 | +| `aspnetcore.authentication.scheme` | string | The name of the authentication scheme. | `Bearer`; `Cookies` | `Conditionally Required` if the request did not end with an error | |
| 456 | +| `error.type` | string | The full name of the exception type. | `System.InvalidOperationException`; `Contoso.MyException` | `Conditionally Required` if the request has ended with an error | |
| 457 | + |
| 458 | +. |
| 459 | + |
| 460 | +#### Metric: `aspnetcore.authentication.forbids` |
| 461 | + |
| 462 | +| Name | Instrument Type | Unit (UCUM) | Description | |
| 463 | +| -------- | --------------- | ----------- | -------------- | |
| 464 | +| `aspnetcore.authentication.forbids` <!--(https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-aspnetcore-metrics/)--> | Counter | `{request}` | The total number of times an authenticated user attempts to access a resource they aren't permitted to access. | |
| 465 | + |
| 466 | +| Attribute | Type | Description | Examples | Presence | |
| 467 | +|---|---|---|---|---| |
| 468 | +| `aspnetcore.authentication.scheme` | string | The name of the authentication scheme. | `Bearer`; `Cookies` | `Conditionally Required` if the request did not end with an error | |
| 469 | +| `error.type` | string | The full name of the exception type. | `System.InvalidOperationException`; `Contoso.MyException` | `Conditionally Required` if the request has ended with an error | |
| 470 | + |
| 471 | +. |
| 472 | + |
| 473 | +#### Metric: `aspnetcore.authentication.sign_ins` |
| 474 | + |
| 475 | +| Name | Instrument Type | Unit (UCUM) | Description | |
| 476 | +| -------- | --------------- | ----------- | -------------- | |
| 477 | +| `aspnetcore.authentication.sign_ins` <!--(https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-aspnetcore-metrics/)--> | Counter | `{request}` | The total number of times a principal is signed in with a scheme. | |
| 478 | + |
| 479 | +| Attribute | Type | Description | Examples | Presence | |
| 480 | +|---|---|---|---|---| |
| 481 | +| `aspnetcore.authentication.scheme` | string | The name of the authentication scheme. | `Bearer`; `Cookies` | `Conditionally Required` if the request did not end with an error | |
| 482 | +| `error.type` | string | The full name of the exception type. | `System.InvalidOperationException`; `Contoso.MyException` | `Conditionally Required` if the request has ended with an error | |
| 483 | + |
| 484 | +. |
| 485 | + |
| 486 | +#### Metric: `aspnetcore.authentication.sign_outs` |
| 487 | + |
| 488 | +| Name | Instrument Type | Unit (UCUM) | Description | |
| 489 | +| -------- | --------------- | ----------- | -------------- | |
| 490 | +| `aspnetcore.authentication.sign_outs` <!--(https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-aspnetcore-metrics/)--> | Counter | `{request}` | The total number of times a principal is signed out with a scheme. | |
| 491 | + |
| 492 | +| Attribute | Type | Description | Examples | Presence | |
| 493 | +|---|---|---|---|---| |
| 494 | +| `aspnetcore.authentication.scheme` | string | The name of the authentication scheme. | `Bearer`; `Cookies` | `Conditionally Required` if the request did not end with an error | |
| 495 | +| `error.type` | string | The full name of the exception type. | `System.InvalidOperationException`; `Contoso.MyException` | `Conditionally Required` if the request has ended with an error | |
| 496 | + |
403 | 497 | :::moniker-end |
0 commit comments