Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,240
Community Members
 
Community Events
176
Community Groups

Access nested JSON in SNS message

Edited

Hi!

 

Our current flow for some of our AWS alerts is Eventbridge Rule -> SNS -> OpsGenie. Through AWS EventBridge Rule, we can only access the 'Message' field in SNS. When we populate the 'Message' field with a JSON object. See the example below.

 

{

"Type": "Notification",

"MessageId": "XXX",

"TopicArn": "arn:aws:sns:eu-central-1:XXX:test_topic_opsgenie",

"Message": "{\n \"eventId\":\"XXX |\",\n \"region\": \"us-east-1 |\",\n \"time\": \"2022-12-12T13:29:18Z |\",\n \"userIdentityArn\": \"arn:aws:sts::XXX:assumed-role/XXX |\",\n \"eventName\": \"XXX |\",\n \"account\": \"XXX |\",\n \"title\": \"XXX |\",\n \"description\": \"The ChangeResourceRecordSets API call was made by the user arn:aws:sts::XXX:assumed-role/XXX/XXX@XXX in account: #XXX, in region: us-east-1 |\",\n \"ops_severity\": \"1 |\",\n \"ops_source\": \"XXX |\",\n \"alias\": \"XXXX |\"\n}",

"Timestamp": "2022-12-12T13:29:20.931Z",

"SignatureVersion": "1",

"Signature": "XXX",

"SigningCertURL": "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-XXX.pem",

"UnsubscribeURL": "https://sns.eu-central-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-central-1:XXX:test_topic_opsgenie:XXX"

}

Through {{ _payload.Type }} or {{ _payload.Message }}, we can access the fields in the main JSON object. However, the fields *within* the Message field are not availabe. For example {{ _payload.Message.region }} or {{ _payload.Message.account }} would not give us any result. I think I have tried all options, e.g., using the removeWhitespace() function and adding "\" to index ({{ _payload.Message.account\ }}), however with no success.
I suspect the issue lies since it seems that the nested JSON is encoded, and OpsGenie is not able to handle this correctly.

I've now resorted to substringBetween() which is far from ideal.
Do you have any suggestions on how to solve this issue? Thank you for your time!

1 answer

1 accepted

1 vote
Answer accepted
Nick H Atlassian Team Dec 13, 2022

Hi @Mike Schouw ,

Unless the region or account fields are nested under the Message field, you will need to use string processing or regex to extract the strings from within the Message field.

This article may help with extracting fields: How to Extract Custom Fields and Data into an Alert

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS

Atlassian Community Events