sensu-plugins / sensu-plugins-opsgenie

Sensu plugins for OpsGenie

Home Page:http://sensu-plugins.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"extraProperties" or "Details (Key-Value Based)" on alert create

nosretep opened this issue · comments

Maybe it's staring me in the face, but is there a way to add "extraProperties" during alert create? I know "tags" exist, but they can get messy quick.

What sort of extra properties would you want to be adding to the alert creation request?

the "extraProperties" noted here https://docs.opsgenie.com/docs/integration-api.

Within Opsgenie integrations and policies, these are also known as "Details (Key-Value Based)", and can be used to help filter/chain alerts.

screenshots are from a slack integration's "Alert Filter:"

details key value filter

options list

"extraProperties", implemented as "Details (Key-Value Based)" in drop downs, can also be used for policy configurations.

extraProperties for policies

"extraProperties" must be deprecated, I think they now use "details" in its place. Command line curl direct to Opsgenie's REST API, I am sending "details" as JSON, and it is converted to "_extraProperties" within the Opsgenie logs.

"details" is referenced here: https://docs.opsgenie.com/docs/alert-api

You definitely want to consider adding "details" to the sensu-opsgenie API, it is extremely useful.

commented

If I manually add the field by selecting from dropdown "Details(Key-Value Based)", I am able to add to opsgenie.
Then, I send GET request to https://www.api.opsgenie.com/v2/integrations/{id}/actions
So, I get

{
    "field": "extra_properties_key_prefix-Entity",
    "not": false,
    "operation": "equals",
    "expectedValue": "Website"
}

But then if I want to push same value (POST method) through code by adding above object, I am not able to. :(

Can someone help me with this?

commented

I got the answer! It's working

While posting data in Opsgenie, for a Key-Value based entity,
keep this in mind:
DOn't forget to put this.
"isExtraPropertiesWithKey":true
And the field name should be our "key", unlike the above GET request "extra_properties_key_prefix-Entity"