alerts

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

BaseURLs represents the base API URLs for the different environments of the New Relic REST API V2.

Functions

This section is empty.

Types

type AlertPlugin

type AlertPlugin struct {
	ID   string `json:"id,omitempty"`
	GUID string `json:"guid,omitempty"`
}

AlertPlugin represents a plugin to use with a Plugin alert condition.

type Alerts

type Alerts struct {
	// contains filtered or unexported fields
}

Alerts is used to communicate with New Relic Alerts.

func New

func New(config config.Config) Alerts

New is used to create a new Alerts client instance.

func (*Alerts) AcknowledgeIncident added in v0.3.0

func (alerts *Alerts) AcknowledgeIncident(id int) (*Incident, error)

AcknowledgeIncident acknowledges an existing incident.

func (*Alerts) CloseIncident added in v0.3.0

func (alerts *Alerts) CloseIncident(id int) (*Incident, error)

CloseIncident closes an existing open incident.

func (*Alerts) CreateChannel added in v0.3.0

func (alerts *Alerts) CreateChannel(channel Channel) (*Channel, error)

CreateChannel creates an alert channel within a given account. The configuration options different based on channel type. For more information on the different configurations, please view the New Relic API documentation for this endpoint. Docs: https://docs.newrelic.com/docs/alerts/rest-api-alerts/new-relic-alerts-rest-api/rest-api-calls-new-relic-alerts#channels

func (*Alerts) CreateCondition added in v0.3.0

func (alerts *Alerts) CreateCondition(condition Condition) (*Condition, error)

CreateCondition creates an alert condition for a specified policy.

func (*Alerts) CreateInfrastructureCondition

func (a *Alerts) CreateInfrastructureCondition(condition InfrastructureCondition) (*InfrastructureCondition, error)

CreateInfrastructureCondition is used to create a New Relic Infrastructure alert condition.

func (*Alerts) CreateNrqlCondition added in v0.3.0

func (alerts *Alerts) CreateNrqlCondition(condition NrqlCondition) (*NrqlCondition, error)

CreateNrqlCondition creates a NRQL alert condition.

func (*Alerts) CreatePluginsCondition

func (alerts *Alerts) CreatePluginsCondition(condition PluginsCondition) (*PluginsCondition, error)

CreatePluginsCondition creates an alert condition for a plugin.

func (*Alerts) CreatePolicy added in v0.3.0

func (alerts *Alerts) CreatePolicy(policy Policy) (*Policy, error)

CreatePolicy creates a new alert policy for a given account.

func (*Alerts) CreateSyntheticsCondition

func (alerts *Alerts) CreateSyntheticsCondition(policyID int, condition SyntheticsCondition) (*SyntheticsCondition, error)

CreateSyntheticsCondition creates a new Synthetics alert condition.

func (*Alerts) DeleteChannel added in v0.3.0

func (alerts *Alerts) DeleteChannel(id int) (*Channel, error)

DeleteChannel deletes the alert channel with the specified ID.

func (*Alerts) DeleteCondition added in v0.3.0

func (alerts *Alerts) DeleteCondition(id int) (*Condition, error)

DeleteCondition delete an alert condition.

func (*Alerts) DeleteInfrastructureCondition

func (a *Alerts) DeleteInfrastructureCondition(conditionID int) error

DeleteInfrastructureCondition is used to delete a New Relic Infrastructure alert condition.

func (*Alerts) DeleteNrqlCondition added in v0.3.0

func (alerts *Alerts) DeleteNrqlCondition(id int) (*NrqlCondition, error)

DeleteNrqlCondition deletes a NRQL alert condition.

func (*Alerts) DeletePluginsCondition

func (alerts *Alerts) DeletePluginsCondition(id int) (*PluginsCondition, error)

DeletePluginsCondition deletes a plugin alert condition.

func (*Alerts) DeletePolicy added in v0.3.0

func (alerts *Alerts) DeletePolicy(id int) (*Policy, error)

DeletePolicy deletes an existing alert policy for a given account.

func (*Alerts) DeletePolicyChannel

func (alerts *Alerts) DeletePolicyChannel(policyID int, channelID int) (*Channel, error)

DeletePolicyChannel deletes a notification channel from an alert policy. This method returns a response containing the Channel that was deleted from the policy.

func (*Alerts) DeleteSyntheticsCondition

func (alerts *Alerts) DeleteSyntheticsCondition(conditionID int) (*SyntheticsCondition, error)

DeleteSyntheticsCondition deletes a Synthetics alert condition.

func (*Alerts) GetChannel added in v0.3.0

func (alerts *Alerts) GetChannel(id int) (*Channel, error)

GetChannel returns a specific alert channel by ID for a given account.

func (*Alerts) GetCondition added in v0.3.0

func (alerts *Alerts) GetCondition(policyID int, id int) (*Condition, error)

GetCondition gets an alert condition for a specified policy ID and condition ID.

func (*Alerts) GetInfrastructureCondition

func (a *Alerts) GetInfrastructureCondition(conditionID int) (*InfrastructureCondition, error)

GetInfrastructureCondition is used to retrieve a specific New Relic Infrastructure alert condition.

func (*Alerts) GetNrqlCondition added in v0.3.0

func (alerts *Alerts) GetNrqlCondition(policyID int, id int) (*NrqlCondition, error)

GetNrqlCondition gets information about a NRQL alert condition for a specified policy ID and condition ID.

func (*Alerts) GetPluginsCondition

func (alerts *Alerts) GetPluginsCondition(policyID int, pluginID int) (*PluginsCondition, error)

GetPluginsCondition gets information about an alert condition for a plugin given a policy ID and plugin ID.

func (*Alerts) GetPolicy added in v0.3.0

func (alerts *Alerts) GetPolicy(id int) (*Policy, error)

GetPolicy returns a specific alert policy by ID for a given account.

func (*Alerts) ListChannels added in v0.3.0

func (alerts *Alerts) ListChannels() ([]*Channel, error)

ListChannels returns all alert channels for a given account.

func (*Alerts) ListConditions added in v0.3.0

func (alerts *Alerts) ListConditions(policyID int) ([]*Condition, error)

ListConditions returns alert conditions for a specified policy.

func (*Alerts) ListIncidents added in v0.3.0

func (alerts *Alerts) ListIncidents(onlyOpen bool, excludeViolations bool) ([]*Incident, error)

ListIncidents returns all alert incidents.

func (*Alerts) ListInfrastructureConditions

func (a *Alerts) ListInfrastructureConditions(policyID int) ([]InfrastructureCondition, error)

ListInfrastructureConditions is used to retrieve New Relic Infrastructure alert conditions.

func (*Alerts) ListNrqlConditions added in v0.3.0

func (alerts *Alerts) ListNrqlConditions(policyID int) ([]*NrqlCondition, error)

ListNrqlConditions returns NRQL alert conditions for a specified policy.

func (*Alerts) ListPluginsConditions

func (alerts *Alerts) ListPluginsConditions(policyID int) ([]*PluginsCondition, error)

ListPluginsConditions returns alert conditions for New Relic plugins for a given alert policy.

func (*Alerts) ListPolicies added in v0.3.0

func (alerts *Alerts) ListPolicies(params *ListPoliciesParams) ([]Policy, error)

ListPolicies returns a list of Alert Policies for a given account.

func (*Alerts) ListSyntheticsConditions

func (alerts *Alerts) ListSyntheticsConditions(policyID int) ([]*SyntheticsCondition, error)

ListSyntheticsConditions returns a list of Synthetics alert conditions for a given policy.

func (*Alerts) UpdateCondition added in v0.3.0

func (alerts *Alerts) UpdateCondition(condition Condition) (*Condition, error)

UpdateCondition updates an alert condition.

func (*Alerts) UpdateInfrastructureCondition

func (a *Alerts) UpdateInfrastructureCondition(condition InfrastructureCondition) (*InfrastructureCondition, error)

UpdateInfrastructureCondition is used to update a New Relic Infrastructure alert condition.

func (*Alerts) UpdateNrqlCondition added in v0.3.0

func (alerts *Alerts) UpdateNrqlCondition(condition NrqlCondition) (*NrqlCondition, error)

UpdateNrqlCondition updates a NRQL alert condition.

func (*Alerts) UpdatePluginsCondition

func (alerts *Alerts) UpdatePluginsCondition(condition PluginsCondition) (*PluginsCondition, error)

UpdatePluginsCondition updates an alert condition for a plugin.

func (*Alerts) UpdatePolicy added in v0.3.0

func (alerts *Alerts) UpdatePolicy(policy Policy) (*Policy, error)

UpdatePolicy update an alert policy for a given account.

func (*Alerts) UpdatePolicyChannels

func (alerts *Alerts) UpdatePolicyChannels(policyID int, channelIDs []int) (*PolicyChannels, error)

UpdatePolicyChannels updates a policy by adding the specified notification channels.

func (*Alerts) UpdateSyntheticsCondition

func (alerts *Alerts) UpdateSyntheticsCondition(condition SyntheticsCondition) (*SyntheticsCondition, error)

UpdateSyntheticsCondition updates an existing Synthetics alert condition.

type Channel added in v0.3.0

type Channel struct {
	ID            int                  `json:"id,omitempty"`
	Name          string               `json:"name,omitempty"`
	Type          string               `json:"type,omitempty"`
	Configuration ChannelConfiguration `json:"configuration,omitempty"`
	Links         ChannelLinks         `json:"links,omitempty"`
}

Channel represents a New Relic alert notification channel

type ChannelConfiguration added in v0.3.0

type ChannelConfiguration struct {
	Recipients            string            `json:"recipients,omitempty"`
	IncludeJSONAttachment string            `json:"include_json_attachment,omitempty"`
	AuthToken             string            `json:"auth_token,omitempty"`
	APIKey                string            `json:"api_key,omitempty"`
	Teams                 string            `json:"teams,omitempty"`
	Tags                  string            `json:"tags,omitempty"`
	URL                   string            `json:"url,omitempty"`
	Channel               string            `json:"channel,omitempty"`
	Key                   string            `json:"key,omitempty"`
	RouteKey              string            `json:"route_key,omitempty"`
	ServiceKey            string            `json:"service_key,omitempty"`
	BaseURL               string            `json:"base_url,omitempty"`
	AuthUsername          string            `json:"auth_username,omitempty"`
	AuthPassword          string            `json:"auth_password,omitempty"`
	PayloadType           string            `json:"payload_type,omitempty"`
	Region                string            `json:"region,omitempty"`
	UserID                string            `json:"user_id,omitempty"`
	Payload               map[string]string `json:"payload,omitempty"`
	Headers               map[string]string `json:"headers,omitempty"`
}

ChannelConfiguration represents a Configuration type within Channels

type ChannelLinks struct {
	PolicyIDs []int `json:"policy_ids,omitempty"`
}

ChannelLinks represent the links between policies and alert channels

type Condition added in v0.3.0

type Condition struct {
	PolicyID            int                  `json:"-"`
	ID                  int                  `json:"id,omitempty"`
	Type                string               `json:"type,omitempty"`
	Name                string               `json:"name,omitempty"`
	Enabled             bool                 `json:"enabled"`
	Entities            []string             `json:"entities,omitempty"`
	Metric              string               `json:"metric,omitempty"`
	RunbookURL          string               `json:"runbook_url,omitempty"`
	Terms               []ConditionTerm      `json:"terms,omitempty"`
	UserDefined         ConditionUserDefined `json:"user_defined,omitempty"`
	Scope               string               `json:"condition_scope,omitempty"`
	GCMetric            string               `json:"gc_metric,omitempty"`
	ViolationCloseTimer int                  `json:"violation_close_timer,omitempty"`
}

Condition represents a New Relic alert condition. TODO: custom unmarshal entities to ints?

type ConditionTerm added in v0.3.0

type ConditionTerm struct {
	Duration     int     `json:"duration,string,omitempty"`
	Operator     string  `json:"operator,omitempty"`
	Priority     string  `json:"priority,omitempty"`
	Threshold    float64 `json:"threshold,string"`
	TimeFunction string  `json:"time_function,omitempty"`
}

ConditionTerm represents the terms of a New Relic alert condition.

type ConditionUserDefined added in v0.3.0

type ConditionUserDefined struct {
	Metric        string `json:"metric,omitempty"`
	ValueFunction string `json:"value_function,omitempty"`
}

ConditionUserDefined represents user defined metrics for the New Relic alert condition.

type Incident added in v0.3.0

type Incident struct {
	ID                 int          `json:"id,omitempty"`
	OpenedAt           int          `json:"opened_at,omitempty"`
	ClosedAt           int          `json:"closed_at,omitempty"`
	IncidentPreference string       `json:"incident_preference,omitempty"`
	Links              IncidentLink `json:"links"`
}

Incident represents a New Relic alert incident.

type IncidentLink struct {
	Violations []int `json:"violations,omitempty"`
	PolicyID   int   `json:"policy_id"`
}

IncidentLink represents a link between a New Relic alert incident and its violations

type InfrastructureCondition

type InfrastructureCondition struct {
	Comparison          string                            `json:"comparison,omitempty"`
	CreatedAt           *serialization.EpochTime          `json:"created_at_epoch_millis,omitempty"`
	Critical            *InfrastructureConditionThreshold `json:"critical_threshold,omitempty"`
	Enabled             bool                              `json:"enabled"`
	Event               string                            `json:"event_type,omitempty"`
	ID                  int                               `json:"id,omitempty"`
	IntegrationProvider string                            `json:"integration_provider,omitempty"`
	Name                string                            `json:"name,omitempty"`
	PolicyID            int                               `json:"policy_id,omitempty"`
	ProcessWhere        string                            `json:"process_where_clause,omitempty"`
	RunbookURL          string                            `json:"runbook_url,omitempty"`
	Select              string                            `json:"select_value,omitempty"`
	Type                string                            `json:"type,omitempty"`
	UpdatedAt           *serialization.EpochTime          `json:"updated_at_epoch_millis,omitempty"`
	ViolationCloseTimer *int                              `json:"violation_close_timer,omitempty"`
	Warning             *InfrastructureConditionThreshold `json:"warning_threshold,omitempty"`
	Where               string                            `json:"where_clause,omitempty"`
}

InfrastructureCondition represents a New Relic Infrastructure alert condition.

type InfrastructureConditionThreshold

type InfrastructureConditionThreshold struct {
	Duration int     `json:"duration_minutes,omitempty"`
	Function string  `json:"time_function,omitempty"`
	Value    float64 `json:"value,omitempty"`
}

InfrastructureConditionThreshold represents an New Relic Infrastructure alert condition threshold.

type ListPoliciesParams added in v0.3.0

type ListPoliciesParams struct {
	Name string `url:"filter[name],omitempty"`
}

ListPoliciesParams represents a set of filters to be used when querying New Relic alert policies.

type NrqlCondition

type NrqlCondition struct {
	Terms               []ConditionTerm `json:"terms,omitempty"`
	Nrql                NrqlQuery       `json:"nrql,omitempty"`
	Type                string          `json:"type,omitempty"`
	Name                string          `json:"name,omitempty"`
	RunbookURL          string          `json:"runbook_url,omitempty"`
	ValueFunction       string          `json:"value_function,omitempty"`
	PolicyID            int             `json:"-"`
	ID                  int             `json:"id,omitempty"`
	ViolationCloseTimer int             `json:"violation_time_limit_seconds,omitempty"`
	ExpectedGroups      int             `json:"expected_groups,omitempty"`
	IgnoreOverlap       bool            `json:"ignore_overlap,omitempty"`
	Enabled             bool            `json:"enabled"`
}

NrqlCondition represents a New Relic NRQL Alert condition.

type NrqlQuery

type NrqlQuery struct {
	Query      string `json:"query,omitempty"`
	SinceValue string `json:"since_value,omitempty"`
}

NrqlQuery represents a NRQL query to use with a NRQL alert condition

type PluginsCondition

type PluginsCondition struct {
	PolicyID          int             `json:"-"`
	ID                int             `json:"id,omitempty"`
	Name              string          `json:"name,omitempty"`
	Enabled           bool            `json:"enabled"`
	Entities          []string        `json:"entities,omitempty"`
	Metric            string          `json:"metric,omitempty"`
	MetricDescription string          `json:"metric_description,omitempty"`
	RunbookURL        string          `json:"runbook_url,omitempty"`
	Terms             []ConditionTerm `json:"terms,omitempty"`
	ValueFunction     string          `json:"value_function,omitempty"`
	Plugin            AlertPlugin     `json:"plugin,omitempty"`
}

PluginsCondition represents an alert condition for New Relic Plugins.

type Policy added in v0.3.0

type Policy struct {
	ID                 int                      `json:"id,omitempty"`
	IncidentPreference string                   `json:"incident_preference,omitempty"`
	Name               string                   `json:"name,omitempty"`
	CreatedAt          *serialization.EpochTime `json:"created_at,omitempty"`
	UpdatedAt          *serialization.EpochTime `json:"updated_at,omitempty"`
}

Policy represents a New Relic alert policy.

type PolicyChannels

type PolicyChannels struct {
	ID         int   `json:"id,omitempty"`
	ChannelIDs []int `json:"channel_ids,omitempty"`
}

PolicyChannels represents an association of alert channels to a specific alert policy.

type SyntheticsCondition

type SyntheticsCondition struct {
	ID         int    `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	Enabled    bool   `json:"enabled"`
	RunbookURL string `json:"runbook_url,omitempty"`
	MonitorID  string `json:"monitor_id,omitempty"`
}

SyntheticsCondition represents a New Relic Synthetics alert condition.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL