Documentation ¶
Overview ¶
Package alertmethod defines AlertMethod object definitions.
Index ¶
- type AlertMethod
- func (a AlertMethod) GetKind() manifest.Kind
- func (a AlertMethod) GetManifestSource() string
- func (a AlertMethod) GetName() string
- func (a AlertMethod) GetOrganization() string
- func (a AlertMethod) GetProject() string
- func (a AlertMethod) GetVersion() manifest.Version
- func (a AlertMethod) SetManifestSource(src string) manifest.Object
- func (a AlertMethod) SetOrganization(org string) manifest.Object
- func (a AlertMethod) SetProject(project string) manifest.Object
- func (a AlertMethod) Validate() error
- type DiscordAlertMethod
- type EmailAlertMethod
- type JiraAlertMethod
- type Metadata
- type OpsgenieAlertMethod
- type PagerDutyAlertMethod
- type SendResolution
- type ServiceNowAlertMethod
- type SlackAlertMethod
- type Spec
- type Status
- type TeamsAlertMethod
- type TemplateVariable
- type WebhookAlertMethod
- type WebhookHeader
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertMethod ¶
type AlertMethod struct { APIVersion manifest.Version `json:"apiVersion"` Kind manifest.Kind `json:"kind"` Metadata Metadata `json:"metadata"` Spec Spec `json:"spec"` Status *Status `json:"status,omitempty"` Organization string `json:"organization,omitempty"` ManifestSource string `json:"manifestSrc,omitempty"` }
AlertMethod represents the configuration required to send a notification to an external service when an alert is triggered.
Example ¶
package main import ( "context" "log" "github.com/nobl9/nobl9-go/internal/examples" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha/alertmethod" ) func main() { // Create the object: myAlertMethod := alertmethod.New( alertmethod.Metadata{ Name: "my-alert-method", DisplayName: "My Alert Method", Project: "default", }, alertmethod.Spec{ Description: "Example alert method", PagerDuty: &alertmethod.PagerDutyAlertMethod{ IntegrationKey: "ABC12345", }, }, ) // Verify the object: if err := myAlertMethod.Validate(); err != nil { log.Fatalf("alert method validation failed, err: %v", err) } // Apply the object: client := examples.GetOfflineEchoClient() if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myAlertMethod}); err != nil { log.Fatalf("failed to apply alert method, err: %v", err) } }
Output: apiVersion: n9/v1alpha kind: AlertMethod metadata: name: my-alert-method displayName: My Alert Method project: default spec: description: Example alert method pagerduty: integrationKey: ABC12345
func New ¶
func New(metadata Metadata, spec Spec) AlertMethod
New creates a new AlertMethod based on provided Metadata nad Spec.
func (AlertMethod) GetKind ¶
func (a AlertMethod) GetKind() manifest.Kind
func (AlertMethod) GetManifestSource ¶
func (a AlertMethod) GetManifestSource() string
func (AlertMethod) GetName ¶
func (a AlertMethod) GetName() string
func (AlertMethod) GetOrganization ¶
func (a AlertMethod) GetOrganization() string
func (AlertMethod) GetProject ¶
func (a AlertMethod) GetProject() string
func (AlertMethod) GetVersion ¶
func (a AlertMethod) GetVersion() manifest.Version
func (AlertMethod) SetManifestSource ¶
func (a AlertMethod) SetManifestSource(src string) manifest.Object
func (AlertMethod) SetOrganization ¶
func (a AlertMethod) SetOrganization(org string) manifest.Object
func (AlertMethod) SetProject ¶
func (a AlertMethod) SetProject(project string) manifest.Object
func (AlertMethod) Validate ¶
func (a AlertMethod) Validate() error
type DiscordAlertMethod ¶
type DiscordAlertMethod struct {
URL string `json:"url"` // Field required when AlertMethod is created.
}
DiscordAlertMethod represents a set of properties required to send message to Discord.
type EmailAlertMethod ¶
type EmailAlertMethod struct { To []string `json:"to,omitempty"` Cc []string `json:"cc,omitempty"` Bcc []string `json:"bcc,omitempty"` // Deprecated: Defining custom template for email alert method is now deprecated. This property is ignored. Subject string `json:"subject,omitempty"` // Deprecated: Defining custom template for email alert method is now deprecated. This property is ignored. Body string `json:"body,omitempty"` }
EmailAlertMethod represents a set of properties required to send an email.
type JiraAlertMethod ¶
type JiraAlertMethod struct { URL string `json:"url"` Username string `json:"username"` APIToken string `json:"apiToken"` // Field required when AlertMethod is created. ProjectKey string `json:"projectKey"` }
JiraAlertMethod represents a set of properties required create tickets in Jira.
type Metadata ¶
type Metadata struct { Name string `json:"name"` DisplayName string `json:"displayName,omitempty"` Project string `json:"project,omitempty"` }
Metadata provides identity information for AlertMethod.
type OpsgenieAlertMethod ¶
type OpsgenieAlertMethod struct { Auth string `json:"auth"` // Field required when AlertMethod is created. URL string `json:"url"` }
OpsgenieAlertMethod represents a set of properties required to send message to Opsgenie.
type PagerDutyAlertMethod ¶
type PagerDutyAlertMethod struct { IntegrationKey string `json:"integrationKey"` SendResolution *SendResolution `json:"sendResolution,omitempty"` }
PagerDutyAlertMethod represents a set of properties required to open an Incident in PagerDuty.
type SendResolution ¶
type SendResolution struct {
Message *string `json:"message"`
}
SendResolution If user set SendResolution, then “Send a notification after the cooldown period is over"
type ServiceNowAlertMethod ¶
type ServiceNowAlertMethod struct { Username string `json:"username"` Password string `json:"password"` // Field required when AlertMethod is created. InstanceName string `json:"instanceName"` }
ServiceNowAlertMethod represents a set of properties required to send message to ServiceNow.
type SlackAlertMethod ¶
type SlackAlertMethod struct {
URL string `json:"url"` // Required when AlertMethod is created.
}
SlackAlertMethod represents a set of properties required to send message to Slack.
type Spec ¶
type Spec struct { Description string `json:"description"` Webhook *WebhookAlertMethod `json:"webhook,omitempty"` PagerDuty *PagerDutyAlertMethod `json:"pagerduty,omitempty"` Slack *SlackAlertMethod `json:"slack,omitempty"` Discord *DiscordAlertMethod `json:"discord,omitempty"` Opsgenie *OpsgenieAlertMethod `json:"opsgenie,omitempty"` ServiceNow *ServiceNowAlertMethod `json:"servicenow,omitempty"` Jira *JiraAlertMethod `json:"jira,omitempty"` Teams *TeamsAlertMethod `json:"msteams,omitempty"` Email *EmailAlertMethod `json:"email,omitempty"` }
Spec holds detailed information specific to AlertMethod.
type Status ¶ added in v0.70.0
type Status struct { LastTestDate string `json:"lastTestDate,omitempty"` NextTestPossibleAt string `json:"nextTestPossibleAt,omitempty"` }
Status represents content of Status optional for AlertMethod Object
type TeamsAlertMethod ¶
type TeamsAlertMethod struct {
URL string `json:"url"`
}
TeamsAlertMethod represents a set of properties required create Microsoft Teams notifications.
type TemplateVariable ¶
type TemplateVariable = string
TemplateVariable can be used with MessageRenderer to override how variables are rendered.
const ( TplVarProjectName TemplateVariable = "project_name" TplVarServiceName TemplateVariable = "service_name" TplVarServiceLabelsText TemplateVariable = "service_labels_text" TplVarOrganization TemplateVariable = "organization" TplVarAlertPolicyName TemplateVariable = "alert_policy_name" TplVarAlertPolicyLabelsText TemplateVariable = "alert_policy_labels_text" TplVarAlertPolicyDescription TemplateVariable = "alert_policy_description" TplVarAlertPolicyConditionsArray TemplateVariable = "alert_policy_conditions[]" TplVarAlertPolicyConditionsText TemplateVariable = "alert_policy_conditions_text" TplVarSeverity TemplateVariable = "severity" TplVarSloName TemplateVariable = "slo_name" TplVarSloLabelsText TemplateVariable = "slo_labels_text" TplVarSloDetailsLink TemplateVariable = "slo_details_link" TplVarObjectiveName TemplateVariable = "objective_name" TplVarTimestamp TemplateVariable = "timestamp" TplVarIsoTimestamp TemplateVariable = "iso_timestamp" TplVarBackwardCompatibleObjectiveName TemplateVariable = "experience_name" )
type WebhookAlertMethod ¶
type WebhookAlertMethod struct { URL string `json:"url"` // Field required when AlertMethod is created. Template *string `json:"template,omitempty"` TemplateFields []string `json:"templateFields,omitempty"` Headers []WebhookHeader `json:"headers,omitempty"` }