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

Horizontal formatting of data from JSON Array

Tim Ashour December 20, 2023

I'm trying to figure out a better way to do some formatting on JSON arrays that I'm receiving through SumoLogic webhook.
I have the description of my integration set like this:
"""
username: {{_payload.username}}
authDevIP: {{_payload.authDevIP}}
"""
And the alert will show up like this:
"""
username: user1
user2
user3
user4
authDevIP: 10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4
"""

I think it would be a little more readable like this:
"""
username: user1 user2 user3 user4
authDevIP: 10.0.0.1 10.0.0.2 10.0.0.3 10.0.0.4
"""

Ideally, there would be tabs or commas, but the main thing would likely be to get horizontal formatting.
Is there a way to do that easily with an array?
I know I could try to use a .get() like is mentioned in this documentation (Dynamic fields in Opsgenie integrations | Opsgenie | Atlassian Support), but I don't know how many iteams will be in these arrays.

2 answers

0 votes
Tim Ashour December 21, 2023

What I would wonder is whether there could be an option as to what items in a list are joined on.
Since the data to Opsgenie is just an array, it seems that there is just a default handling that says that the items in the array are joined on a newline character.
If there was a formating function like .get() for an array that allowed a joining character to be specified, that would solve the issue.
eg. If I sent
{usernames : [user1,user2,user3]}
I could use
{{_payload.usernames}}.join(" ") or {{_payload.usernames}}.join("\t")

0 votes
eugenio_onofre
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 20, 2023

Hello,

Opsgenie is not able to handle String parsing when creating alerts. I would recommend doing it on Sumologic alert configuration side.

Please do not forget to accept this answer in case it helps you resolve your issue as it may help other community members in the future.

Regards,
Eugenio

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events