Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

OEC (Windows Service) action with PowerShell - how do I see (grab) the alert parameters or payload?

Can someone provide an example of the OEC json configuration and the powershell method to capture the globalargs passed?

1 answer

0 votes
Connor Eyles Atlassian Team May 26, 2021

Hi @tolkien_leung 

Here are some instructions on how to handle OEC payload in Powershell:

The environment this was tested in is Windows 2012 and above… Powershell 3 and above.

Starting at linerps 1 of your PowerShell script you should define the parameters that PowerShell is expected to receive from OEC, these are payload, apiKey, opsgenieUrl, and logLevel.

param([string]$payload,
[string]$apiKey,
[string]$opsgenieUrl,
[string]$logLevel)

Once the parameters have been defined you need to convert the payload from JSON to a Powershell object.

$payloadPsObj = $payload | ConvertFrom-Json

Now you can call your data like this, to get the payload data you can use $payloadPsObj.<Namespace or array index>, for example, the below will get you the alertId from the payload:

$alertDetails = $payloadPsObj.alert
$alertId = $alertDetails.alertId

echo $alertId

The full final script should look like this:

param([string]$payload,
[string]$apiKey,
[string]$opsgenieUrl,
[string]$logLevel)

$payloadPsObj = $payload | ConvertFrom-Json

$alertDetails = $payloadPsObj.alert
$alertId = $alertDetails.alertId

echo $alertId

Thanks,

Connor

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Opsgenie

How do I use Zebrium + Opsgenie for Root Cause Analysis (RCA)?

This article was co-authored by Gavin Cohen of Zebrium. Zebrium has a bi-directional integration with Opsgenie and is a machine learning solution for RCA.  We all know the drill. 💤 You'r...

308 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you