Skip to content

az monitor metrics alert create returns invalid JSON on success. #12892

@bmukes

Description

@bmukes

Describe the bug
After a successful call to az monitor metrics alert create in PowerShell 7, I expect to get a [String] of JSON returned. Instead I am getting an [Object[50]] because the first two lines of the response are

ANTLR runtime and generated code versions disagree: 4.8!=4.7.2

followed by 48 array elements containing the JSON return value.

See returned value below:

ANTLR runtime and generated code versions disagree: 4.8!=4.7.2
ANTLR runtime and generated code versions disagree: 4.8!=4.7.2
{
	"actions": [{
		"actionGroupId": "/subscriptions/#####/resourceGroups/####/providers/microsoft.insights/actionGroups/###",
		"webhookProperties": null
	}],
	"autoMitigate": null,
	"criteria": {
		"additionalProperties": null,
		"allOf": [{
			"additionalProperties": null,
			"criterionType": "StaticThresholdCriterion",
			"dimensions": [],
			"metricName": "AverageMemoryWorkingSet",
			"metricNamespace": "microsoft.web/sites",
			"name": "cond0",
			"operator": "GreaterThan",
			"threshold": 15032385534.0,
			"timeAggregation": "Average"
		}],
		"odatatype": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
	},
	"description": "This instance memory working set above 1.4GB.",
	"enabled": true,
	"evaluationFrequency": "0:01:00",
	"id": "/subscriptions/###/resourceGroups/###/providers/Microsoft.Insights/metricAlerts/App Memory Exceeded Threshold",
	"lastUpdatedTime": null,
	"location": "global",
	"name": "App Memory Exceeded Threshold",
	"resourceGroup": "#####",
	"scopes": ["/subscriptions/#####/resourceGroups/#####/providers/Microsoft.Web/sites/#####"],
	"severity": 2,
	"tags": {
		"Environment": "prod",
		"OrganizationIdentifier": "aaa",
		"ProductName": "fse",
		"ResourceType": "Web App Metric Alert"
	},
	"targetResourceRegion": null,
	"targetResourceType": "microsoft.web/sites",
	"type": "Microsoft.Insights/metricAlerts",
	"windowSize": "0:05:00"
}

To Reproduce
run az monitor metrics alert create for the following values

          "AlertScopeType": "WebApp",
          "AlertName": "App Memory Exceeded Threshold",
          "Evaluationfrequency": "1m",
          "Severity": 2,
          "WindowSize": "5m",
          "Condition": "avg AverageMemoryWorkingSet > 15032385534.0",
          "Description": "This instance memory working set above 1.4GB."

Expected behavior
that the response would be JSON as indicated below after I removed two lines indicated above

{
	"actions": [{
		"actionGroupId": "/subscriptions/#####/resourceGroups/####/providers/microsoft.insights/actionGroups/###",
		"webhookProperties": null
	}],
	"autoMitigate": null,
	"criteria": {
		"additionalProperties": null,
		"allOf": [{
			"additionalProperties": null,
			"criterionType": "StaticThresholdCriterion",
			"dimensions": [],
			"metricName": "AverageMemoryWorkingSet",
			"metricNamespace": "microsoft.web/sites",
			"name": "cond0",
			"operator": "GreaterThan",
			"threshold": 15032385534.0,
			"timeAggregation": "Average"
		}],
		"odatatype": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
	},
	"description": "This instance memory working set above 1.4GB.",
	"enabled": true,
	"evaluationFrequency": "0:01:00",
	"id": "/subscriptions/###/resourceGroups/###/providers/Microsoft.Insights/metricAlerts/App Memory Exceeded Threshold",
	"lastUpdatedTime": null,
	"location": "global",
	"name": "App Memory Exceeded Threshold",
	"resourceGroup": "#####",
	"scopes": ["/subscriptions/#####/resourceGroups/#####/providers/Microsoft.Web/sites/#####"],
	"severity": 2,
	"tags": {
		"Environment": "prod",
		"OrganizationIdentifier": "aaa",
		"ProductName": "fse",
		"ResourceType": "Web App Metric Alert"
	},
	"targetResourceRegion": null,
	"targetResourceType": "microsoft.web/sites",
	"type": "Microsoft.Insights/metricAlerts",
	"windowSize": "0:05:00"
}

Environment summary

az --version

azure-cli 2.3.1

command-modules-nspkg 2.0.3
core 2.3.1
nspkg 3.0.4
telemetry 1.0.4

Extensions:
azure-firewall 0.1.8

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\bdm0609.azure\cliextensions'

Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLega

$PSVERSIONTABLE

Name Value
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Additional context
replaced the subscriptionid, resource group, and web application name in the JSON shown.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions