Documentation ¶
Index ¶
- Variables
- type AlertPlugin
- type Alerts
- func (alerts *Alerts) AcknowledgeIncident(id int) (*Incident, error)
- func (alerts *Alerts) CloseIncident(id int) (*Incident, error)
- func (alerts *Alerts) CreateChannel(channel Channel) (*Channel, error)
- func (alerts *Alerts) CreateCondition(condition Condition) (*Condition, error)
- func (a *Alerts) CreateInfrastructureCondition(condition InfrastructureCondition) (*InfrastructureCondition, error)
- func (alerts *Alerts) CreateMultiLocationSyntheticsCondition(condition MultiLocationSyntheticsCondition, policyID int) (*MultiLocationSyntheticsCondition, error)
- func (alerts *Alerts) CreateNrqlCondition(condition NrqlCondition) (*NrqlCondition, error)
- func (alerts *Alerts) CreatePluginsCondition(condition PluginsCondition) (*PluginsCondition, error)
- func (alerts *Alerts) CreatePolicy(policy Policy) (*Policy, error)
- func (alerts *Alerts) CreateSyntheticsCondition(policyID int, condition SyntheticsCondition) (*SyntheticsCondition, error)
- func (alerts *Alerts) DeleteChannel(id int) (*Channel, error)
- func (alerts *Alerts) DeleteCondition(id int) (*Condition, error)
- func (a *Alerts) DeleteInfrastructureCondition(conditionID int) error
- func (alerts *Alerts) DeleteMultiLocationSyntheticsCondition(conditionID int) (*MultiLocationSyntheticsCondition, error)
- func (alerts *Alerts) DeleteNrqlCondition(id int) (*NrqlCondition, error)
- func (alerts *Alerts) DeletePluginsCondition(id int) (*PluginsCondition, error)
- func (alerts *Alerts) DeletePolicy(id int) (*Policy, error)
- func (alerts *Alerts) DeletePolicyChannel(policyID int, channelID int) (*Channel, error)
- func (alerts *Alerts) DeleteSyntheticsCondition(conditionID int) (*SyntheticsCondition, error)
- func (alerts *Alerts) GetChannel(id int) (*Channel, error)
- func (alerts *Alerts) GetCondition(policyID int, id int) (*Condition, error)
- func (a *Alerts) GetInfrastructureCondition(conditionID int) (*InfrastructureCondition, error)
- func (alerts *Alerts) GetNrqlCondition(policyID int, id int) (*NrqlCondition, error)
- func (alerts *Alerts) GetPluginsCondition(policyID int, pluginID int) (*PluginsCondition, error)
- func (alerts *Alerts) GetPolicy(id int) (*Policy, error)
- func (alerts *Alerts) GetSyntheticsCondition(policyID int, conditionID int) (*SyntheticsCondition, error)
- func (alerts *Alerts) ListChannels() ([]*Channel, error)
- func (alerts *Alerts) ListConditions(policyID int) ([]*Condition, error)
- func (alerts *Alerts) ListIncidents(onlyOpen bool, excludeViolations bool) ([]*Incident, error)
- func (a *Alerts) ListInfrastructureConditions(policyID int) ([]InfrastructureCondition, error)
- func (alerts *Alerts) ListMultiLocationSyntheticsConditions(policyID int) ([]*MultiLocationSyntheticsCondition, error)
- func (alerts *Alerts) ListNrqlConditions(policyID int) ([]*NrqlCondition, error)
- func (alerts *Alerts) ListPluginsConditions(policyID int) ([]*PluginsCondition, error)
- func (alerts *Alerts) ListPolicies(params *ListPoliciesParams) ([]Policy, error)
- func (alerts *Alerts) ListSyntheticsConditions(policyID int) ([]*SyntheticsCondition, error)
- func (alerts *Alerts) UpdateCondition(condition Condition) (*Condition, error)
- func (a *Alerts) UpdateInfrastructureCondition(condition InfrastructureCondition) (*InfrastructureCondition, error)
- func (alerts *Alerts) UpdateMultiLocationSyntheticsCondition(condition MultiLocationSyntheticsCondition) (*MultiLocationSyntheticsCondition, error)
- func (alerts *Alerts) UpdateNrqlCondition(condition NrqlCondition) (*NrqlCondition, error)
- func (alerts *Alerts) UpdatePluginsCondition(condition PluginsCondition) (*PluginsCondition, error)
- func (alerts *Alerts) UpdatePolicy(policy Policy) (*Policy, error)
- func (alerts *Alerts) UpdatePolicyChannels(policyID int, channelIDs []int) (*PolicyChannels, error)
- func (alerts *Alerts) UpdateSyntheticsCondition(condition SyntheticsCondition) (*SyntheticsCondition, error)
- type Channel
- type ChannelConfiguration
- type ChannelLinks
- type Condition
- type ConditionTerm
- type ConditionUserDefined
- type Incident
- type IncidentLink
- type InfrastructureCondition
- type InfrastructureConditionThreshold
- type ListPoliciesParams
- type MapStringInterface
- type MultiLocationSyntheticsCondition
- type MultiLocationSyntheticsConditionTerm
- type NrqlCondition
- type NrqlQuery
- type PluginsCondition
- type Policy
- type PolicyChannels
- type SyntheticsCondition
Constants ¶
This section is empty.
Variables ¶
var BaseURLs = region.DefaultBaseURLs
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 ¶
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 (*Alerts) AcknowledgeIncident ¶ added in v0.3.0
AcknowledgeIncident acknowledges an existing incident.
func (*Alerts) CloseIncident ¶ added in v0.3.0
CloseIncident closes an existing open incident.
func (*Alerts) CreateChannel ¶ added in v0.3.0
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
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) CreateMultiLocationSyntheticsCondition ¶ added in v0.9.0
func (alerts *Alerts) CreateMultiLocationSyntheticsCondition(condition MultiLocationSyntheticsCondition, policyID int) (*MultiLocationSyntheticsCondition, error)
CreateMultiLocationSyntheticsCondition creates an alert condition for a specified policy.
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
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
DeleteChannel deletes the alert channel with the specified ID.
func (*Alerts) DeleteCondition ¶ added in v0.3.0
DeleteCondition delete an alert condition.
func (*Alerts) DeleteInfrastructureCondition ¶
DeleteInfrastructureCondition is used to delete a New Relic Infrastructure alert condition.
func (*Alerts) DeleteMultiLocationSyntheticsCondition ¶ added in v0.9.0
func (alerts *Alerts) DeleteMultiLocationSyntheticsCondition(conditionID int) (*MultiLocationSyntheticsCondition, error)
DeleteMultiLocationSyntheticsCondition delete an 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
DeletePolicy deletes an existing alert policy for a given account.
func (*Alerts) DeletePolicyChannel ¶
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
GetChannel returns a specific alert channel by ID for a given account.
func (*Alerts) GetCondition ¶ added in v0.3.0
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
GetPolicy returns a specific alert policy by ID for a given account.
func (*Alerts) GetSyntheticsCondition ¶ added in v0.6.0
func (alerts *Alerts) GetSyntheticsCondition(policyID int, conditionID int) (*SyntheticsCondition, error)
GetSyntheticsCondition retrieves a specific Synthetics alert condition.
func (*Alerts) ListChannels ¶ added in v0.3.0
ListChannels returns all alert channels for a given account.
func (*Alerts) ListConditions ¶ added in v0.3.0
ListConditions returns alert conditions for a specified policy.
func (*Alerts) ListIncidents ¶ added in v0.3.0
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) ListMultiLocationSyntheticsConditions ¶ added in v0.9.0
func (alerts *Alerts) ListMultiLocationSyntheticsConditions(policyID int) ([]*MultiLocationSyntheticsCondition, error)
ListMultiLocationSyntheticsConditions returns alert conditions for a specified policy.
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
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) UpdateMultiLocationSyntheticsCondition ¶ added in v0.9.0
func (alerts *Alerts) UpdateMultiLocationSyntheticsCondition(condition MultiLocationSyntheticsCondition) (*MultiLocationSyntheticsCondition, error)
UpdateMultiLocationSyntheticsCondition updates an 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
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 is unmarshaled to type map[string]string Payload MapStringInterface `json:"payload,omitempty"` // Headers is unmarshaled to type map[string]string Headers MapStringInterface `json:"headers,omitempty"` }
ChannelConfiguration represents a Configuration type within Channels
type ChannelLinks ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 MapStringInterface ¶ added in v0.7.1
type MapStringInterface map[string]interface{}
MapStringInterface is used for custom unmarshaling of fields that have potentially dynamic types. E.g. when a field can be a string or an object/map
func (*MapStringInterface) UnmarshalJSON ¶ added in v0.7.1
func (c *MapStringInterface) UnmarshalJSON(data []byte) error
UnmarshalJSON is a custom unmarshal method to guard against fields that can have more than one type returned from an API.
type MultiLocationSyntheticsCondition ¶ added in v0.9.0
type MultiLocationSyntheticsCondition 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"` Entities []string `json:"entities,omitempty"` Terms []MultiLocationSyntheticsConditionTerm `json:"terms,omitempty"` ViolationTimeLimitSeconds int `json:"violation_time_limit_seconds,omitempty"` }
MultiLocationSyntheticsCondition represents a location-based failure condition.
ViolationTimeLimitSeconds must be one of 3600, 7200, 14400, 28800, 43200, 86400.
type MultiLocationSyntheticsConditionTerm ¶ added in v0.9.0
type MultiLocationSyntheticsConditionTerm struct { Priority string `json:"priority,omitempty"` Threshold int `json:"threshold,omitempty"` }
MultiLocationSyntheticsConditionTerm represents a single term for a location-based failure condition.
Priority must be "warning" or "critical". Threshold must be greater than zero.
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.