opsgenie / opsgenie-go-sdk-v2

Opsgenie GO SDK v2
Apache License 2.0
34 stars 63 forks source link

Create alert with Responders and VisibleTo not working #81

Open betorvs opened 3 years ago

betorvs commented 3 years ago

Hi all,

I have some questions:

Description

Following this opsgenie documentation I'm trying to add both fields in alert creation:

...
createResult, err := alertClient.Create(ctx, &alert.CreateAlertRequest{
        Message:     title,
        Alias:       alias,
        Description: something,
        Responders:  teams,
        VisibleTo:   visibilityTeams,
        ...

in teams variable:

[]alert.Responder{alert.Responder{Type:"team", Name:"ops", Id:"", Username:""},}

in visibilityTeams:

[]alert.Responder{alert.Responder{Type:"team", Name:"sre", Id:"", Username:""},}

But when I checked in my opsgenie free account logs, it doesn't work (only responders):

_incomingData
_parsedData
note null
-responders
0 ops
-actions [ ]
-tags [ webserver01, check-nginx, default, agent ]
alias webserver01/check-nginx
description example output
source sensuGo
message webserver01/check-nginx
priority P5
user Alert API
_extraProperties { subscriptions: [testing], interval: 20, status: 1 }
entity webserver01
integrationType Sensu
integrationName ops_Sensu

Why in incomingData.parsedData there's no visibleTo field?

I'm trying to add this option in my sensu opsgenie plugin And I'm using sensu integration to grant me an API key.

Thanks for any help.

EnverKESMEN commented 3 years ago

We've deprecated the visibleTo field. But not removed from Public API for backward compatibility. Basically, we're adding that field to the responder list and act like responders.

Sorry for that wrong reply. I thought teams. We are still using the visibleTo field. I've tested with my enterprise account and you're right. We don't write that field here. But not sure if it should be here or not. Let me discuss this with my team.

image

betorvs commented 3 years ago

any news @EnverKESMEN ?

EnverKESMEN commented 3 years ago

I created an internal task about this issue and it is in the current sprint. I'll update here when it's done.

EnverKESMEN commented 3 years ago

image Hello again, we started to log id and type for visibleTo field.

betorvs commented 3 years ago

I will test and comment here. Thanks @EnverKESMEN

betorvs commented 3 years ago

Hi again @EnverKESMEN , Just one question: If I send a test alert to "ops" team and add "sre" team as visibleTo, should it appear in alert short description? Like "ops" and "sre", instead only "ops" (I pasted it here in alert).

Log:

Screenshot 2021-05-25 at 09 18 26

Alert:

Screenshot 2021-05-25 at 09 19 05
EnverKESMEN commented 3 years ago

Only ops team will see in description because only responder is ops. Also, SRE team members can see the alert because they have visibleTo right.

from our public api doc https://docs.opsgenie.com/docs/alert-api#create-alert Teams and users that the alert will become visible to without sending any notification. Please note: that alert will be visible to the teams that are specified within responders field by default, so there is no need to re-specify them within visibleTo field. You can refer below for example values.

betorvs commented 3 years ago

Hi @EnverKESMEN , From your public api doc If the API Key belongs to a team integration, this field will be overwritten with the owner team. it means if I create an integration apy-key in ops team, I cannot add sre team as responders using that api-key. Is it? I was testing with multiple responders and I wasn't able to create an alert with multiple responders.

Screenshot 2021-05-30 at 08 52 43

In alert it keeps showing Responders: ops only.

How can I create an api-key to be used for this case? for multiple responders I mean.