Vytvořte nové pravidlo upozornění protokolu aktivit nebo aktualizujte existující pravidlo.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}?api-version=2020-10-01
Parametry identifikátoru URI
Name |
V |
Vyžadováno |
Typ |
Description |
activityLogAlertName
|
path |
True
|
string
|
Název pravidla upozornění protokolu aktivit.
|
resourceGroupName
|
path |
True
|
string
|
Název skupiny prostředků. V názvu se rozlišují malá a velká písmena.
|
subscriptionId
|
path |
True
|
string
|
ID cílového předplatného.
|
api-version
|
query |
True
|
string
|
Verze rozhraní API, která se má použít pro tuto operaci.
|
Text požadavku
Name |
Vyžadováno |
Typ |
Description |
properties.actions
|
True
|
ActionList
|
Akce, které se aktivují při splnění podmínky.
|
properties.condition
|
True
|
AlertRuleAllOfCondition
|
Podmínka, která způsobí aktivaci tohoto upozornění.
|
properties.scopes
|
True
|
string[]
|
Seznam ID prostředků, které se použijí jako předpony. Upozornění se bude vztahovat pouze na události protokolu aktivit s ID prostředků, které spadají pod jednu z těchto předpon. Tento seznam musí obsahovat alespoň jednu položku.
|
location
|
|
string
|
Umístění prostředku. Pravidla upozornění protokolu aktivit Azure se podporují v oblastech Globální, Západní Evropa a Severní Evropa.
|
properties.description
|
|
string
|
Popis tohoto pravidla upozornění protokolu aktivit.
|
properties.enabled
|
|
boolean
|
Označuje, jestli je toto pravidlo upozornění protokolu aktivit povolené. Pokud pravidlo upozornění protokolu aktivit není povolené, nebude aktivována žádná z jeho akcí.
|
tags
|
|
object
|
Značky prostředku.
|
Odpovědi
Name |
Typ |
Description |
200 OK
|
ActivityLogAlertResource
|
Existující pravidlo upozornění protokolu aktivit bylo úspěšně aktualizováno.
|
201 Created
|
ActivityLogAlertResource
|
Nové pravidlo upozornění protokolu aktivit bylo úspěšně vytvořeno.
|
Other Status Codes
|
ErrorResponse
|
Došlo k chybě a pravidlo upozornění protokolu aktivit nebylo možné vytvořit nebo aktualizovat.
|
Zabezpečení
azure_auth
Tok Azure Active Directory OAuth2
Typ:
oauth2
Tok:
implicit
URL autorizace:
https://login.microsoftonline.com/common/oauth2/authorize
Rozsahy
Name |
Description |
user_impersonation
|
zosobnění uživatelského účtu
|
Příklady
Create or update an Activity Log Alert rule
Ukázkový požadavek
PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRule?api-version=2020-10-01
{
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "Administrative"
},
{
"field": "level",
"equals": "Error"
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule."
}
}
import com.azure.resourcemanager.monitor.fluent.models.ActivityLogAlertResourceInner;
import com.azure.resourcemanager.monitor.models.ActionList;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertActionGroup;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertAllOfCondition;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertLeafCondition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ActivityLogAlerts CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/
* ActivityLogAlertRule_CreateOrUpdate.json
*/
/**
* Sample code: Create or update an Activity Log Alert rule.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateAnActivityLogAlertRule(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getActivityLogAlerts().createOrUpdateWithResponse(
"MyResourceGroup", "SampleActivityLogAlertRule",
new ActivityLogAlertResourceInner().withLocation("Global").withTags(mapOf())
.withScopes(Arrays.asList("/subscriptions/187f412d-1758-44d9-b052-169e2564721d"))
.withCondition(new ActivityLogAlertAllOfCondition().withAllOf(Arrays.asList(
new ActivityLogAlertLeafCondition().withField("category").withEquals("Administrative"),
new ActivityLogAlertLeafCondition().withField("level").withEquals("Error"))))
.withActions(new ActionList().withActionGroups(Arrays.asList(new ActivityLogAlertActionGroup()
.withActionGroupId(
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")
.withWebhookProperties(mapOf("sampleWebhookProperty", "SamplePropertyValue")))))
.withEnabled(true).withDescription("Description of sample Activity Log Alert rule."),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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/azcore/to"
"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/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdate.json
func ExampleActivityLogAlertsClient_CreateOrUpdate_createOrUpdateAnActivityLogAlertRule() {
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.NewActivityLogAlertsClient().CreateOrUpdate(ctx, "MyResourceGroup", "SampleActivityLogAlertRule", armmonitor.ActivityLogAlertResource{
Location: to.Ptr("Global"),
Tags: map[string]*string{},
Properties: &armmonitor.AlertRuleProperties{
Description: to.Ptr("Description of sample Activity Log Alert rule."),
Actions: &armmonitor.ActionList{
ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
{
ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
WebhookProperties: map[string]*string{
"sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
},
}},
},
Condition: &armmonitor.AlertRuleAllOfCondition{
AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
{
Equals: to.Ptr("Administrative"),
Field: to.Ptr("category"),
},
{
Equals: to.Ptr("Error"),
Field: to.Ptr("level"),
}},
},
Enabled: to.Ptr(true),
Scopes: []*string{
to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
},
}, 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.ActivityLogAlertResource = armmonitor.ActivityLogAlertResource{
// Name: to.Ptr("SampleActivityLogAlertRule"),
// Type: to.Ptr("Microsoft.Insights/ActivityLogAlerts"),
// ID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule"),
// Location: to.Ptr("Global"),
// Tags: map[string]*string{
// },
// Properties: &armmonitor.AlertRuleProperties{
// Description: to.Ptr("Description of sample Activity Log Alert rule."),
// Actions: &armmonitor.ActionList{
// ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
// {
// ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup"),
// WebhookProperties: map[string]*string{
// "sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
// },
// }},
// },
// Condition: &armmonitor.AlertRuleAllOfCondition{
// AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
// {
// Equals: to.Ptr("Administrative"),
// Field: to.Ptr("Category"),
// },
// {
// Equals: to.Ptr("Error"),
// Field: to.Ptr("Level"),
// }},
// },
// Enabled: to.Ptr(true),
// Scopes: []*string{
// to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
// },
// }
}
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 Create a new Activity Log Alert rule or update an existing one.
*
* @summary Create a new Activity Log Alert rule or update an existing one.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdate.json
*/
async function createOrUpdateAnActivityLogAlertRule() {
const subscriptionId =
process.env["MONITOR_SUBSCRIPTION_ID"] || "187f412d-1758-44d9-b052-169e2564721d";
const resourceGroupName = process.env["MONITOR_RESOURCE_GROUP"] || "MyResourceGroup";
const activityLogAlertName = "SampleActivityLogAlertRule";
const activityLogAlertRule = {
description: "Description of sample Activity Log Alert rule.",
actions: {
actionGroups: [
{
actionGroupId:
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
webhookProperties: { sampleWebhookProperty: "SamplePropertyValue" },
},
],
},
condition: {
allOf: [
{ equals: "Administrative", field: "category" },
{ equals: "Error", field: "level" },
],
},
enabled: true,
location: "Global",
scopes: ["/subscriptions/187f412d-1758-44d9-b052-169e2564721d"],
tags: {},
};
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential, subscriptionId);
const result = await client.activityLogAlerts.createOrUpdate(
resourceGroupName,
activityLogAlertName,
activityLogAlertRule,
);
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.Resources;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdate.json
// this example is just showing the usage of "ActivityLogAlerts_CreateOrUpdate" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d";
string resourceGroupName = "MyResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ActivityLogAlertResource
ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts();
// invoke the operation
string activityLogAlertName = "SampleActivityLogAlertRule";
ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global"))
{
Scopes =
{
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d"
},
ConditionAllOf =
{
new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "category",
EqualsValue = "Administrative",
},new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "level",
EqualsValue = "Error",
}
},
ActionsActionGroups =
{
new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"))
{
WebhookProperties =
{
["sampleWebhookProperty"] = "SamplePropertyValue",
},
}
},
IsEnabled = true,
Description = "Description of sample Activity Log Alert rule.",
Tags =
{
},
};
ArmOperation<ActivityLogAlertResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data);
ActivityLogAlertResource result = lro.Value;
// 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
ActivityLogAlertData 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
Ukázková odpověď
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRule",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "Category",
"equals": "Administrative"
},
{
"field": "Level",
"equals": "Error"
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule."
}
}
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRule",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "Category",
"equals": "Administrative"
},
{
"field": "Level",
"equals": "Error"
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule."
}
}
Create or update an Activity Log Alert rule with 'anyOf' condition
Ukázkový požadavek
PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition?api-version=2020-10-01
{
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident"
},
{
"field": "properties.incidentType",
"equals": "Maintenance"
}
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
}
}
import com.azure.resourcemanager.monitor.fluent.models.ActivityLogAlertResourceInner;
import com.azure.resourcemanager.monitor.models.ActionList;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertActionGroup;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertAllOfCondition;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertLeafCondition;
import com.azure.resourcemanager.monitor.models.AlertRuleLeafCondition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ActivityLogAlerts CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/
* ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
*/
/**
* Sample code: Create or update an Activity Log Alert rule with 'anyOf' condition.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateAnActivityLogAlertRuleWithAnyOfCondition(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getActivityLogAlerts().createOrUpdateWithResponse(
"MyResourceGroup", "SampleActivityLogAlertRuleWithAnyOfCondition",
new ActivityLogAlertResourceInner().withLocation("Global").withTags(mapOf())
.withScopes(Arrays.asList("subscriptions/187f412d-1758-44d9-b052-169e2564721d"))
.withCondition(new ActivityLogAlertAllOfCondition().withAllOf(Arrays.asList(
new ActivityLogAlertLeafCondition().withField("category").withEquals("ServiceHealth"),
new ActivityLogAlertLeafCondition().withAnyOf(Arrays.asList(
new AlertRuleLeafCondition().withField("properties.incidentType").withEquals("Incident"),
new AlertRuleLeafCondition().withField("properties.incidentType").withEquals("Maintenance"))))))
.withActions(new ActionList().withActionGroups(Arrays.asList(new ActivityLogAlertActionGroup()
.withActionGroupId(
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")
.withWebhookProperties(mapOf("sampleWebhookProperty", "SamplePropertyValue")))))
.withEnabled(true)
.withDescription("Description of sample Activity Log Alert rule with 'anyOf' condition."),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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/azcore/to"
"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/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
func ExampleActivityLogAlertsClient_CreateOrUpdate_createOrUpdateAnActivityLogAlertRuleWithAnyOfCondition() {
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.NewActivityLogAlertsClient().CreateOrUpdate(ctx, "MyResourceGroup", "SampleActivityLogAlertRuleWithAnyOfCondition", armmonitor.ActivityLogAlertResource{
Location: to.Ptr("Global"),
Tags: map[string]*string{},
Properties: &armmonitor.AlertRuleProperties{
Description: to.Ptr("Description of sample Activity Log Alert rule with 'anyOf' condition."),
Actions: &armmonitor.ActionList{
ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
{
ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
WebhookProperties: map[string]*string{
"sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
},
}},
},
Condition: &armmonitor.AlertRuleAllOfCondition{
AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
{
Equals: to.Ptr("ServiceHealth"),
Field: to.Ptr("category"),
},
{
AnyOf: []*armmonitor.AlertRuleLeafCondition{
{
Equals: to.Ptr("Incident"),
Field: to.Ptr("properties.incidentType"),
},
{
Equals: to.Ptr("Maintenance"),
Field: to.Ptr("properties.incidentType"),
}},
}},
},
Enabled: to.Ptr(true),
Scopes: []*string{
to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
},
}, 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.ActivityLogAlertResource = armmonitor.ActivityLogAlertResource{
// Name: to.Ptr("SampleActivityLogAlertRuleWithAnyOfCondition"),
// Type: to.Ptr("Microsoft.Insights/ActivityLogAlerts"),
// ID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition"),
// Location: to.Ptr("Global"),
// Tags: map[string]*string{
// },
// Properties: &armmonitor.AlertRuleProperties{
// Description: to.Ptr("Description of sample Activity Log Alert rule with 'anyOf' condition."),
// Actions: &armmonitor.ActionList{
// ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
// {
// ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
// WebhookProperties: map[string]*string{
// "sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
// },
// }},
// },
// Condition: &armmonitor.AlertRuleAllOfCondition{
// AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
// {
// Equals: to.Ptr("ServiceHealth"),
// Field: to.Ptr("category"),
// },
// {
// AnyOf: []*armmonitor.AlertRuleLeafCondition{
// {
// Equals: to.Ptr("Incident"),
// Field: to.Ptr("properties.incidentType"),
// },
// {
// Equals: to.Ptr("Maintenance"),
// Field: to.Ptr("properties.incidentType"),
// }},
// }},
// },
// Enabled: to.Ptr(true),
// Scopes: []*string{
// to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
// },
// }
}
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 Create a new Activity Log Alert rule or update an existing one.
*
* @summary Create a new Activity Log Alert rule or update an existing one.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
*/
async function createOrUpdateAnActivityLogAlertRuleWithAnyOfCondition() {
const subscriptionId =
process.env["MONITOR_SUBSCRIPTION_ID"] || "187f412d-1758-44d9-b052-169e2564721d";
const resourceGroupName = process.env["MONITOR_RESOURCE_GROUP"] || "MyResourceGroup";
const activityLogAlertName = "SampleActivityLogAlertRuleWithAnyOfCondition";
const activityLogAlertRule = {
description: "Description of sample Activity Log Alert rule with 'anyOf' condition.",
actions: {
actionGroups: [
{
actionGroupId:
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
webhookProperties: { sampleWebhookProperty: "SamplePropertyValue" },
},
],
},
condition: {
allOf: [
{ equals: "ServiceHealth", field: "category" },
{
anyOf: [
{ equals: "Incident", field: "properties.incidentType" },
{ equals: "Maintenance", field: "properties.incidentType" },
],
},
],
},
enabled: true,
location: "Global",
scopes: ["subscriptions/187f412d-1758-44d9-b052-169e2564721d"],
tags: {},
};
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential, subscriptionId);
const result = await client.activityLogAlerts.createOrUpdate(
resourceGroupName,
activityLogAlertName,
activityLogAlertRule,
);
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.Resources;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
// this example is just showing the usage of "ActivityLogAlerts_CreateOrUpdate" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d";
string resourceGroupName = "MyResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ActivityLogAlertResource
ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts();
// invoke the operation
string activityLogAlertName = "SampleActivityLogAlertRuleWithAnyOfCondition";
ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global"))
{
Scopes =
{
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
},
ConditionAllOf =
{
new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "category",
EqualsValue = "ServiceHealth",
},new ActivityLogAlertAnyOfOrLeafCondition()
{
AnyOf =
{
new AlertRuleLeafCondition()
{
Field = "properties.incidentType",
EqualsValue = "Incident",
},new AlertRuleLeafCondition()
{
Field = "properties.incidentType",
EqualsValue = "Maintenance",
}
},
}
},
ActionsActionGroups =
{
new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"))
{
WebhookProperties =
{
["sampleWebhookProperty"] = "SamplePropertyValue",
},
}
},
IsEnabled = true,
Description = "Description of sample Activity Log Alert rule with 'anyOf' condition.",
Tags =
{
},
};
ArmOperation<ActivityLogAlertResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data);
ActivityLogAlertResource result = lro.Value;
// 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
ActivityLogAlertData 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
Ukázková odpověď
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithAnyOfCondition",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident"
},
{
"field": "properties.incidentType",
"equals": "Maintenance"
}
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
}
}
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithAnyOfCondition",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident"
},
{
"field": "properties.incidentType",
"equals": "Maintenance"
}
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
}
}
Create or update an Activity Log Alert rule with 'containsAny'
Ukázkový požadavek
PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny?api-version=2020-10-01
{
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
"containsAny": [
"North Europe",
"West Europe"
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'containsAny'."
}
}
import com.azure.resourcemanager.monitor.fluent.models.ActivityLogAlertResourceInner;
import com.azure.resourcemanager.monitor.models.ActionList;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertActionGroup;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertAllOfCondition;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertLeafCondition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ActivityLogAlerts CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/
* ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
*/
/**
* Sample code: Create or update an Activity Log Alert rule with 'containsAny'.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateAnActivityLogAlertRuleWithContainsAny(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getActivityLogAlerts()
.createOrUpdateWithResponse("MyResourceGroup", "SampleActivityLogAlertRuleWithContainsAny",
new ActivityLogAlertResourceInner().withLocation("Global").withTags(mapOf())
.withScopes(Arrays.asList("subscriptions/187f412d-1758-44d9-b052-169e2564721d"))
.withCondition(new ActivityLogAlertAllOfCondition().withAllOf(Arrays.asList(
new ActivityLogAlertLeafCondition().withField("category").withEquals("ServiceHealth"),
new ActivityLogAlertLeafCondition()
.withField("properties.impactedServices[*].ImpactedRegions[*].RegionName")
.withContainsAny(Arrays.asList("North Europe", "West Europe")))))
.withActions(new ActionList().withActionGroups(Arrays.asList(new ActivityLogAlertActionGroup()
.withActionGroupId(
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")
.withWebhookProperties(mapOf("sampleWebhookProperty", "SamplePropertyValue")))))
.withEnabled(true)
.withDescription("Description of sample Activity Log Alert rule with 'containsAny'."),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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/azcore/to"
"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/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
func ExampleActivityLogAlertsClient_CreateOrUpdate_createOrUpdateAnActivityLogAlertRuleWithContainsAny() {
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.NewActivityLogAlertsClient().CreateOrUpdate(ctx, "MyResourceGroup", "SampleActivityLogAlertRuleWithContainsAny", armmonitor.ActivityLogAlertResource{
Location: to.Ptr("Global"),
Tags: map[string]*string{},
Properties: &armmonitor.AlertRuleProperties{
Description: to.Ptr("Description of sample Activity Log Alert rule with 'containsAny'."),
Actions: &armmonitor.ActionList{
ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
{
ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
WebhookProperties: map[string]*string{
"sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
},
}},
},
Condition: &armmonitor.AlertRuleAllOfCondition{
AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
{
Equals: to.Ptr("ServiceHealth"),
Field: to.Ptr("category"),
},
{
ContainsAny: []*string{
to.Ptr("North Europe"),
to.Ptr("West Europe")},
Field: to.Ptr("properties.impactedServices[*].ImpactedRegions[*].RegionName"),
}},
},
Enabled: to.Ptr(true),
Scopes: []*string{
to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
},
}, 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.ActivityLogAlertResource = armmonitor.ActivityLogAlertResource{
// Name: to.Ptr("SampleActivityLogAlertRuleWithContainsAny"),
// Type: to.Ptr("Microsoft.Insights/ActivityLogAlerts"),
// ID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny"),
// Location: to.Ptr("Global"),
// Tags: map[string]*string{
// },
// Properties: &armmonitor.AlertRuleProperties{
// Description: to.Ptr("Description of sample Activity Log Alert rule with 'containsAny'."),
// Actions: &armmonitor.ActionList{
// ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
// {
// ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
// WebhookProperties: map[string]*string{
// "sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
// },
// }},
// },
// Condition: &armmonitor.AlertRuleAllOfCondition{
// AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
// {
// Equals: to.Ptr("ServiceHealth"),
// Field: to.Ptr("category"),
// },
// {
// ContainsAny: []*string{
// to.Ptr("North Europe"),
// to.Ptr("West Europe")},
// Field: to.Ptr("properties.impactedServices[*].ImpactedRegions[*].RegionName"),
// }},
// },
// Enabled: to.Ptr(true),
// Scopes: []*string{
// to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
// },
// }
}
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 Create a new Activity Log Alert rule or update an existing one.
*
* @summary Create a new Activity Log Alert rule or update an existing one.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
*/
async function createOrUpdateAnActivityLogAlertRuleWithContainsAny() {
const subscriptionId =
process.env["MONITOR_SUBSCRIPTION_ID"] || "187f412d-1758-44d9-b052-169e2564721d";
const resourceGroupName = process.env["MONITOR_RESOURCE_GROUP"] || "MyResourceGroup";
const activityLogAlertName = "SampleActivityLogAlertRuleWithContainsAny";
const activityLogAlertRule = {
description: "Description of sample Activity Log Alert rule with 'containsAny'.",
actions: {
actionGroups: [
{
actionGroupId:
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
webhookProperties: { sampleWebhookProperty: "SamplePropertyValue" },
},
],
},
condition: {
allOf: [
{ equals: "ServiceHealth", field: "category" },
{
containsAny: ["North Europe", "West Europe"],
field: "properties.impactedServices[*].ImpactedRegions[*].RegionName",
},
],
},
enabled: true,
location: "Global",
scopes: ["subscriptions/187f412d-1758-44d9-b052-169e2564721d"],
tags: {},
};
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential, subscriptionId);
const result = await client.activityLogAlerts.createOrUpdate(
resourceGroupName,
activityLogAlertName,
activityLogAlertRule,
);
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.Resources;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
// this example is just showing the usage of "ActivityLogAlerts_CreateOrUpdate" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d";
string resourceGroupName = "MyResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ActivityLogAlertResource
ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts();
// invoke the operation
string activityLogAlertName = "SampleActivityLogAlertRuleWithContainsAny";
ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global"))
{
Scopes =
{
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
},
ConditionAllOf =
{
new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "category",
EqualsValue = "ServiceHealth",
},new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "properties.impactedServices[*].ImpactedRegions[*].RegionName",
ContainsAny =
{
"North Europe","West Europe"
},
}
},
ActionsActionGroups =
{
new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"))
{
WebhookProperties =
{
["sampleWebhookProperty"] = "SamplePropertyValue",
},
}
},
IsEnabled = true,
Description = "Description of sample Activity Log Alert rule with 'containsAny'.",
Tags =
{
},
};
ArmOperation<ActivityLogAlertResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data);
ActivityLogAlertResource result = lro.Value;
// 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
ActivityLogAlertData 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
Ukázková odpověď
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithContainsAny",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
"containsAny": [
"North Europe",
"West Europe"
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'containsAny'."
}
}
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithContainsAny",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
"containsAny": [
"North Europe",
"West Europe"
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'containsAny'."
}
}
Definice
Name |
Description |
ActionGroup
|
Ukazatel na skupinu akcí Azure.
|
ActionList
|
Seznam akcí pravidla upozornění protokolu aktivit.
|
ActivityLogAlertResource
|
Prostředek pravidla upozornění protokolu aktivit.
|
AlertRuleAllOfCondition
|
Podmínka pravidla upozornění protokolu aktivit, která je splněna, když jsou splněny všechny jeho členské podmínky.
|
AlertRuleAnyOfOrLeafCondition
|
Podmínka pravidla upozornění protokolu aktivit, která je splněna, když jsou splněny všechny jeho členské podmínky.
Každá podmínka může mít jeden z následujících typů: Důležité: Každý typ má svou jedinečnou podmnožinu vlastností. Vlastnosti z různých typů NEMOHOU existovat v jedné podmínce.
-
Podmínka listu – musí obsahovat pole a buď "rovná se", nebo "containsAny".
Upozorňujeme, že parametr anyOf by neměl být nastaven v podmínce listu.
-
Podmínka AnyOf – musí obsahovat pouze hodnotu anyOf (což je pole podmínek listu).
Mějte na paměti, že "field", "equals" a "containsAny" by neměly být nastaveny v podmínce AnyOf.
|
AlertRuleLeafCondition
|
Podmínka pravidla upozornění protokolu aktivit, která je splněna porovnáním pole a hodnoty události protokolu aktivit.
Tato podmínka musí obsahovat pole a buď "rovná se", nebo "containsAny".
|
ErrorResponse
|
Odpověď na chybu.
|
ActionGroup
Ukazatel na skupinu akcí Azure.
Name |
Typ |
Description |
actionGroupId
|
string
|
ID prostředku skupiny akcí. Tato hodnota nesmí být null nebo prázdná.
|
webhookProperties
|
object
|
slovník vlastních vlastností, které se mají zahrnout do operace post. Tato data jsou připojena k datové části webhooku.
|
ActionList
Seznam akcí pravidla upozornění protokolu aktivit.
Name |
Typ |
Description |
actionGroups
|
ActionGroup[]
|
Seznam skupin akcí.
|
ActivityLogAlertResource
Prostředek pravidla upozornění protokolu aktivit.
Name |
Typ |
Default value |
Description |
id
|
string
|
|
ID prostředku.
|
location
|
string
|
global
|
Umístění prostředku. Pravidla upozornění protokolu aktivit Azure se podporují v oblastech Globální, Západní Evropa a Severní Evropa.
|
name
|
string
|
|
Název prostředku.
|
properties.actions
|
ActionList
|
|
Akce, které se aktivují při splnění podmínky.
|
properties.condition
|
AlertRuleAllOfCondition
|
|
Podmínka, která způsobí aktivaci tohoto upozornění.
|
properties.description
|
string
|
|
Popis tohoto pravidla upozornění protokolu aktivit.
|
properties.enabled
|
boolean
|
True
|
Označuje, jestli je toto pravidlo upozornění protokolu aktivit povolené. Pokud pravidlo upozornění protokolu aktivit není povolené, nebude aktivována žádná z jeho akcí.
|
properties.scopes
|
string[]
|
|
Seznam ID prostředků, které se použijí jako předpony. Upozornění se bude vztahovat pouze na události protokolu aktivit s ID prostředků, které spadají pod jednu z těchto předpon. Tento seznam musí obsahovat alespoň jednu položku.
|
tags
|
object
|
|
Značky prostředku.
|
type
|
string
|
|
Typ prostředku.
|
AlertRuleAllOfCondition
Podmínka pravidla upozornění protokolu aktivit, která je splněna, když jsou splněny všechny jeho členské podmínky.
AlertRuleAnyOfOrLeafCondition
Podmínka pravidla upozornění protokolu aktivit, která je splněna, když jsou splněny všechny jeho členské podmínky.
Každá podmínka může mít jeden z následujících typů: Důležité: Každý typ má svou jedinečnou podmnožinu vlastností. Vlastnosti z různých typů NEMOHOU existovat v jedné podmínce.
-
Podmínka listu – musí obsahovat pole a buď "rovná se", nebo "containsAny".
Upozorňujeme, že parametr anyOf by neměl být nastaven v podmínce listu.
-
Podmínka AnyOf – musí obsahovat pouze hodnotu anyOf (což je pole podmínek listu).
Mějte na paměti, že "field", "equals" a "containsAny" by neměly být nastaveny v podmínce AnyOf.
Name |
Typ |
Description |
anyOf
|
AlertRuleLeafCondition[]
|
Podmínka pravidla upozornění protokolu aktivit anyOf
Podmínka pravidla upozornění protokolu aktivit, která je splněna, pokud je splněna alespoň jedna z podmínek jeho člena listu.
|
containsAny
|
string[]
|
Hodnota pole události bude porovnána s hodnotami v tomto poli (nerozlišují se malá a malá písmena), aby se zjistilo, jestli je podmínka splněna.
|
equals
|
string
|
Hodnota pole události bude porovnána s touto hodnotou (nerozlišují se malá a velká písmena), aby se zjistilo, jestli je podmínka splněna.
|
field
|
string
|
Název pole události protokolu aktivit, které tato podmínka prozkoumá.
Možné hodnoty pro toto pole jsou (nerozlišují se malá a velká písmena): resourceId, category, caller, level, operationName, resourceGroup, resourceProvider, status, subStatus, resourceType nebo cokoli, co začíná na vlastnosti.
|
AlertRuleLeafCondition
Podmínka pravidla upozornění protokolu aktivit, která je splněna porovnáním pole a hodnoty události protokolu aktivit.
Tato podmínka musí obsahovat pole a buď "rovná se", nebo "containsAny".
Name |
Typ |
Description |
containsAny
|
string[]
|
Hodnota pole události bude porovnána s hodnotami v tomto poli (nerozlišují se malá a malá písmena), aby se zjistilo, jestli je podmínka splněna.
|
equals
|
string
|
Hodnota pole události bude porovnána s touto hodnotou (nerozlišují se malá a velká písmena), aby se zjistilo, jestli je podmínka splněna.
|
field
|
string
|
Název pole události protokolu aktivit, které tato podmínka prozkoumá.
Možné hodnoty pro toto pole jsou (nerozlišují se malá a velká písmena): resourceId, category, caller, level, operationName, resourceGroup, resourceProvider, status, subStatus, resourceType nebo cokoli, co začíná na vlastnosti.
|
ErrorResponse
Odpověď na chybu.
Name |
Typ |
Description |
code
|
string
|
Kód chyby
|
message
|
string
|
Chybová zpráva označující, proč operace selhala.
|