Please provide script for sections under msteams configuration watcher

I want alerts in a tabular format in MS Teams , I am providing a snippet for adding sections in the body . Please, help me know where i am making mistake .

 "MS_Teams": {
  "transform": {
    "script": {
      "source": "return ['title': 'Failure at timestamp :'+ ctx.payload.hits.hits.0._source.eventTimestamp, 'sections': [ { 'facts': [ { 'name': 'Service Incident:', 'value': 'ID' } ] } ] ]",
      "lang": "painless"
    }
  }

I have resolved it .

Please share the solution in the thread, it might help someone in future :slight_smile:

    "MS_Teams": {
  "webhook": {
    "scheme": "https",
    "host": "outlook.office.com",
    "port": 443,
    "method": "post",
    "path": "/webhook/141b6cf0-7568-4013-872a-3e4c0af99f00@5989ece0-f90e-40bf-9c79-1a7beccdb861/IncomingWebhook/4f931fbe4e26a52fb293642f086c/bd2a812e-0995-47dd",
    "params": {},
    "headers": {
      "Content-type": "application/json"
    },
    "body": "{ \"summary\":\"Failure At timestamp: {{ctx.payload.hits.hits.0._source.eventTimestamp}}\", \"sections\":[ { \"activityTitle\":\"Timestamp : {{ctx.payload.hits.hits.0._source.eventTimestamp}}\" }, { \"title\":\"Details of failure:\", \"facts\":[ { \"name\":\"Event Level\", \"value\":\"{{ctx.payload.hits.hits.0._source.eventLevel}}\"}, { \"name\":\"Event Description\", \"value\":\"{{ctx.payload.hits.hits.0._source.eventDescription}}\" }, { \"name\":\"Component Lifecycle\", \"value\":\"{{ctx.payload.hits.hits.0._source.componentLifecycle}}\" }, { \"name\":\"Country Scope\", \"value\":\"countryScope\" } ] } ] }"
  }
}

It will provide alerts in tabular format .

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.