Documentation ¶
Overview ¶
Package alerts provides a programmatic API for interacting with the New Relic Alerts product. It can be used for a variety of operations, including:
- Creating, reading, updating, and deleting alert policies
- Creating, reading, updating, and deleting alert notification channels
- Associating one or more notification channels with an alert policy
- Creating, reading, updating, and deleting APM alert conditions
- Creating, reading, updating, and deleting NRQL alert conditions
- Creating, reading, updating, and deleting Synthetics alert conditions
- Creating, reading, updating, and deleting multi-location Synthetics conditions
- Creating, reading, updating, and deleting Infrastructure alert conditions
- Creating, reading, updating, and deleting Plugins alert conditions
- Associating one or more alert conditions with a policy
Authentication ¶
You will need a valid API key to communicate with the backend New Relic APIs that provide this functionality. Using a Personal API key is the preferred method but an Admin's API key will also work. See the API key documentation below for more information on how to locate these keys:
https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys
Working with Infrastructure and Synthetics alert conditions requires an Admin's API key. If you are using the client to provision either of these resources alongside others, initializing the client with both types of keys is preferred.
Example (Policy) ¶
// Initialize the client configuration. A Personal API key or Admin API key // is required to communicate with the backend API. cfg := config.Config{ AdminAPIKey: os.Getenv("NEW_RELIC_ADMIN_API_KEY"), PersonalAPIKey: os.Getenv("NEW_RELIC_API_KEY"), } // Initialize the client. client := New(cfg) // Create a new alert policy. p := Policy{ Name: "Example alert policy", IncidentPreference: IncidentPreferenceTypes.PerCondition, } policy, err := client.CreatePolicy(p) if err != nil { log.Fatal("error creating policy:", err) } // Create a new alert notification channel. ec := Channel{ Name: "Example email notification channel", Type: ChannelTypes.Email, Configuration: ChannelConfiguration{ Recipients: "test@newrelic.com", IncludeJSONAttachment: "1", }, } emailChannel, err := client.CreateChannel(ec) if err != nil { log.Fatal("error creating notification channel:", err) } // Associate the new alert channel with the created policy. _, err = client.UpdatePolicyChannels(policy.ID, []int{emailChannel.ID}) if err != nil { log.Fatal("error associating policy with channel:", err) } // Create a new NRQL alert condition. nc := &NrqlCondition{ Name: "Example NRQL condition", Type: "static", RunbookURL: "https://www.example.com/myrunbook", Enabled: true, ValueFunction: ValueFunctionTypes.SingleValue, Nrql: NrqlQuery{ Query: "FROM Transaction SELECT average(duration) WHERE appName = 'Example Application'", SinceValue: "3", }, Terms: []ConditionTerm{ { Duration: 5, Operator: OperatorTypes.Above, Priority: PriorityTypes.Warning, Threshold: 3, TimeFunction: TimeFunctionTypes.All, }, { Duration: 5, Operator: OperatorTypes.Above, Priority: PriorityTypes.Critical, Threshold: 1, TimeFunction: TimeFunctionTypes.All, }, }, } _, err = client.CreateNrqlCondition(policy.ID, *nc) if err != nil { log.Fatal("error creating NRQL condition:", err) }
Output:
Index ¶
- Variables
- type AlertPlugin
- type Alerts
- func (a *Alerts) AcknowledgeIncident(id int) (*Incident, error)
- func (a *Alerts) CloseIncident(id int) (*Incident, error)
- func (a *Alerts) CreateChannel(channel Channel) (*Channel, error)
- func (a *Alerts) CreateCondition(policyID int, condition Condition) (*Condition, error)
- func (a *Alerts) CreateInfrastructureCondition(condition InfrastructureCondition) (*InfrastructureCondition, error)
- func (a *Alerts) CreateMultiLocationSyntheticsCondition(condition MultiLocationSyntheticsCondition, policyID int) (*MultiLocationSyntheticsCondition, error)
- func (a *Alerts) CreateNrqlCondition(policyID int, condition NrqlCondition) (*NrqlCondition, error)
- func (a *Alerts) CreatePluginsCondition(policyID int, condition PluginsCondition) (*PluginsCondition, error)
- func (a *Alerts) CreatePolicy(policy Policy) (*Policy, error)
- func (a *Alerts) CreatePolicyMutation(accountID int, policy QueryPolicyCreateInput) (*QueryPolicy, error)
- func (a *Alerts) CreateSyntheticsCondition(policyID int, condition SyntheticsCondition) (*SyntheticsCondition, error)
- func (a *Alerts) DeleteChannel(id int) (*Channel, error)
- func (a *Alerts) DeleteCondition(id int) (*Condition, error)
- func (a *Alerts) DeleteInfrastructureCondition(conditionID int) error
- func (a *Alerts) DeleteMultiLocationSyntheticsCondition(conditionID int) (*MultiLocationSyntheticsCondition, error)
- func (a *Alerts) DeleteNrqlCondition(id int) (*NrqlCondition, error)
- func (a *Alerts) DeletePluginsCondition(id int) (*PluginsCondition, error)
- func (a *Alerts) DeletePolicy(id int) (*Policy, error)
- func (a *Alerts) DeletePolicyChannel(policyID int, channelID int) (*Channel, error)
- func (a *Alerts) DeletePolicyMutation(accountID, id int) (*QueryPolicy, error)
- func (a *Alerts) DeleteSyntheticsCondition(conditionID int) (*SyntheticsCondition, error)
- func (a *Alerts) GetChannel(id int) (*Channel, error)
- func (a *Alerts) GetCondition(policyID int, id int) (*Condition, error)
- func (a *Alerts) GetInfrastructureCondition(conditionID int) (*InfrastructureCondition, error)
- func (a *Alerts) GetNrqlCondition(policyID int, id int) (*NrqlCondition, error)
- func (a *Alerts) GetPluginsCondition(policyID int, pluginID int) (*PluginsCondition, error)
- func (a *Alerts) GetPolicy(id int) (*Policy, error)
- func (a *Alerts) GetSyntheticsCondition(policyID int, conditionID int) (*SyntheticsCondition, error)
- func (a *Alerts) ListChannels() ([]*Channel, error)
- func (a *Alerts) ListConditions(policyID int) ([]*Condition, error)
- func (a *Alerts) ListIncidents(onlyOpen bool, excludeViolations bool) ([]*Incident, error)
- func (a *Alerts) ListInfrastructureConditions(policyID int) ([]InfrastructureCondition, error)
- func (a *Alerts) ListMultiLocationSyntheticsConditions(policyID int) ([]*MultiLocationSyntheticsCondition, error)
- func (a *Alerts) ListNrqlConditions(policyID int) ([]*NrqlCondition, error)
- func (a *Alerts) ListPluginsConditions(policyID int) ([]*PluginsCondition, error)
- func (a *Alerts) ListPolicies(params *ListPoliciesParams) ([]Policy, error)
- func (a *Alerts) ListSyntheticsConditions(policyID int) ([]*SyntheticsCondition, error)
- func (a *Alerts) QueryPolicy(accountID, id int) (*QueryPolicy, error)
- func (a *Alerts) UpdateCondition(condition Condition) (*Condition, error)
- func (a *Alerts) UpdateInfrastructureCondition(condition InfrastructureCondition) (*InfrastructureCondition, error)
- func (a *Alerts) UpdateMultiLocationSyntheticsCondition(condition MultiLocationSyntheticsCondition) (*MultiLocationSyntheticsCondition, error)
- func (a *Alerts) UpdateNrqlCondition(condition NrqlCondition) (*NrqlCondition, error)
- func (a *Alerts) UpdatePluginsCondition(condition PluginsCondition) (*PluginsCondition, error)
- func (a *Alerts) UpdatePolicy(policy Policy) (*Policy, error)
- func (a *Alerts) UpdatePolicyChannels(policyID int, channelIDs []int) (*PolicyChannels, error)
- func (a *Alerts) UpdatePolicyMutation(accountID int, policyID int, policy QueryPolicyUpdateInput) (*QueryPolicy, error)
- func (a *Alerts) UpdateSyntheticsCondition(condition SyntheticsCondition) (*SyntheticsCondition, error)
- type Channel
- type ChannelConfiguration
- type ChannelLinks
- type ChannelType
- type Condition
- type ConditionTerm
- type ConditionType
- type ConditionUserDefined
- type Incident
- type IncidentLink
- type IncidentPreferenceType
- type InfrastructureCondition
- type InfrastructureConditionThreshold
- type ListPoliciesParams
- type MetricType
- type MultiLocationSyntheticsCondition
- type MultiLocationSyntheticsConditionTerm
- type NrqlCondition
- type NrqlQuery
- type OperatorType
- type PluginsCondition
- type Policy
- type PolicyChannels
- type PriorityType
- type QueryPolicy
- type QueryPolicyCreateInput
- type QueryPolicyInput
- type QueryPolicyUpdateInput
- type SyntheticsCondition
- type TimeFunctionType
- type ValueFunctionType
Examples ¶
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.
var ( // ChannelTypes enumerates the possible channel types for an alert channel. ChannelTypes = struct { Email ChannelType OpsGenie ChannelType PagerDuty ChannelType Slack ChannelType User ChannelType VictorOps ChannelType Webhook ChannelType }{ Email: "email", OpsGenie: "opsgenie", PagerDuty: "pagerduty", Slack: "slack", User: "user", VictorOps: "victorops", Webhook: "webhook", } )
var ( // ConditionTypes enumerates the possible condition types for an alert condition. ConditionTypes = struct { APMApplicationMetric ConditionType APMKeyTransactionMetric ConditionType ServersMetric ConditionType BrowserMetric ConditionType MobileMetric ConditionType }{ APMApplicationMetric: "apm_app_metric", APMKeyTransactionMetric: "apm_kt_metric", ServersMetric: "servers_metric", BrowserMetric: "browser_metric", MobileMetric: "mobile_metric", } )
var ( // IncidentPreferenceTypes specifies the possible incident preferenece types for an alert policy. IncidentPreferenceTypes = struct { PerPolicy IncidentPreferenceType PerCondition IncidentPreferenceType PerConditionAndTarget IncidentPreferenceType }{ PerPolicy: "PER_POLICY", PerCondition: "PER_CONDITION", PerConditionAndTarget: "PER_CONDITION_AND_TARGET", } )
var ( // MetricTypes enumerates the possible metric types for an alert condition. // Not all metric types are valid for all condition types. See the docuentation for more details. MetricTypes = struct { AjaxResponseTime MetricType AjaxThroughput MetricType Apdex MetricType CPUPercentage MetricType Database MetricType DiskIOPercentage MetricType DomProcessing MetricType EndUserApdex MetricType ErrorCount MetricType ErrorPercentage MetricType FullestDiskPercentage MetricType Images MetricType JSON MetricType LoadAverageOneMinute MetricType MemoryPercentage MetricType MobileCrashRate MetricType Network MetricType NetworkErrorPercentage MetricType PageRendering MetricType PageViewThroughput MetricType PageViewsWithJsErrors MetricType RequestQueuing MetricType ResponseTime MetricType ResponseTimeBackground MetricType ResponseTimeWeb MetricType StatusErrorPercentage MetricType Throughput MetricType ThroughputBackground MetricType ThroughputWeb MetricType TotalPageLoad MetricType UserDefined MetricType ViewLoading MetricType WebApplication MetricType }{ AjaxResponseTime: "ajax_response_time", AjaxThroughput: "ajax_throughput", Apdex: "apdex", CPUPercentage: "cpu_percentage", Database: "database", DiskIOPercentage: "disk_io_percentage", DomProcessing: "dom_processing", EndUserApdex: "end_user_apdex", ErrorCount: "error_count", ErrorPercentage: "error_percentage", FullestDiskPercentage: "fullest_disk_percentage", Images: "images", JSON: "json", LoadAverageOneMinute: "load_average_one_minute", MemoryPercentage: "memory_percentage", MobileCrashRate: "mobile_crash_rate", Network: "network", NetworkErrorPercentage: "network_error_percentage", PageRendering: "page_rendering", PageViewThroughput: "page_view_throughput", PageViewsWithJsErrors: "page_views_with_js_errors", RequestQueuing: "request_queuing", ResponseTime: "response_time", ResponseTimeBackground: "response_time_background", ResponseTimeWeb: "response_time_web", StatusErrorPercentage: "status_error_percentage", Throughput: "throughput", ThroughputBackground: "throughput_background", ThroughputWeb: "throughput_web", TotalPageLoad: "total_page_load", UserDefined: "user_defined", ViewLoading: "view_loading", WebApplication: "web_application", } )
var ( // OperatorTypes enumerates the possible operator values for alert condition terms. OperatorTypes = struct { Above OperatorType Below OperatorType }{ Above: "above", Below: "below", } )
var ( // PriorityTypes enumerates the possible priority values for alert condition terms. PriorityTypes = struct { Critical PriorityType Warning PriorityType }{ Critical: "critical", Warning: "warning", } )
var ( // TimeFunctionTypes enumerates the possible time function types for alert condition terms. TimeFunctionTypes = struct { All TimeFunctionType Any TimeFunctionType }{ All: "all", Any: "any", } )
var ( // ValueFunctionTypes enumerates the possible value function types for custom metrics. ValueFunctionTypes = struct { Average ValueFunctionType Min ValueFunctionType Max ValueFunctionType Total ValueFunctionType SampleSize ValueFunctionType SingleValue ValueFunctionType }{ Average: "average", Min: "min", Max: "max", Total: "total", SampleSize: "sample_size", SingleValue: "single_value", } )
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 (a *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 (a *Alerts) CreateNrqlCondition(policyID int, condition NrqlCondition) (*NrqlCondition, error)
CreateNrqlCondition creates a NRQL alert condition.
func (*Alerts) CreatePluginsCondition ¶
func (a *Alerts) CreatePluginsCondition(policyID int, 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) CreatePolicyMutation ¶ added in v0.17.0
func (a *Alerts) CreatePolicyMutation(accountID int, policy QueryPolicyCreateInput) (*QueryPolicy, error)
func (*Alerts) CreateSyntheticsCondition ¶
func (a *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 (a *Alerts) DeleteMultiLocationSyntheticsCondition(conditionID int) (*MultiLocationSyntheticsCondition, error)
DeleteMultiLocationSyntheticsCondition delete an alert condition.
func (*Alerts) DeleteNrqlCondition ¶ added in v0.3.0
func (a *Alerts) DeleteNrqlCondition(id int) (*NrqlCondition, error)
DeleteNrqlCondition deletes a NRQL alert condition.
func (*Alerts) DeletePluginsCondition ¶
func (a *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) DeletePolicyMutation ¶ added in v0.17.0
func (a *Alerts) DeletePolicyMutation(accountID, id int) (*QueryPolicy, error)
DeletePolicyMutation is the NerdGraph mutation to delete a policy given the account ID and the policy ID.
func (*Alerts) DeleteSyntheticsCondition ¶
func (a *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 (a *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 (a *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 (a *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 (a *Alerts) ListMultiLocationSyntheticsConditions(policyID int) ([]*MultiLocationSyntheticsCondition, error)
ListMultiLocationSyntheticsConditions returns alert conditions for a specified policy.
func (*Alerts) ListNrqlConditions ¶ added in v0.3.0
func (a *Alerts) ListNrqlConditions(policyID int) ([]*NrqlCondition, error)
ListNrqlConditions returns NRQL alert conditions for a specified policy.
func (*Alerts) ListPluginsConditions ¶
func (a *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 (a *Alerts) ListPolicies(params *ListPoliciesParams) ([]Policy, error)
ListPolicies returns a list of Alert Policies for a given account.
func (*Alerts) ListSyntheticsConditions ¶
func (a *Alerts) ListSyntheticsConditions(policyID int) ([]*SyntheticsCondition, error)
ListSyntheticsConditions returns a list of Synthetics alert conditions for a given policy.
func (*Alerts) QueryPolicy ¶ added in v0.17.0
func (a *Alerts) QueryPolicy(accountID, id int) (*QueryPolicy, error)
QueryPolicy queries NerdGraph for a policy matching the given account ID and policy ID.
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 (a *Alerts) UpdateMultiLocationSyntheticsCondition(condition MultiLocationSyntheticsCondition) (*MultiLocationSyntheticsCondition, error)
UpdateMultiLocationSyntheticsCondition updates an alert condition.
func (*Alerts) UpdateNrqlCondition ¶ added in v0.3.0
func (a *Alerts) UpdateNrqlCondition(condition NrqlCondition) (*NrqlCondition, error)
UpdateNrqlCondition updates a NRQL alert condition.
func (*Alerts) UpdatePluginsCondition ¶
func (a *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 (a *Alerts) UpdatePolicyChannels(policyID int, channelIDs []int) (*PolicyChannels, error)
UpdatePolicyChannels updates a policy by adding the specified notification channels.
func (*Alerts) UpdatePolicyMutation ¶ added in v0.17.0
func (a *Alerts) UpdatePolicyMutation(accountID int, policyID int, policy QueryPolicyUpdateInput) (*QueryPolicy, error)
func (*Alerts) UpdateSyntheticsCondition ¶
func (a *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 ChannelType `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 serialization.MapStringInterface `json:"payload,omitempty"` // Headers is unmarshaled to type map[string]string Headers serialization.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 ChannelType ¶ added in v0.14.0
type ChannelType string
ChannelType specifies the channel type used when creating the alert channel.
type Condition ¶ added in v0.3.0
type Condition struct { ID int `json:"id,omitempty"` Type ConditionType `json:"type,omitempty"` Name string `json:"name,omitempty"` Enabled bool `json:"enabled"` Entities []string `json:"entities,omitempty"` Metric MetricType `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 OperatorType `json:"operator,omitempty"` Priority PriorityType `json:"priority,omitempty"` Threshold float64 `json:"threshold,string"` TimeFunction TimeFunctionType `json:"time_function,omitempty"` }
ConditionTerm represents the terms of a New Relic alert condition.
func (*ConditionTerm) UnmarshalJSON ¶ added in v0.17.1
func (c *ConditionTerm) UnmarshalJSON(data []byte) error
UnmarshalJSON is responsible for unmarshaling the ConditionTerm type.
type ConditionType ¶ added in v0.14.0
type ConditionType string
ConditionType specifies the condition type used when creating the alert condition.
type ConditionUserDefined ¶ added in v0.3.0
type ConditionUserDefined struct { Metric string `json:"metric,omitempty"` ValueFunction ValueFunctionType `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 *serialization.EpochTime `json:"opened_at,omitempty"` ClosedAt *serialization.EpochTime `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 IncidentPreferenceType ¶ added in v0.14.0
type IncidentPreferenceType string
IncidentPreferenceType specifies rollup settings for alert policies.
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 MetricType ¶ added in v0.14.0
type MetricType string
MetricType specifies the metric type used when creating the alert condition.
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 ValueFunctionType `json:"value_function,omitempty"` 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 OperatorType ¶ added in v0.17.0
type OperatorType string
OperatorType specifies the operator for alert condition terms.
type PluginsCondition ¶
type PluginsCondition struct { 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 IncidentPreferenceType `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 PriorityType ¶ added in v0.17.0
type PriorityType string
PriorityType specifies the priority for alert condition terms.
type QueryPolicy ¶ added in v0.17.0
type QueryPolicy struct { ID int `json:"id,string"` IncidentPreference IncidentPreferenceType `json:"incidentPreference"` Name string `json:"name"` }
QueryPolicy is similar to a Policy, but the resulting NerdGraph objects are string IDs in the JSON response.
type QueryPolicyCreateInput ¶ added in v0.17.0
type QueryPolicyCreateInput struct {
QueryPolicyInput
}
type QueryPolicyInput ¶ added in v0.17.0
type QueryPolicyInput struct { IncidentPreference IncidentPreferenceType `json:"incidentPreference"` Name string `json:"name"` }
type QueryPolicyUpdateInput ¶ added in v0.17.0
type QueryPolicyUpdateInput struct {
QueryPolicyInput
}
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.
type TimeFunctionType ¶ added in v0.14.0
type TimeFunctionType string
TimeFunctionType specifies the time function to be used for alert condition terms.
type ValueFunctionType ¶ added in v0.14.0
type ValueFunctionType string
ValueFunctionType specifies the value function to be used for returning custom metric data.