Crie uma nova regra de Alerta do Log de Atividades ou atualize uma existente.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}?api-version=2020-10-01
Parâmetros de URI
Nome |
Em |
Obrigatório |
Tipo |
Description |
activityLogAlertName
|
path |
True
|
string
|
O nome da regra de Alerta do Log de Atividades.
|
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos. O nome diferencia maiúsculas de minúsculas.
|
subscriptionId
|
path |
True
|
string
|
A ID da assinatura de destino.
|
api-version
|
query |
True
|
string
|
A versão da API a ser usada para esta operação.
|
Corpo da solicitação
Nome |
Obrigatório |
Tipo |
Description |
properties.actions
|
True
|
ActionList
|
As ações que serão ativadas quando a condição for atendida.
|
properties.condition
|
True
|
AlertRuleAllOfCondition
|
A condição que fará com que esse alerta seja ativado.
|
properties.scopes
|
True
|
string[]
|
Uma lista de IDs de recurso que serão usadas como prefixos. O alerta só se aplicará a eventos do Log de Atividades com IDs de recurso que se enquadram em um desses prefixos. Essa lista deve incluir pelo menos um item.
|
location
|
|
string
|
A localização do recurso. As regras de Alerta do Log de Atividades do Azure têm suporte nas regiões Global, Oeste da Europa e Norte da Europa.
|
properties.description
|
|
string
|
Uma descrição desta regra de Alerta do Log de Atividades.
|
properties.enabled
|
|
boolean
|
Indica se essa regra de Alerta do Log de Atividades está habilitada. Se uma regra de Alerta do Log de Atividades não estiver habilitada, nenhuma de suas ações será ativada.
|
tags
|
|
object
|
As marcas do recurso.
|
Respostas
Nome |
Tipo |
Description |
200 OK
|
ActivityLogAlertResource
|
Uma regra de Alerta do Log de Atividades existente foi atualizada com êxito.
|
201 Created
|
ActivityLogAlertResource
|
Uma nova regra de Alerta do Log de Atividades foi criada com êxito.
|
Other Status Codes
|
ErrorResponse
|
Ocorreu um erro e não foi possível criar nem atualizar a regra de Alerta do Log de Atividades.
|
Segurança
azure_auth
Fluxo do OAuth2 do Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Escopos
Nome |
Description |
user_impersonation
|
representar sua conta de usuário
|
Exemplos
Create or update an Activity Log Alert rule
Solicitação de exemplo
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
Resposta de exemplo
{
"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
Solicitação de exemplo
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
Resposta de exemplo
{
"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'
Solicitação de exemplo
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
Resposta de exemplo
{
"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'."
}
}
Definições
Nome |
Description |
ActionGroup
|
Um ponteiro para um Grupo de Ações do Azure.
|
ActionList
|
Uma lista de ações de regra de alerta do log de atividades.
|
ActivityLogAlertResource
|
Um recurso de regra de alerta do log de atividades.
|
AlertRuleAllOfCondition
|
Uma condição de regra de alerta do Log de Atividades que é atendida quando todas as suas condições de membro são atendidas.
|
AlertRuleAnyOfOrLeafCondition
|
Uma condição de regra de alerta do Log de Atividades que é atendida quando todas as suas condições de membro são atendidas.
Cada condição pode ser de um dos seguintes tipos: Importante: cada tipo tem seu subconjunto exclusivo de propriedades. Propriedades de tipos diferentes NÃO podem existir em uma condição.
-
Condição folha – deve conter 'field' e 'equals' ou 'containsAny'.
Observe que 'anyOf' não deve ser definido em uma Condição folha.
-
Condição AnyOf – deve conter apenas 'anyOf' (que é uma matriz de condições folha).
Observe que 'field', 'equals' e 'containsAny' não devem ser definidos em uma condição AnyOf.
|
AlertRuleLeafCondition
|
Uma condição de regra de alerta do log de atividades que é atendida comparando o campo e o valor de um evento do Log de Atividades.
Essa condição deve conter 'field' e 'equals' ou 'containsAny'.
|
ErrorResponse
|
A resposta de erro.
|
ActionGroup
Um ponteiro para um Grupo de Ações do Azure.
Nome |
Tipo |
Description |
actionGroupId
|
string
|
A ID do recurso do Grupo de Ações. Isso não pode ser nulo ou vazio.
|
webhookProperties
|
object
|
o dicionário de propriedades personalizadas a serem incluídas com a operação pós-operação. Esses dados são acrescentados ao conteúdo do webhook.
|
ActionList
Uma lista de ações de regra de alerta do log de atividades.
Nome |
Tipo |
Description |
actionGroups
|
ActionGroup[]
|
A lista dos Grupos de Ações.
|
ActivityLogAlertResource
Um recurso de regra de alerta do log de atividades.
Nome |
Tipo |
Valor padrão |
Description |
id
|
string
|
|
A ID do recurso.
|
location
|
string
|
global
|
A localização do recurso. As regras de Alerta do Log de Atividades do Azure têm suporte nas regiões Global, Oeste da Europa e Norte da Europa.
|
name
|
string
|
|
O nome do recurso.
|
properties.actions
|
ActionList
|
|
As ações que serão ativadas quando a condição for atendida.
|
properties.condition
|
AlertRuleAllOfCondition
|
|
A condição que fará com que esse alerta seja ativado.
|
properties.description
|
string
|
|
Uma descrição desta regra de Alerta do Log de Atividades.
|
properties.enabled
|
boolean
|
True
|
Indica se essa regra de Alerta do Log de Atividades está habilitada. Se uma regra de Alerta do Log de Atividades não estiver habilitada, nenhuma de suas ações será ativada.
|
properties.scopes
|
string[]
|
|
Uma lista de IDs de recurso que serão usadas como prefixos. O alerta só se aplicará a eventos do Log de Atividades com IDs de recurso que se enquadram em um desses prefixos. Essa lista deve incluir pelo menos um item.
|
tags
|
object
|
|
As marcas do recurso.
|
type
|
string
|
|
Tipo do recurso.
|
AlertRuleAllOfCondition
Uma condição de regra de alerta do Log de Atividades que é atendida quando todas as suas condições de membro são atendidas.
AlertRuleAnyOfOrLeafCondition
Uma condição de regra de alerta do Log de Atividades que é atendida quando todas as suas condições de membro são atendidas.
Cada condição pode ser de um dos seguintes tipos: Importante: cada tipo tem seu subconjunto exclusivo de propriedades. Propriedades de tipos diferentes NÃO podem existir em uma condição.
-
Condição folha – deve conter 'field' e 'equals' ou 'containsAny'.
Observe que 'anyOf' não deve ser definido em uma Condição folha.
-
Condição AnyOf – deve conter apenas 'anyOf' (que é uma matriz de condições folha).
Observe que 'field', 'equals' e 'containsAny' não devem ser definidos em uma condição AnyOf.
Nome |
Tipo |
Description |
anyOf
|
AlertRuleLeafCondition[]
|
Uma condição de Alerta do Log de Atividades 'anyOf'.
Uma condição de regra de alerta do log de atividades que é atendida quando pelo menos uma de suas condições folha membro é atendida.
|
containsAny
|
string[]
|
O valor do campo do evento será comparado com os valores nessa matriz (que não diferencia maiúsculas de minúsculas) para determinar se a condição é atendida.
|
equals
|
string
|
O valor do campo do evento será comparado a esse valor (que não diferencia maiúsculas de minúsculas) para determinar se a condição foi atendida.
|
field
|
string
|
O nome do campo do evento log de atividades que essa condição examinará.
Os valores possíveis para esse campo são (que não diferencia maiúsculas de minúsculas): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType' ou qualquer coisa que comece com 'properties'.
|
AlertRuleLeafCondition
Uma condição de regra de alerta do log de atividades que é atendida comparando o campo e o valor de um evento do Log de Atividades.
Essa condição deve conter 'field' e 'equals' ou 'containsAny'.
Nome |
Tipo |
Description |
containsAny
|
string[]
|
O valor do campo do evento será comparado com os valores nessa matriz (que não diferencia maiúsculas de minúsculas) para determinar se a condição é atendida.
|
equals
|
string
|
O valor do campo do evento será comparado a esse valor (que não diferencia maiúsculas de minúsculas) para determinar se a condição foi atendida.
|
field
|
string
|
O nome do campo do evento log de atividades que essa condição examinará.
Os valores possíveis para esse campo são (que não diferencia maiúsculas de minúsculas): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType' ou qualquer coisa que comece com 'properties'.
|
ErrorResponse
A resposta de erro.
Nome |
Tipo |
Description |
code
|
string
|
O código de erro.
|
message
|
string
|
A mensagem de erro que indica por que a operação falhou.
|