获取指定资源的活动诊断设置。
GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}?api-version=2021-05-01-preview
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
name
|
path |
True
|
string
|
诊断设置的名称。
|
resourceUri
|
path |
True
|
string
|
资源的标识符。
|
api-version
|
query |
True
|
string
|
要用于此操作的 API 版本。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
Gets the diagnostic setting
示例请求
GET https://management.azure.com/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/Microsoft.Insights/diagnosticSettings/mysetting?api-version=2021-05-01-preview
/**
* Samples for DiagnosticSettingsOperation Get.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/
* getDiagnosticSetting.json
*/
/**
* Sample code: Gets the diagnostic setting.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getsTheDiagnosticSetting(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getDiagnosticSettingsOperations().getWithResponse(
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6",
"mysetting", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json
func ExampleDiagnosticSettingsClient_Get_getsTheDiagnosticSetting() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDiagnosticSettingsClient().Get(ctx, "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", "mysetting", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.DiagnosticSettingsResource = armmonitor.DiagnosticSettingsResource{
// Name: to.Ptr("mysetting"),
// Type: to.Ptr("Microsoft.Insights/diagnosticSettings"),
// ID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/microsoft.insights/diagnosticSettings/mysetting"),
// Properties: &armmonitor.DiagnosticSettings{
// EventHubAuthorizationRuleID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"),
// Logs: []*armmonitor.LogSettings{
// {
// CategoryGroup: to.Ptr("allLogs"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// MarketplacePartnerID: to.Ptr("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"),
// Metrics: []*armmonitor.MetricSettings{
// {
// Category: to.Ptr("WorkflowMetrics"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// StorageAccountID: to.Ptr("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"),
// WorkspaceID: to.Ptr(""),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets the active diagnostic settings for the specified resource.
*
* @summary Gets the active diagnostic settings for the specified resource.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json
*/
async function getsTheDiagnosticSetting() {
const resourceUri =
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
const name = "mysetting";
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential);
const result = await client.diagnosticSettings.get(resourceUri, name);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json
// this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this DiagnosticSettingResource created on azure
// for more information of creating DiagnosticSettingResource, please refer to the document of DiagnosticSettingResource
string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
string name = "mysetting";
ResourceIdentifier diagnosticSettingResourceId = DiagnosticSettingResource.CreateResourceIdentifier(resourceUri, name);
DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId);
// invoke the operation
DiagnosticSettingResource result = await diagnosticSetting.GetAsync();
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
DiagnosticSettingData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/microsoft.insights/diagnosticSettings/mysetting",
"type": "Microsoft.Insights/diagnosticSettings",
"name": "mysetting",
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"categoryGroup": "allLogs",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
Gets the diagnostic setting for category
示例请求
GET https://management.azure.com/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/Microsoft.Insights/diagnosticSettings/mysetting?api-version=2021-05-01-preview
/**
* Samples for DiagnosticSettingsOperation Get.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/
* getDiagnosticSettingCategory.json
*/
/**
* Sample code: Gets the diagnostic setting for category.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getsTheDiagnosticSettingForCategory(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getDiagnosticSettingsOperations().getWithResponse(
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6",
"mysetting", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json
func ExampleDiagnosticSettingsClient_Get_getsTheDiagnosticSettingForCategory() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDiagnosticSettingsClient().Get(ctx, "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", "mysetting", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.DiagnosticSettingsResource = armmonitor.DiagnosticSettingsResource{
// Name: to.Ptr("mysetting"),
// Type: to.Ptr(""),
// ID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/diagnosticSettings/service"),
// Properties: &armmonitor.DiagnosticSettings{
// EventHubAuthorizationRuleID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"),
// Logs: []*armmonitor.LogSettings{
// {
// Category: to.Ptr("WorkflowRuntime"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// MarketplacePartnerID: to.Ptr("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"),
// Metrics: []*armmonitor.MetricSettings{
// {
// Category: to.Ptr("WorkflowMetrics"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// StorageAccountID: to.Ptr("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"),
// WorkspaceID: to.Ptr(""),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets the active diagnostic settings for the specified resource.
*
* @summary Gets the active diagnostic settings for the specified resource.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json
*/
async function getsTheDiagnosticSettingForCategory() {
const resourceUri =
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
const name = "mysetting";
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential);
const result = await client.diagnosticSettings.get(resourceUri, name);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json
// this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this DiagnosticSettingResource created on azure
// for more information of creating DiagnosticSettingResource, please refer to the document of DiagnosticSettingResource
string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
string name = "mysetting";
ResourceIdentifier diagnosticSettingResourceId = DiagnosticSettingResource.CreateResourceIdentifier(resourceUri, name);
DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId);
// invoke the operation
DiagnosticSettingResource result = await diagnosticSetting.GetAsync();
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
DiagnosticSettingData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/diagnosticSettings/service",
"type": "",
"name": "mysetting",
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"category": "WorkflowRuntime",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
定义
createdByType
创建资源的标识类型。
名称 |
类型 |
说明 |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DiagnosticSettingsResource
诊断设置资源。
名称 |
类型 |
说明 |
id
|
string
|
资源的完全限定的资源 ID。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
资源的名称
|
properties.eventHubAuthorizationRuleId
|
string
|
事件中心授权规则的资源 ID。
|
properties.eventHubName
|
string
|
事件中心的名称。 如果未指定,则将选择默认事件中心。
|
properties.logAnalyticsDestinationType
|
string
|
一个字符串,指示导出到 Log Analytics 是应使用默认目标类型(即 AzureDiagnostics),还是使用构造如下的目标类型:_。 可能的值为:Dedicated 和 null (null 为 default.)
|
properties.logs
|
LogSettings[]
|
日志设置的列表。
|
properties.marketplacePartnerId
|
string
|
要向其发送诊断日志的市场资源的完整 ARM 资源 ID。
|
properties.metrics
|
MetricSettings[]
|
指标设置的列表。
|
properties.serviceBusRuleId
|
string
|
诊断设置的服务总线规则 ID。 这是为了保持向后兼容性。
|
properties.storageAccountId
|
string
|
要向其发送诊断日志的存储帐户的资源 ID。
|
properties.workspaceId
|
string
|
要向其发送诊断日志的 Log Analytics 工作区的完整 ARM 资源 ID。 示例:/subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2
|
systemData
|
systemData
|
与此资源相关的系统元数据。
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
ErrorResponse
描述错误响应的格式。
名称 |
类型 |
说明 |
code
|
string
|
错误代码
|
message
|
string
|
指示操作失败原因的错误消息。
|
LogSettings
MultiTenantDiagnosticSettings 的一部分。 指定特定日志的设置。
名称 |
类型 |
说明 |
category
|
string
|
此设置应用于的资源类型的诊断日志类别的名称。 若要获取资源的诊断日志类别列表,请先执行 GET 诊断设置操作。
|
categoryGroup
|
string
|
应用此设置的资源类型的诊断日志类别组的名称。 若要获取资源的诊断日志类别列表,请先执行 GET 诊断设置操作。
|
enabled
|
boolean
|
一个值,该值指示是否启用此日志。
|
retentionPolicy
|
RetentionPolicy
|
此日志的保留策略。
|
MetricSettings
MultiTenantDiagnosticSettings 的一部分。 指定特定指标的设置。
名称 |
类型 |
说明 |
category
|
string
|
应用此设置的资源类型的诊断指标类别的名称。 若要获取资源的诊断指标类别列表,请先执行 GET 诊断设置操作。
|
enabled
|
boolean
|
一个值,该值指示是否启用此类别。
|
retentionPolicy
|
RetentionPolicy
|
此类别的保留策略。
|
timeGrain
|
string
|
指标的时间基元,采用ISO8601格式。
|
RetentionPolicy
指定日志的保留策略。
名称 |
类型 |
说明 |
days
|
integer
|
保留天数(以天为单位)。 值为 0 将无限期保留事件。
|
enabled
|
boolean
|
指示是否启用保留策略的值。
|
systemData
与资源的创建和上次修改相关的元数据。
名称 |
类型 |
说明 |
createdAt
|
string
|
资源创建时间戳 (UTC) 。
|
createdBy
|
string
|
创建资源的标识。
|
createdByType
|
createdByType
|
创建资源的标识类型。
|
lastModifiedAt
|
string
|
资源上次修改的时间戳 (UTC)
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识类型。
|