opsgenie-go-sdk-v2
opsgenie-go-sdk-v2 copied to clipboard
Create alert with Responders and VisibleTo not working
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.
~~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.
any news @EnverKESMEN ?
I created an internal task about this issue and it is in the current sprint. I'll update here when it's done.
Hello again, we started to log id and type for visibleTo field.
I will test and comment here. Thanks @EnverKESMEN
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:
Alert:

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

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.