How to send budget alert notification via Slack ?

Kuldeep Singh(OT) 75 Reputation points
2024-02-16T13:45:14.0866667+00:00
  1. i have created a budget which send its notification to action group.
  2. In action group we forwarding alerts on Logic app.
  3. In Logic app first things we use

When a HTTP Request is received block is used and under it body we define

{ "properties": { "data": { "properties": { "context": { "properties": { "condition": { "properties": { "allOf": { "items": { "properties": { "dimensions": { "items": { "properties": { "name": { "type": "string" }, "value": { "type": "string" } }, "required": [ "name", "value" ], "type": "object" }, "type": "array" }, "metricName": { "type": "string" }, "metricValue": { "type": "integer" }, "operator": { "type": "string" }, "threshold": { "type": "string" }, "timeAggregation": { "type": "string" } }, "required": [ "metricName", "dimensions", "operator", "threshold", "timeAggregation", "metricValue" ], "type": "object" }, "type": "array" }, "windowSize": { "type": "string" } }, "type": "object" }, "conditionType": { "type": "string" }, "description": { "type": "string" }, "id": { "type": "string" }, "name": { "type": "string" }, "portalLink": { "type": "string" }, "resourceGroupName": { "type": "string" }, "resourceId": { "type": "string" }, "resourceName": { "type": "string" }, "resourceType": { "type": "string" }, "subscriptionId": { "type": "string" }, "timestamp": { "type": "string" } }, "type": "object" }, "properties": { "properties": {}, "type": "object" }, "status": { "type": "string" }, "version": { "type": "string" } }, "type": "object" }, "schemaId": { "type": "string" } }, "type": "object" }

and then i use HTTP step in which i define slack url but its not wokring.

Error am getting - 

ExpressionEvaluationFailed. The execution of template action 'For_each' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['data']?['context']?['condition']?['allOf']' is of type 'Null'. The result must be a valid array.

Refernece blogs i am using https://blog.opstree.com/2022/05/10/alerting-through-azure-logic-apps/

Community Center | Not monitored
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,941 Reputation points Moderator
    2024-02-21T11:11:32.8766667+00:00

    @Kuldeep Singh(OT) I don't see any reference guide that would help with your flow. But there is difference reference document on how to create the individual component/different service and then build your flow: Create Buget --> monitor Group action --> Specify your logic app post URL as webhook You can test your schema first which schema is sent and some common schemas are listed here. Logic App: Http trigger --> Http call (to call the slack endpoint. Please refer to slack documentation for HTTP call) Test Schema

    {
      "schemaId": "azureMonitorCommonAlertSchema",
      "data": {
        "essentials": {
          "monitoringService": "CostAlerts",
          "firedDateTime": "2024-02-21T10:57:32.056Z",
          "description": "Your spend for budget Test_actual_cost_budget is now $11,111.00 exceeding your specified threshold $25.00.",
          "essentialsVersion": "1.0",
          "alertContextVersion": "1.0",
          "alertId": "/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.CostManagement/alerts/Test_Alert",
          "alertRule": null,
          "severity": null,
          "signalType": null,
          "monitorCondition": null,
          "alertTargetIDs": null,
          "configurationItems": [
            "budgets"
          ],
          "originAlertId": null
        },
        "alertContext": {
          "AlertCategory": "budgets",
          "AlertData": {
            "Scope": "/subscriptions/11111111-1111-1111-1111-111111111111/",
            "ThresholdType": "Actual",
            "BudgetType": "Cost",
            "BudgetThreshold": "$50.00",
            "NotificationThresholdAmount": "$25.00",
            "BudgetName": "Test_actual_cost_budget",
            "BudgetId": "/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Consumption/budgets/Test_actual_cost_budget",
            "BudgetStartDate": "2022-11-01",
            "BudgetCreator": "******@sample.test",
            "Unit": "USD",
            "SpentAmount": "$11,111.00"
          }
        }
      }
    }
    

    Created new budgets on my subscription. Please refer to Create Buget document for more detailsUser's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.