{ "swagger": "2.0", "info": { "title": "Microsoft Insights API", "version": "2018-04-16", "description": "Azure Monitor client to create/update/delete Scheduled Query Rules" }, "host": "management.azure.com", "schemes": [ "https" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "security": [ { "azure_auth": [ "user_impersonation" ] } ], "securityDefinitions": { "azure_auth": { "type": "oauth2", "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", "flow": "implicit", "description": "Azure Active Directory OAuth2 Flow", "scopes": { "user_impersonation": "impersonate your user account" } } }, "paths": { "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}": { "put": { "description": "Creates or updates an log search rule.", "tags": [ "scheduledQueryRules" ], "operationId": "ScheduledQueryRules_CreateOrUpdate", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ResourceGroupNameParameter" }, { "$ref": "#/parameters/RuleNameParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" }, { "name": "parameters", "in": "body", "required": true, "schema": { "$ref": "#/definitions/LogSearchRuleResource" }, "description": "The parameters of the rule to create or update." } ], "responses": { "default": { "description": "Error response describing why the operation failed.", "schema": { "$ref": "#/definitions/ErrorContract" } }, "200": { "description": "Successful request to update an Log Search rule", "schema": { "$ref": "#/definitions/LogSearchRuleResource" } }, "201": { "description": "Created alert rule", "schema": { "$ref": "#/definitions/LogSearchRuleResource" } } }, "x-ms-examples": { "Create or Update rule - AlertingAction": { "$ref": "./examples/createOrUpdateScheduledQueryRules.json" }, "Create or Update rule - AlertingAction with Cross-Resource": { "$ref": "./examples/createOrUpdateScheduledQueryRuleswithCrossResource.json" }, "Create or Update rule - LogToMetricAction": { "$ref": "./examples/createOrUpdateScheduledQueryRule-LogToMetricAction.json" } } }, "get": { "description": "Gets an Log Search rule", "tags": [ "scheduledQueryRules" ], "operationId": "ScheduledQueryRules_Get", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ResourceGroupNameParameter" }, { "$ref": "#/parameters/RuleNameParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter" } ], "responses": { "default": { "description": "Error response describing why the operation failed.", "schema": { "$ref": "#/definitions/ErrorContract" } }, "200": { "description": "Successful request to get a Log Search rule", "schema": { "$ref": "#/definitions/LogSearchRuleResource" } } }, "x-ms-examples": { "Get rule": { "$ref": "./examples/getScheduledQueryRules.json" } } }, "patch": { "tags": [ "scheduledQueryRules" ], "description": "Update log search Rule.", "operationId": "ScheduledQueryRules_Update", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ResourceGroupNameParameter" }, { "$ref": "#/parameters/RuleNameParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" }, { "name": "parameters", "in": "body", "required": true, "schema": { "$ref": "#/definitions/LogSearchRuleResourcePatch" }, "description": "The parameters of the rule to update." } ], "responses": { "default": { "description": "Error response describing why the operation failed.", "schema": { "$ref": "#/definitions/ErrorContract" } }, "200": { "description": "Successful request to update an Log Search rule", "schema": { "$ref": "#/definitions/LogSearchRuleResource" } } }, "x-ms-examples": { "Patch Log Search Rule": { "$ref": "./examples/patchScheduledQueryRules.json" } } }, "delete": { "description": "Deletes a Log Search rule", "tags": [ "scheduledQueryRules" ], "operationId": "ScheduledQueryRules_Delete", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ResourceGroupNameParameter" }, { "$ref": "#/parameters/RuleNameParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter" } ], "responses": { "default": { "description": "Error response describing why the operation failed.", "schema": { "$ref": "#/definitions/ErrorContract" } }, "200": { "description": "Successful request to delete a Log Search rule" }, "204": { "description": "No Content. Resource not found" } }, "x-ms-examples": { "Delete rule": { "$ref": "./examples/deleteScheduledQueryRules.json" } } } }, "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules": { "get": { "tags": [ "scheduledQueryRules" ], "operationId": "ScheduledQueryRules_ListBySubscription", "description": "List the Log Search rules within a subscription group.", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" }, { "$ref": "#/parameters/FilterParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter" } ], "responses": { "default": { "description": "Error response describing why the operation failed.", "schema": { "$ref": "#/definitions/ErrorContract" } }, "200": { "description": "Successful request for a list of alert rules", "schema": { "$ref": "#/definitions/LogSearchRuleResourceCollection" } } }, "x-ms-pageable": { "nextLinkName": null }, "x-ms-examples": { "List rules": { "$ref": "./examples/listScheduledQueryRules.json" } }, "x-ms-odata": "#/definitions/LogSearchRuleResource" } }, "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules": { "get": { "tags": [ "scheduledQueryRules" ], "operationId": "ScheduledQueryRules_ListByResourceGroup", "description": "List the Log Search rules within a resource group.", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ResourceGroupNameParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" }, { "$ref": "#/parameters/FilterParameter" }, { "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter" } ], "responses": { "default": { "description": "Error response describing why the operation failed.", "schema": { "$ref": "#/definitions/ErrorContract" } }, "200": { "description": "Successful request for a list of alert rules", "schema": { "$ref": "#/definitions/LogSearchRuleResourceCollection" } } }, "x-ms-pageable": { "nextLinkName": null }, "x-ms-examples": { "List rules": { "$ref": "./examples/listScheduledQueryRules.json" } }, "x-ms-odata": "#/definitions/LogSearchRuleResource" } } }, "definitions": { "Resource": { "type": "object", "properties": { "id": { "type": "string", "readOnly": true, "description": "Azure resource Id" }, "name": { "type": "string", "readOnly": true, "description": "Azure resource name" }, "type": { "type": "string", "readOnly": true, "description": "Azure resource type" }, "location": { "type": "string", "description": "Resource location", "x-ms-mutability": [ "create", "read" ] }, "tags": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Resource tags" }, "kind": { "type": "string", "readOnly": true, "description": "Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value." }, "etag": { "type": "string", "readOnly": true, "description": "The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. " } }, "required": [ "location" ], "x-ms-azure-resource": true, "description": "An azure resource object" }, "LogSearchRuleResource": { "type": "object", "allOf": [ { "$ref": "#/definitions/Resource" } ], "required": [ "properties" ], "properties": { "properties": { "x-ms-client-flatten": true, "$ref": "#/definitions/LogSearchRule", "description": "The rule properties of the resource." } }, "description": "The Log Search Rule resource." }, "LogSearchRuleResourcePatch": { "type": "object", "properties": { "tags": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Resource tags" }, "properties": { "x-ms-client-flatten": true, "$ref": "#/definitions/LogSearchRulePatch", "description": "The log search rule properties of the resource." } }, "description": "The log search rule resource for patch operations." }, "LogSearchRuleResourceCollection": { "type": "object", "properties": { "value": { "type": "array", "items": { "$ref": "#/definitions/LogSearchRuleResource" }, "description": "The values for the Log Search Rule resources." } }, "description": "Represents a collection of Log Search rule resources." }, "Source": { "type": "object", "description": "Specifies the log search query.", "properties": { "query": { "type": "string", "description": "Log search query. Required for action type - AlertingAction" }, "authorizedResources": { "type": "array", "items": { "type": "string" }, "description": "List of Resource referred into query" }, "dataSourceId": { "type": "string", "description": "The resource uri over which log search query is to be run." }, "queryType": { "$ref": "#/definitions/QueryType", "description": "Set value to 'ResultCount' ." } }, "required": [ "dataSourceId" ] }, "Schedule": { "type": "object", "description": "Defines how often to run the search and the time interval.", "properties": { "frequencyInMinutes": { "type": "integer", "format": "int32", "description": "frequency (in minutes) at which rule condition should be evaluated." }, "timeWindowInMinutes": { "type": "integer", "format": "int32", "description": "Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes)." } }, "required": [ "frequencyInMinutes", "timeWindowInMinutes" ] }, "TriggerCondition": { "description": "The condition that results in the Log Search rule.", "properties": { "thresholdOperator": { "$ref": "#/definitions/ConditionalOperator", "description": "Evaluation operation for rule - 'GreaterThan' or 'LessThan." }, "threshold": { "description": "Result or count threshold based on which rule should be triggered.", "format": "double", "type": "number" }, "metricTrigger": { "$ref": "#/definitions/LogMetricTrigger", "description": "Trigger condition for metric query rule" } }, "required": [ "thresholdOperator", "threshold" ], "type": "object" }, "AzNsActionGroup": { "type": "object", "properties": { "actionGroup": { "type": "array", "description": "Azure Action Group reference.", "items": { "type": "string" } }, "emailSubject": { "type": "string", "description": "Custom subject override for all email ids in Azure action group" }, "customWebhookPayload": { "type": "string", "description": "Custom payload to be sent for all webhook URI in Azure action group" } }, "description": "Azure action group" }, "LogMetricTrigger": { "type": "object", "properties": { "thresholdOperator": { "$ref": "#/definitions/ConditionalOperator", "description": "Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'." }, "threshold": { "format": "double", "type": "number", "description": "The threshold of the metric trigger." }, "metricTriggerType": { "$ref": "#/definitions/MetricTriggerType", "description": "Metric Trigger Type - 'Consecutive' or 'Total'" }, "metricColumn": { "type": "string", "description": "Evaluation of metric on a particular column" } }, "description": "A log metrics trigger descriptor." }, "ConditionalOperator": { "type": "string", "enum": [ "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", "Equal" ], "default": "GreaterThanOrEqual", "x-ms-enum": { "name": "ConditionalOperator", "modelAsString": true }, "description": "Result Condition Evaluation criteria." }, "MetricTriggerType": { "type": "string", "enum": [ "Consecutive", "Total" ], "default": "Consecutive", "x-ms-enum": { "name": "metricTriggerType", "modelAsString": true }, "description": "Metric Trigger Evaluation Type" }, "AlertSeverity": { "type": "string", "enum": [ "0", "1", "2", "3", "4" ], "x-ms-enum": { "name": "AlertSeverity", "modelAsString": true }, "description": "Severity Level of Alert" }, "QueryType": { "type": "string", "enum": [ "ResultCount" ], "x-ms-enum": { "name": "QueryType", "modelAsString": true }, "description": "Set value to 'ResultAccount'" }, "LogSearchRule": { "type": "object", "description": "Log Search Rule Definition", "properties": { "createdWithApiVersion": { "type": "string", "readOnly": true, "description": "The api-version used when creating this alert rule" }, "isLegacyLogAnalyticsRule": { "type": "boolean", "readOnly": true, "description": "True if alert rule is legacy Log Analytic rule" }, "description": { "type": "string", "description": "The description of the Log Search rule." }, "displayName": { "type": "string", "description": "The display name of the alert rule" }, "autoMitigate": { "type": "boolean", "default": false, "description": "The flag that indicates whether the alert should be automatically resolved or not. The default is false." }, "enabled": { "type": "string", "description": "The flag which indicates whether the Log Search rule is enabled. Value should be true or false", "enum": [ "true", "false" ], "x-ms-enum": { "name": "enabled", "modelAsString": true } }, "lastUpdatedTime": { "readOnly": true, "type": "string", "format": "date-time", "description": "Last time the rule was updated in IS08601 format." }, "provisioningState": { "readOnly": true, "type": "string", "enum": [ "Succeeded", "Deploying", "Canceled", "Failed" ], "x-ms-enum": { "name": "provisioningState", "modelAsString": true }, "description": "Provisioning state of the scheduled query rule" }, "source": { "$ref": "#/definitions/Source", "description": "Data Source against which rule will Query Data" }, "schedule": { "$ref": "#/definitions/Schedule", "description": "Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction" }, "action": { "$ref": "#/definitions/Action", "description": "Action needs to be taken on rule execution." } }, "required": [ "source", "action" ] }, "LogSearchRulePatch": { "type": "object", "description": "Log Search Rule Definition for Patching", "properties": { "enabled": { "type": "string", "description": "The flag which indicates whether the Log Search rule is enabled. Value should be true or false", "enum": [ "true", "false" ], "x-ms-enum": { "name": "enabled", "modelAsString": true } } } }, "Action": { "type": "object", "discriminator": "odata.type", "properties": { "odata.type": { "type": "string", "description": "Specifies the action. Supported values - AlertingAction, LogToMetricAction" } }, "required": [ "odata.type" ], "description": "Action descriptor." }, "AlertingAction": { "description": "Specify action need to be taken when rule type is Alert", "x-ms-discriminator-value": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction", "type": "object", "allOf": [ { "$ref": "#/definitions/Action" } ], "properties": { "severity": { "$ref": "#/definitions/AlertSeverity", "description": "Severity of the alert" }, "aznsAction": { "$ref": "#/definitions/AzNsActionGroup", "description": "Azure action group reference." }, "throttlingInMin": { "type": "integer", "format": "int32", "description": "time (in minutes) for which Alerts should be throttled or suppressed." }, "trigger": { "$ref": "#/definitions/TriggerCondition", "description": "The trigger condition that results in the alert rule being." } }, "required": [ "trigger", "severity" ] }, "Dimension": { "type": "object", "description": "Specifies the criteria for converting log to metric.", "properties": { "name": { "type": "string", "description": "Name of the dimension" }, "operator": { "type": "string", "description": "Operator for dimension values", "enum": [ "Include" ], "x-ms-enum": { "name": "operator", "modelAsString": true } }, "values": { "type": "array", "items": { "type": "string" }, "description": "List of dimension values" } }, "required": [ "name", "operator", "values" ] }, "Criteria": { "type": "object", "description": "Specifies the criteria for converting log to metric.", "properties": { "metricName": { "type": "string", "description": "Name of the metric" }, "dimensions": { "type": "array", "items": { "$ref": "#/definitions/Dimension" }, "x-ms-identifiers": [ "name" ], "description": "List of Dimensions for creating metric" } }, "required": [ "metricName" ] }, "LogToMetricAction": { "description": "Specify action need to be taken when rule type is converting log to metric", "x-ms-discriminator-value": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction", "type": "object", "allOf": [ { "$ref": "#/definitions/Action" } ], "properties": { "criteria": { "type": "array", "items": { "$ref": "#/definitions/Criteria" }, "x-ms-identifiers": [ "metricName" ], "description": "Criteria of Metric" } }, "required": [ "criteria" ] }, "ErrorContract": { "description": "Describes the format of Error response.", "type": "object", "properties": { "error": { "description": "The error details.", "$ref": "#/definitions/ErrorResponse" } } }, "ErrorResponse": { "description": "Describes the format of Error response.", "type": "object", "properties": { "code": { "description": "Error code", "type": "string" }, "message": { "description": "Error message indicating why the operation failed.", "type": "string" } } } }, "parameters": { "RuleNameParameter": { "name": "ruleName", "in": "path", "required": true, "type": "string", "description": "The name of the rule.", "x-ms-parameter-location": "method" }, "FilterParameter": { "name": "$filter", "in": "query", "required": false, "type": "string", "description": "The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx", "x-ms-parameter-location": "method" } } }