sensu-plugins / sensu-plugins-opsgenie

Sensu plugins for OpsGenie
http://sensu-plugins.io
MIT License
4 stars 24 forks source link

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

Open nosretep opened 5 years ago

nosretep commented 5 years ago

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.

Castaglia commented 5 years ago

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

nosretep commented 5 years ago

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
nosretep commented 5 years ago

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

extraProperties for policies

nosretep commented 5 years ago

"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.

jayjani10 commented 2 years ago

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?

jayjani10 commented 2 years ago

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"