opsgenie-go-sdk-v2 icon indicating copy to clipboard operation
opsgenie-go-sdk-v2 copied to clipboard

Create alert with Responders and VisibleTo not working

Open betorvs opened this issue 3 years ago • 8 comments

Hi all,

I have some questions:

  • Is this Responders and VisibleTo need extra configuration in opsgenie side?
  • Is this only an option for advanced plans?
  • Is there any extra documentation about how to create an alert using this golang sdk that shows how to write the code?

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.

betorvs avatar Mar 31 '21 16:03 betorvs

~~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

EnverKESMEN avatar Apr 01 '21 11:04 EnverKESMEN

any news @EnverKESMEN ?

betorvs avatar Apr 20 '21 10:04 betorvs

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

EnverKESMEN avatar Apr 30 '21 09:04 EnverKESMEN

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

EnverKESMEN avatar May 07 '21 08:05 EnverKESMEN

I will test and comment here. Thanks @EnverKESMEN

betorvs avatar May 24 '21 09:05 betorvs

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

betorvs avatar May 25 '21 07:05 betorvs

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.

EnverKESMEN avatar May 25 '21 09:05 EnverKESMEN

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.

betorvs avatar May 30 '21 06:05 betorvs