Diagnostic - Create Or Update
建立新的診斷或更新現有的診斷。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}?api-version=2024-05-01
URI 參數
名稱 | 位於 | 必要 | 類型 | Description |
---|---|---|---|---|
diagnostic
|
path | True |
string minLength: 1maxLength: 80 pattern: ^[^*#&+:<>?]+$ |
診斷標識碼。 目前 API 管理服務實例中必須是唯一的。 |
resource
|
path | True |
string minLength: 1maxLength: 90 |
資源群組的名稱。 名稱不區分大小寫。 |
service
|
path | True |
string minLength: 1maxLength: 50 pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$ |
API 管理服務的名稱。 |
subscription
|
path | True |
string (uuid) |
目標訂用帳戶的標識碼。 此值必須是 UUID。 |
api-version
|
query | True |
string minLength: 1 |
要用於這項作業的 API 版本。 |
要求標頭
名稱 | 必要 | 類型 | Description |
---|---|---|---|
If-Match |
string |
實體的 ETag。 建立實體時不需要,但在更新實體時則為必要專案。 |
要求本文
名稱 | 必要 | 類型 | Description |
---|---|---|---|
properties.loggerId | True |
string |
目標記錄器的資源識別碼。 |
properties.alwaysLog |
指定不應該套用何種類型的訊息取樣設定。 |
||
properties.backend |
傳入/傳出 HTTP 訊息至後端的診斷設定 |
||
properties.frontend |
傳入/傳出 HTTP 訊息至閘道的診斷設定。 |
||
properties.httpCorrelationProtocol |
設定要用於Application Insights診斷的相互關聯通訊協定。 |
||
properties.logClientIp |
boolean |
記錄 ClientIP。 默認值為 false。 |
|
properties.metrics |
boolean |
透過發出計量原則發出自定義計量。 僅適用於 Application Insights 診斷設定。 |
|
properties.operationNameFormat |
Application Insights 遙測作業名稱的格式。 預設值為 Name。 |
||
properties.sampling |
診斷的取樣設定。 |
||
properties.verbosity |
套用至追蹤原則所發出之追蹤的詳細資訊層級。 |
回應
名稱 | 類型 | Description |
---|---|---|
200 OK |
診斷已成功更新 標題 ETag: string |
|
201 Created |
已成功建立診斷。 標題 ETag: string |
|
Other Status Codes |
描述作業失敗原因的錯誤回應。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
名稱 | Description |
---|---|
user_impersonation | 模擬您的用戶帳戶 |
範例
ApiManagementCreateDiagnostic
範例要求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/applicationinsights?api-version=2024-05-01
{
"properties": {
"alwaysLog": "allErrors",
"loggerId": "/loggers/azuremonitor",
"sampling": {
"samplingType": "fixed",
"percentage": 50
},
"frontend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
},
"backend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
}
}
}
範例回覆
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/applicationinsights",
"type": "Microsoft.ApiManagement/service/diagnostics",
"name": "applicationinsights",
"properties": {
"alwaysLog": "allErrors",
"loggerId": "/loggers/azuremonitor",
"sampling": {
"samplingType": "fixed",
"percentage": 50
},
"frontend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
},
"backend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/applicationinsights",
"type": "Microsoft.ApiManagement/service/diagnostics",
"name": "applicationinsights",
"properties": {
"alwaysLog": "allErrors",
"loggerId": "/loggers/applicationinsights",
"sampling": {
"samplingType": "fixed",
"percentage": 50
},
"frontend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
},
"backend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
}
}
}
定義
名稱 | Description |
---|---|
Always |
指定不應該套用何種類型的訊息取樣設定。 |
Body |
本文記錄設定。 |
Data |
|
Data |
|
Data |
數據遮罩模式。 |
Diagnostic |
診斷詳細數據。 |
Error |
資源管理錯誤其他資訊。 |
Error |
錯誤詳細數據。 |
Error |
錯誤回應 |
Http |
設定要用於Application Insights診斷的相互關聯通訊協定。 |
Http |
Http 訊息診斷設定。 |
Operation |
Application Insights 遙測作業名稱的格式。 預設值為 Name。 |
Pipeline |
傳入/傳出 HTTP 訊息至閘道的診斷設定。 |
Sampling |
診斷的取樣設定。 |
Sampling |
取樣類型。 |
Verbosity |
套用至追蹤原則所發出之追蹤的詳細資訊層級。 |
AlwaysLog
指定不應該套用何種類型的訊息取樣設定。
值 | Description |
---|---|
allErrors |
不論取樣設定為何,請一律記錄所有錯誤的要求。 |
BodyDiagnosticSettings
本文記錄設定。
名稱 | 類型 | Description |
---|---|---|
bytes |
integer (int32) maximum: 8192 |
要記錄的要求本文字節數目。 |
DataMasking
名稱 | 類型 | Description |
---|---|---|
headers |
標頭的遮罩設定 |
|
queryParams |
Url 查詢參數的遮罩設定 |
DataMaskingEntity
名稱 | 類型 | Description |
---|---|---|
mode |
數據遮罩模式。 |
|
value |
string |
要遮罩的實體名稱(例如標頭的名稱或查詢參數)。 |
DataMaskingMode
數據遮罩模式。
值 | Description |
---|---|
Hide |
隱藏實體的存在。 |
Mask |
遮罩實體的值。 |
DiagnosticContract
診斷詳細數據。
名稱 | 類型 | Description |
---|---|---|
id |
string |
資源的完整資源標識碼。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
name |
string |
資源的名稱 |
properties.alwaysLog |
指定不應該套用何種類型的訊息取樣設定。 |
|
properties.backend |
傳入/傳出 HTTP 訊息至後端的診斷設定 |
|
properties.frontend |
傳入/傳出 HTTP 訊息至閘道的診斷設定。 |
|
properties.httpCorrelationProtocol |
設定要用於Application Insights診斷的相互關聯通訊協定。 |
|
properties.logClientIp |
boolean |
記錄 ClientIP。 默認值為 false。 |
properties.loggerId |
string |
目標記錄器的資源識別碼。 |
properties.metrics |
boolean |
透過發出計量原則發出自定義計量。 僅適用於 Application Insights 診斷設定。 |
properties.operationNameFormat |
Application Insights 遙測作業名稱的格式。 預設值為 Name。 |
|
properties.sampling |
診斷的取樣設定。 |
|
properties.verbosity |
套用至追蹤原則所發出之追蹤的詳細資訊層級。 |
|
type |
string |
資源的型別。 例如“Microsoft.Compute/virtualMachines” 或 “Microsoft.Storage/storageAccounts” |
ErrorAdditionalInfo
資源管理錯誤其他資訊。
名稱 | 類型 | Description |
---|---|---|
info |
object |
其他資訊。 |
type |
string |
其他信息類型。 |
ErrorDetail
錯誤詳細數據。
名稱 | 類型 | Description |
---|---|---|
additionalInfo |
錯誤其他資訊。 |
|
code |
string |
錯誤碼。 |
details |
錯誤詳細數據。 |
|
message |
string |
錯誤訊息。 |
target |
string |
錯誤目標。 |
ErrorResponse
錯誤回應
名稱 | 類型 | Description |
---|---|---|
error |
error 物件。 |
HttpCorrelationProtocol
設定要用於Application Insights診斷的相互關聯通訊協定。
值 | Description |
---|---|
Legacy |
使用要求相互關聯數據插入 Request-Id 和 Request-Context 標頭。 請參閱 https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md。 |
None |
請勿讀取並插入相互關聯標頭。 |
W3C |
插入追蹤內容標頭。 請參閱 https://w3c.github.io/trace-context。 |
HttpMessageDiagnostic
Http 訊息診斷設定。
名稱 | 類型 | Description |
---|---|---|
body |
本文記錄設定。 |
|
dataMasking |
數據遮罩設定。 |
|
headers |
string[] |
要記錄的 HTTP 標頭陣列。 |
OperationNameFormat
Application Insights 遙測作業名稱的格式。 預設值為 Name。
值 | Description |
---|---|
Name |
API_NAME;rev=API_REVISION - OPERATION_NAME |
Url |
HTTP_VERB URL |
PipelineDiagnosticSettings
傳入/傳出 HTTP 訊息至閘道的診斷設定。
名稱 | 類型 | Description |
---|---|---|
request |
要求的診斷設定。 |
|
response |
回應的診斷設定。 |
SamplingSettings
診斷的取樣設定。
名稱 | 類型 | Description |
---|---|---|
percentage |
number (double) minimum: 0maximum: 100 |
固定速率取樣的取樣率。 |
samplingType |
取樣類型。 |
SamplingType
取樣類型。
值 | Description |
---|---|
fixed |
固定速率取樣。 |
Verbosity
套用至追蹤原則所發出之追蹤的詳細資訊層級。
值 | Description |
---|---|
error |
只有 'severity' 設定為 'error' 的追蹤才會傳送至附加至此診斷實例的記錄器。 |
information |
將 [嚴重性] 設定為 'information' 和 'error' 的追蹤將會傳送至附加至此診斷實例的記錄器。 |
verbose |
追蹤原則發出的所有追蹤都會傳送至附加至此診斷實例的記錄器。 |