在 Azure 逻辑应用程序中,变量(数组类型)输出为 null。我如何获得所需的输出

问题描述 投票:0回答:1

我已经初始化了一个数组类型的变量,但我总是得到的输出值为空。

我使用了 JSON 有效负载:通过以下链接记录警报并监控服务 = Application Insights:

https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-payload-samples

这是我的数组表达式:

createArray(triggerBody()?['data']?['essentials']?['alertContext']?['condition']?['allof']?[0]?['dimensions']?[0]?['value'])

如何获得实际需要的输出?

我从中添加表达式的 http 输出主体架构:

"body": {
        "schemaId": "azureMonitorCommonAlertSchema",
        "data": {
            "essentials": {
                "alertId": "",
                "alertRule": "",
                "severity": "Sev1",
                "signalType": "Log",
                "monitorCondition": "Fired",
                "monitoringService": "Log Alerts V2",
                "alertTargetIDs": [
             "/subscriptions/"
                ],
                "configurationItems": [
                    "/subscriptions/"
                ],
                "originAlertId": "bb88b50d-3cec-452c-a5d4-xxxxx”,
                "firedDateTime": "2023-XX-XXT",
                "description": “xxxx”,
                "essentialsVersion": "1.0",
                "alertContextVersion": "1.0"
            },
            "alertContext": {
                "properties": {},
                "conditionType": "LogQueryCriteria",
                "condition": {
                    "windowSize": "PT15M",
                    "allOf": [
                        {
                            "searchQuery": "  exceptions \n| where assembly has \”__XXXX\”\n| where timestamp >= ago(1h)\n| summarize errorCount = count() by outerMessage\n| where errorCount >= 1\n| where outerMessage contains \”XXXX\”\n\n”,
                            "metricMeasureColumn": "errorCount",
                            "targetResourceTypes": "['microsoft.insights/components']",
                            "operator": "GreaterThanOrEqual",
                            "threshold": "1",
                            "timeAggregation": "Total",
                            "dimensions": [
                                {
                                    "name": "outerMessage",
                                    "value": "Error Found in XXXX”
                                }
                            ],
                            "metricValue": 12,
                            "failingPeriods": {
                                "numberOfEvaluationPeriods": 1,
                                "minFailingPeriodsToAlert": 1
                            },
                            "linkToSearchResultsUI": "https://portal.azure.comXXX”,
                            "linkToFilteredSearchResultsUI": "https://portal.azure.comXXXX”,
                            "linkToSearchResultsAPI": "https://api.applicationinsights.io/v1/apps/XXX”,
                            "linkToFilteredSearchResultsAPI": "https://api.applicationinsights.io/v1/apps/XXXx”
                        }
                    ],
                    "windowStartTime": "2023XXXX”,
                    "windowEndTime": "2023XXXX”
                }
            },
            "customProperties": {}
        }
    }
arrays json azure azure-logic-apps
1个回答
0
投票

当你看到它时你会踢自己,但你在不需要时指定了

essentials
。它和
alertContext
处于同一水平线上。

所以把你的表情改成这样...

createArray(triggerBody()?['data']?['alertContext']?['condition']?['allof']?[0]?['dimensions']?[0]?['value'])
© www.soinside.com 2019 - 2024. All rights reserved.