newrelic

package
v0.0.0-...-ac5bdac Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

README

GoDoc Build status

New Relic API library for Go

This is a Go library that wraps the New Relic REST API. It provides the needed types to interact with the New Relic REST API.

It's still in progress and I haven't finished the entirety of the API, yet. I plan to finish all GET (read) operations before any POST (create) operations, and then PUT (update) operations, and, finally, the DELETE operations.

The API documentation can be found from New Relic, and you'll need an API key (for some operations, an Admin API key is required).

USAGE

This library will provide a client object and any operations can be performed through it. Simply import this library and create a client to get started:

package main

import (
  "github.com/yfronto/newrelic"
)

var api_key = "..." // Required

func main() {
  // Create the client object
  client := newrelic.NewClient(api_key)

  // Get the applciation with ID 12345
  myApp, err := client.GetApplication(12345)
  if err != nil {
    // Handle error
  }

  // Work with the object
  fmt.Println(myApp.Name)

  // Some operations accept options
  opts := &newrelic.AlertEventOptions{
    // Only events with "MyProduct" as the product name
    Filter: newRelic.AlertEventFilter{
      Product: "MyProduct",
    },
  }
  // Get a list of recent events for my product
  events, err := client.GetAlertEvents(opts)
  if err != nil {
    // Handle error
  }
  // Display each event with some information
  for _, e := range events {
    fmt.Printf("%d -- %d (%s): %s\n", e.Timestamp, e.Id, e.Priority, e.Description)
  }
}

Contributing

As I work to populate all actions, bugs are bound to come up. Feel free to send me a pull request or just file an issue. Staying up to date with an API is hard work and I'm happy to accept contributors.

DISCLAIMER: I am in no way affiliated with New Relic and this work is merely a convenience project for myself with no guarantees. It should be considered "as-is" with no implication of responsibility. See the included LICENSE for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertCondition

type AlertCondition struct {
	Enabled     bool                 `json:"enabled,omitempty"`
	Entities    []string             `json:"entities,omitempty"`
	ID          int                  `json:"id,omitempty"`
	Metric      string               `json:"metric,omitempty"`
	Name        string               `json:"name,omitempty"`
	RunbookURL  string               `json:"runbook_url,omitempty"`
	Terms       []AlertConditionTerm `json:"terms,omitempty"`
	Type        string               `json:"type,omitempty"`
	UserDefined AlertUserDefined     `json:"user_defined,omitempty"`
}

AlertCondition describes what triggers an alert for a specific policy.

type AlertConditionOptions

type AlertConditionOptions struct {
	Page int
	// contains filtered or unexported fields
}

AlertConditionOptions define filters for GetAlertConditions.

func (*AlertConditionOptions) String

func (o *AlertConditionOptions) String() string

type AlertConditionTerm

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

AlertConditionTerm defines thresholds that trigger an AlertCondition.

type AlertEvent

type AlertEvent struct {
	ID            int    `json:"id,omitempty"`
	EventType     string `json:"event_type,omitempty"`
	Product       string `json:"product,omitempty"`
	EntityType    string `json:"entity_type,omitempty"`
	EntityGroupID int    `json:"entity_group_id,omitempty"`
	EntityID      int    `json:"entity_id,omitempty"`
	Priority      string `json:"priority,omitempty"`
	Description   string `json:"description,omitempty"`
	Timestamp     int64  `json:"timestamp,omitempty"`
	IncidentID    int    `json:"incident_id"`
}

AlertEvent describes a triggered event.

type AlertEventFilter

type AlertEventFilter struct {
	// TODO: New relic restricts these options
	Product       string
	EntityType    string
	EntityGroupID int
	EntityID      int
	EventType     string
}

AlertEventFilter provides filters for AlertEventOptions when calling GetAlertEvents.

type AlertEventOptions

type AlertEventOptions struct {
	Filter AlertEventFilter
	Page   int
}

AlertEventOptions is an optional means of filtering AlertEvents when calling GetAlertEvents.

func (*AlertEventOptions) String

func (o *AlertEventOptions) String() string

type AlertUserDefined

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

AlertUserDefined describes user-defined behavior for an AlertCondition.

type Application

type Application struct {
	ID                 int                `json:"id,omitempty"`
	Name               string             `json:"name,omitempty"`
	Language           string             `json:"language,omitempty"`
	HealthStatus       string             `json:"health_status,omitempty"`
	Reporting          bool               `json:"reporting,omitempty"`
	LastReportedAt     time.Time          `json:"last_reported_at,omitempty"`
	ApplicationSummary ApplicationSummary `json:"application_summary,omitempty"`
	EndUserSummary     EndUserSummary     `json:"end_user_summary,omitempty"`
	Settings           Settings           `json:"settings,omitempty"`
	Links              Links              `json:"links,omitempty"`
}

Application describes a New Relic Application.

type ApplicationDeployment

type ApplicationDeployment struct {
	ID          int                        `json:"id,omitempty"`
	Revision    string                     `json:"revision,omitempty"`
	Changelog   string                     `json:"changelog,omitempty"`
	Description string                     `json:"description,omitempty"`
	User        string                     `json:"user,omitempty"`
	Timestamp   time.Time                  `json:"timestamp,omitempty"`
	Links       ApplicationDeploymentLinks `json:"links,omitempty"`
}

ApplicationDeployment contains information about a New Relic Application Deployment.

type ApplicationDeploymentLinks struct {
	Application int `json:"application,omitempty"`
}

ApplicationDeploymentLinks represents links that apply to an ApplicationDeployment.

type ApplicationDeploymentOptions

type ApplicationDeploymentOptions struct {
	Page int
}

ApplicationDeploymentOptions provide a means to filter when calling GetApplicationDeployments.

func (*ApplicationDeploymentOptions) String

type ApplicationFilter

type ApplicationFilter struct {
	Name     string
	Host     string
	IDs      []int
	Language string
}

ApplicationFilter provides a means to filter requests through ApplicaitonOptions when calling GetApplications.

type ApplicationHost

type ApplicationHost struct {
	ApplicationName    string                        `json:"application_name,omitempty"`
	ApplicationSummary ApplicationHostSummary        `json:"application_summary,omitempty"`
	HealthStatus       string                        `json:"health_status,omitempty"`
	Host               string                        `json:"host,omitempty"`
	ID                 int                           `json:"idomitempty"`
	Language           string                        `json:"language,omitempty"`
	Links              ApplicationHostLinks          `json:"links,omitempty"`
	EndUserSummary     ApplicationHostEndUserSummary `json:"end_user_summary,omitempty"`
}

ApplicationHost describes a New Relic Application Host.

type ApplicationHostEndUserSummary

type ApplicationHostEndUserSummary struct {
	ResponseTime float64 `json:"response_time,omitempty"`
	Throughput   float64 `json:"throughput,omitempty"`
	ApdexScore   float64 `json:"apdex_score,omitempty"`
}

ApplicationHostEndUserSummary describes the end user summary component of an ApplicationHost.

type ApplicationHostLinks struct {
	Application          int   `json:"application,omitempty"`
	ApplicationInstances []int `json:"application_instances,omitempty"`
	Server               int   `json:"server,omitempty"`
}

ApplicationHostLinks list IDs associated with an ApplicationHost.

type ApplicationHostSummary

type ApplicationHostSummary struct {
	ApdexScore    float64 `json:"apdex_score,omitempty"`
	ErrorRate     float64 `json:"error_rate,omitempty"`
	InstanceCount int     `json:"instance_count,omitempty"`
	ResponseTime  float64 `json:"response_time,omitempty"`
	Throughput    float64 `json:"throughput,omitempty"`
}

ApplicationHostSummary describes an Application's host.

type ApplicationHostsFilter

type ApplicationHostsFilter struct {
	Hostname string
	IDs      []int
}

ApplicationHostsFilter provides a means to filter requests through ApplicationHostsOptions when calling GetApplicationHosts.

type ApplicationHostsOptions

type ApplicationHostsOptions struct {
	Filter ApplicationHostsFilter
	Page   int
}

ApplicationHostsOptions provide a means to filter results when calling GetApplicationHosts.

func (*ApplicationHostsOptions) String

func (o *ApplicationHostsOptions) String() string

type ApplicationInstance

type ApplicationInstance struct {
	ID                 int                               `json:"id,omitempty"`
	ApplicationName    string                            `json:"application_name,omitempty"`
	Host               string                            `json:"host,omitempty"`
	Port               int                               `json:"port,omitempty"`
	Language           string                            `json:"language,omitempty"`
	HealthStatus       string                            `json:"health_status,omitempty"`
	ApplicationSummary ApplicationInstanceSummary        `json:"application_summary,omitempty"`
	EndUserSummary     ApplicationInstanceEndUserSummary `json:"end_user_summary,omitempty"`
	Links              ApplicationInstanceLinks          `json:"links,omitempty"`
}

ApplicationInstance describes a New Relic Application instance.

type ApplicationInstanceEndUserSummary

type ApplicationInstanceEndUserSummary struct {
	ResponseTime float64 `json:"response_time,omitempty"`
	Throughput   float64 `json:"throughput,omitempty"`
	ApdexScore   float64 `json:"apdex_score,omitempty"`
}

ApplicationInstanceEndUserSummary describes the end user summary component of an ApplicationInstance.

type ApplicationInstanceLinks struct {
	Application     int `json:"application,omitempty"`
	ApplicationHost int `json:"application_host,omitempty"`
	Server          int `json:"server,omitempty"`
}

ApplicationInstanceLinks lists IDs associated with an ApplicationInstances.

type ApplicationInstanceSummary

type ApplicationInstanceSummary struct {
	ResponseTime  float64 `json:"response_time,omitempty"`
	Throughput    float64 `json:"throughput,omitempty"`
	ErrorRate     float64 `json:"error_rate,omitempty"`
	ApdexScore    float64 `json:"apdex_score,omitempty"`
	InstanceCount int     `json:"instance_count,omitempty"`
}

ApplicationInstanceSummary describes an Application's instance.

type ApplicationInstancesFilter

type ApplicationInstancesFilter struct {
	Hostname string
	IDs      []int
}

ApplicationInstancesFilter provides a means to filter requests through ApplicationInstancesOptions when calling GetApplicationInstances.

type ApplicationInstancesOptions

type ApplicationInstancesOptions struct {
	Filter ApplicationInstancesFilter
	Page   int
}

ApplicationInstancesOptions provides a means to filter results when calling GetApplicationInstances.

func (*ApplicationInstancesOptions) String

func (o *ApplicationInstancesOptions) String() string

type ApplicationOptions

type ApplicationOptions struct {
	Filter ApplicationFilter
	Page   int
}

ApplicationOptions provides a means to filter results when calling GetApplicaitons.

func (*ApplicationOptions) String

func (o *ApplicationOptions) String() string

type ApplicationSummary

type ApplicationSummary struct {
	ResponseTime            float64 `json:"response_time,omitempty"`
	Throughput              float64 `json:"throughput,omitempty"`
	ErrorRate               float64 `json:"error_rate,omitempty"`
	ApdexTarget             float64 `json:"apdex_target,omitempty"`
	ApdexScore              float64 `json:"apdex_score,omitempty"`
	HostCount               int     `json:"host_count,omitempty"`
	InstanceCount           int     `json:"instance_count,omitempty"`
	ConcurrentInstanceCount int     `json:"concurrent_instance_count,omitempty"`
}

ApplicationSummary describes the brief summary component of an Application.

type Array

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

An Array is a type expected by the NewRelic API that differs from a comma- separated list. When passing GET params that expect an 'Array' type with one to many values, the expected format is "key=val1&key=val2" but an argument with zero to many values is of the form "key=val1,val2", and neither can be used in the other's place, so we have to differentiate somehow.

type BrowserApplication

type BrowserApplication struct {
	ID                   int    `json:"id,omitempty"`
	Name                 string `json:"name,omitempty"`
	BrowserMonitoringKey string `json:"browser_monitoring_key,omitempty"`
	LoaderScript         string `json:"loader_script,omitempty"`
}

BrowserApplication describes a New Relic Browser Application.

type BrowserApplicationsFilter

type BrowserApplicationsFilter struct {
	Name string
	IDs  []int
}

BrowserApplicationsFilter is the filtering component of BrowserApplicationsOptions

type BrowserApplicationsOptions

type BrowserApplicationsOptions struct {
	Filter BrowserApplicationsFilter
	Page   int
}

BrowserApplicationsOptions provides a filtering mechanism for GetBrowserApplications.

func (*BrowserApplicationsOptions) String

func (o *BrowserApplicationsOptions) String() string

type Client

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

Client provides a set of methods to interact with the New Relic API.

func NewClient

func NewClient(apiKey string) *Client

NewClient returns a new Client object for interfacing with the New Relic API.

func NewWithHTTPClient

func NewWithHTTPClient(apiKey string, client *http.Client) *Client

NewWithHTTPClient returns a new Client object for interfacing with the New Relic API, allowing for override of the http.Client object.

func (*Client) GetAlertConditions

func (c *Client) GetAlertConditions(policy int, options *AlertConditionOptions) ([]AlertCondition, error)

GetAlertConditions will return any AlertCondition defined for a given policy, optionally filtered by AlertConditionOptions.

func (*Client) GetAlertEvents

func (c *Client) GetAlertEvents(options *AlertEventOptions) ([]AlertEvent, error)

GetAlertEvents will return a slice of recent AlertEvent items triggered, optionally filtering by AlertEventOptions.

func (*Client) GetApplication

func (c *Client) GetApplication(id int) (*Application, error)

GetApplication returns a single Application associated with a given ID.

func (*Client) GetApplicationDeployments

func (c *Client) GetApplicationDeployments(id int, opt *ApplicationDeploymentOptions) ([]ApplicationDeployment, error)

GetApplicationDeployments returns a slice of New Relic Application Deployments.

func (*Client) GetApplicationHost

func (c *Client) GetApplicationHost(appID, hostID int) (*ApplicationHost, error)

GetApplicationHost returns a single Application Host associated with the given application host ID and host ID.

func (*Client) GetApplicationHostMetricData

func (c *Client) GetApplicationHostMetricData(appID, hostID int, names []string, options *MetricDataOptions) (*MetricDataResponse, error)

GetApplicationHostMetricData will return all metric data for a particular application's host and slice of metric names, optionally filtered by MetricDataOptions.

func (*Client) GetApplicationHostMetrics

func (c *Client) GetApplicationHostMetrics(appID, hostID int, options *MetricsOptions) ([]Metric, error)

GetApplicationHostMetrics will return a slice of Metric items for a particular Application ID's Host ID, optionally filtering by MetricsOptions.

func (*Client) GetApplicationHosts

func (c *Client) GetApplicationHosts(id int, options *ApplicationHostsOptions) ([]ApplicationHost, error)

GetApplicationHosts returns a slice of New Relic Application Hosts, optionally filtering by ApplicationHostOptions.

func (*Client) GetApplicationInstance

func (c *Client) GetApplicationInstance(appID, instanceID int) (*ApplicationInstance, error)

GetApplicationInstance returns a single Application Instance associated with the given application ID and instance ID

func (*Client) GetApplicationInstanceMetricData

func (c *Client) GetApplicationInstanceMetricData(appID, instanceID int, names []string, options *MetricDataOptions) (*MetricDataResponse, error)

GetApplicationInstanceMetricData will return all metric data for a particular application's instance and slice of metric names, optionally filtered by MetricDataOptions.

func (*Client) GetApplicationInstanceMetrics

func (c *Client) GetApplicationInstanceMetrics(appID, instanceID int, options *MetricsOptions) ([]Metric, error)

GetApplicationInstanceMetrics will return a slice of Metric items for a particular Application ID's instance ID, optionally filtering by MetricsOptions.

func (*Client) GetApplicationInstances

func (c *Client) GetApplicationInstances(appID int, options *ApplicationInstancesOptions) ([]ApplicationInstance, error)

GetApplicationInstances returns a slice of New Relic Application Instances, optionall filtering by ApplicationInstancesOptions.

func (*Client) GetApplicationMetricData

func (c *Client) GetApplicationMetricData(id int, names []string, options *MetricDataOptions) (*MetricDataResponse, error)

GetApplicationMetricData will return all metric data for a particular application and slice of metric names, optionally filtered by MetricDataOptions.

func (*Client) GetApplicationMetrics

func (c *Client) GetApplicationMetrics(id int, options *MetricsOptions) ([]Metric, error)

GetApplicationMetrics will return a slice of Metric items for a particular Application ID, optionally filtering by MetricsOptions.

func (*Client) GetApplications

func (c *Client) GetApplications(options *ApplicationOptions) ([]Application, error)

GetApplications returns a slice of New Relic Applications, optionally filtering by ApplicationOptions.

func (*Client) GetBrowserApplications

func (c *Client) GetBrowserApplications(opt *BrowserApplicationsOptions) ([]BrowserApplication, error)

GetBrowserApplications will return a slice of New Relic Browser Applications, optionally filtered by BrowserApplicationsOptions.

func (*Client) GetComponentMetricData

func (c *Client) GetComponentMetricData(id int, names []string, options *MetricDataOptions) (*MetricDataResponse, error)

GetComponentMetricData will return all metric data for a particular component, optionally filtered by MetricDataOptions.

func (*Client) GetComponentMetrics

func (c *Client) GetComponentMetrics(id int, options *MetricsOptions) ([]Metric, error)

GetComponentMetrics will return a slice of Metric items for a particular Component ID, optionally filtered by MetricsOptions.

func (*Client) GetKeyTransaction

func (c *Client) GetKeyTransaction(id int) (*KeyTransaction, error)

GetKeyTransaction will return a single New Relic Key Transaction for the given id.

func (*Client) GetKeyTransactions

func (c *Client) GetKeyTransactions(opt *KeyTransactionsOptions) ([]KeyTransaction, error)

GetKeyTransactions will return a slice of New Relic Key Transactions, optionally filtered by KeyTransactionsOptions.

func (*Client) GetLegacyAlertPolicies

func (c *Client) GetLegacyAlertPolicies(options *LegacyAlertPolicyOptions) ([]LegacyAlertPolicy, error)

GetLegacyAlertPolicies will return a slice of LegacyAlertPolicy items, optionally filtering by LegacyAlertPolicyOptions.

func (*Client) GetLegacyAlertPolicy

func (c *Client) GetLegacyAlertPolicy(id int) (*LegacyAlertPolicy, error)

GetLegacyAlertPolicy will return the LegacyAlertPolicy with particular ID.

func (*Client) GetMobileApplication

func (c *Client) GetMobileApplication(id int) (*MobileApplication, error)

GetMobileApplication returns a single Mobile Application with the id.

func (*Client) GetMobileApplicationMetricData

func (c *Client) GetMobileApplicationMetricData(id int, names []string, options *MetricDataOptions) (*MetricDataResponse, error)

GetMobileApplicationMetricData will return all metric data for a particular MobileAplication and slice of metric names, optionally filtered by MetricDataOptions.

func (*Client) GetMobileApplicationMetrics

func (c *Client) GetMobileApplicationMetrics(id int, options *MetricsOptions) ([]Metric, error)

GetMobileApplicationMetrics will return a slice of Metric items for a particular MobileAplication ID, optionally filtering by MetricsOptions.

func (*Client) GetMobileApplications

func (c *Client) GetMobileApplications() ([]MobileApplication, error)

GetMobileApplications returns a slice of New Relic Mobile Applications.

func (*Client) GetNotificationChannel

func (c *Client) GetNotificationChannel(id int) (*NotificationChannel, error)

GetNotificationChannel will return the NotificationChannel with particular ID.

func (*Client) GetNotificationChannels

func (c *Client) GetNotificationChannels(options *NotificationChannelsOptions) ([]NotificationChannel, error)

GetNotificationChannels will return a slice of NotificationChannel items, optionally filtering by NotificationChannelsOptions.

func (*Client) GetServer

func (c *Client) GetServer(id int) (*Server, error)

GetServer will return a single New Relic Server for the given id.

func (*Client) GetServerMetricData

func (c *Client) GetServerMetricData(id int, names []string, options *MetricDataOptions) (*MetricDataResponse, error)

GetServerMetricData will return all metric data for a particular Server and slice of metric names, optionally filtered by MetricDataOptions.

func (*Client) GetServerMetrics

func (c *Client) GetServerMetrics(id int, options *MetricsOptions) ([]Metric, error)

GetServerMetrics will return a slice of Metric items for a particular Server ID, optionally filtering by MetricsOptions.

func (*Client) GetServers

func (c *Client) GetServers(opt *ServersOptions) ([]Server, error)

GetServers will return a slice of New Relic Servers, optionally filtered by ServerOptions.

func (*Client) GetUsages

func (c *Client) GetUsages(product string, start, end time.Time, includeSubaccounts bool) (*UsageData, error)

GetUsages will return usage for a product in a given time frame.

type EndUserSummary

type EndUserSummary struct {
	ResponseTime float64 `json:"response_time,omitempty"`
	Throughput   float64 `json:"throughput,omitempty"`
	ApdexTarget  float64 `json:"apdex_target,omitempty"`
	ApdexScore   float64 `json:"apdex_score,omitempty"`
}

EndUserSummary describes the end user summary component of an Application.

type KeyTransaction

type KeyTransaction struct {
	ID                 int                 `json:"id,omitempty"`
	Name               string              `json:"name,omitempty"`
	TransactionName    string              `json:"transaction_name,omitempty"`
	HealthStatus       string              `json:"health_status,omitempty"`
	Reporting          bool                `json:"reporting,omitempty"`
	LastReportedAt     time.Time           `json:"last_reported_at,omitempty"`
	ApplicationSummary ApplicationSummary  `json:"application_summary,omitempty"`
	EndUserSummary     EndUserSummary      `json:"end_user_summary,omitempty"`
	Links              KeyTransactionLinks `json:"links,omitempty"`
}

KeyTransaction represents a New Relic Key Transaction.

type KeyTransactionLinks struct {
	Application int `json:"application,omitempty"`
}

KeyTransactionLinks link KeyTransactions to the objects to which they pertain.

type KeyTransactionsFilter

type KeyTransactionsFilter struct {
	Name string
	IDs  []int
}

KeyTransactionsFilter is the filtering component of KeyTransactionsOptions.

type KeyTransactionsOptions

type KeyTransactionsOptions struct {
	Filter KeyTransactionsFilter
	Page   int
}

KeyTransactionsOptions provides a filtering mechanism for GetKeyTransactions.

func (*KeyTransactionsOptions) String

func (o *KeyTransactionsOptions) String() string

type LegacyAlertPolicy

type LegacyAlertPolicy struct {
	Conditions         []LegacyAlertPolicyCondition `json:"conditions,omitempty"`
	Enabled            bool                         `json:"enabled,omitempty"`
	ID                 int                          `json:"id,omitempty"`
	Links              LegacyAlertPolicyLinks       `json:"links,omitempty"`
	IncidentPreference string                       `json:"incident_preference,omitempty"`
	Name               string                       `json:"name,omitempty"`
}

LegacyAlertPolicy describes a New Relic alert policy.

type LegacyAlertPolicyCondition

type LegacyAlertPolicyCondition struct {
	ID             int     `json:"id,omitempty"`
	Enabled        bool    `json:"enabled,omitempty"`
	Severity       string  `json:"severity,omitempty"`
	Threshold      float64 `json:"threshold,omitempty"`
	TriggerMinutes int     `json:"trigger_minutes,omitempty"`
	Type           string  `json:"type,omitempty"`
}

LegacyAlertPolicyCondition describes conditions that trigger an LegacyAlertPolicy.

type LegacyAlertPolicyFilter

type LegacyAlertPolicyFilter struct {
	Name string
}

LegacyAlertPolicyFilter provides filters for LegacyAlertPolicyOptions.

type LegacyAlertPolicyLinks struct {
	NotificationChannels []int `json:"notification_channels,omitempty"`
	Servers              []int `json:"servers,omitempty"`
}

LegacyAlertPolicyLinks describes object links for Alert Policies.

type LegacyAlertPolicyOptions

type LegacyAlertPolicyOptions struct {
	Filter LegacyAlertPolicyFilter
	Page   int
}

LegacyAlertPolicyOptions is an optional means of filtering when calling GetLegacyAlertPolicies.

func (*LegacyAlertPolicyOptions) String

func (o *LegacyAlertPolicyOptions) String() string
type Links struct {
	Servers              []int `json:"servers,omitempty"`
	ApplicationHosts     []int `json:"application_hosts,omitempty"`
	ApplicationInstances []int `json:"application_instances,omitempty"`
	AlertPolicy          int   `json:"alert_policy,omitempty"`
}

Links list IDs associated with an Application.

type Metric

type Metric struct {
	Name   string   `json:"name,omitempty"`
	Values []string `json:"values,omitempty"`
}

Metric describes a New Relic metric.

type MetricClient

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

MetricClient implements a generic New Relic metrics client. This is used as a general client for fetching metric names and data.

func NewMetricClient

func NewMetricClient(newRelicClient *Client) *MetricClient

NewMetricClient creates and returns a new MetricClient.

func (*MetricClient) GetMetricData

func (mc *MetricClient) GetMetricData(path string, names []string, options *MetricDataOptions) (*MetricDataResponse, error)

GetMetricData is a generic function for fetching data for a specific metric. from different parts of New Relic. Example: Application metric data, Component metric data, etc.

func (*MetricClient) GetMetrics

func (mc *MetricClient) GetMetrics(path string, options *MetricsOptions) ([]Metric, error)

GetMetrics is a generic function for fetching a list of available metrics from different parts of New Relic. Example: Application metrics, Component metrics, etc.

type MetricData

type MetricData struct {
	Name       string            `json:"name,omitempty"`
	Timeslices []MetricTimeslice `json:"timeslices,omitempty"`
}

MetricData describes the data for a particular metric.

type MetricDataOptions

type MetricDataOptions struct {
	Names     Array
	Values    Array
	From      time.Time
	To        time.Time
	Period    int
	Summarize bool
	Raw       bool
}

MetricDataOptions allow filtering when getting data about a particular set of New Relic metrics.

func (*MetricDataOptions) String

func (o *MetricDataOptions) String() string

type MetricDataResponse

type MetricDataResponse struct {
	From            time.Time    `json:"from,omitempty"`
	To              time.Time    `json:"to,omitempty"`
	MetricsNotFound []string     `json:"metrics_not_found,omitempty"`
	MetricsFound    []string     `json:"metrics_found,omitempty"`
	Metrics         []MetricData `json:"metrics,omitempty"`
}

MetricDataResponse is the response received from New Relic for any request for metric data.

type MetricTimeslice

type MetricTimeslice struct {
	From   time.Time          `json:"from,omitempty"`
	To     time.Time          `json:"to,omitempty"`
	Values map[string]float64 `json:"values,omitempty"`
}

MetricTimeslice describes the period to which a Metric pertains.

type MetricsOptions

type MetricsOptions struct {
	Name string
	Page int
}

MetricsOptions options allow filtering when getting lists of metric names associated with an entity.

func (*MetricsOptions) String

func (o *MetricsOptions) String() string

type MobileApplication

type MobileApplication struct {
	ID            int                           `json:"id,omitempty"`
	Name          string                        `json:"name,omitempty"`
	HealthStatus  string                        `json:"health_status,omitempty"`
	Reporting     bool                          `json:"reporting,omitempty"`
	MobileSummary MobileApplicationSummary      `json:"mobile_summary,omitempty"`
	CrashSummary  MobileApplicationCrashSummary `json:"crash_summary,omitempty"`
}

MobileApplication describes a New Relic Application Host.

type MobileApplicationCrashSummary

type MobileApplicationCrashSummary struct {
	SupportsCrashData    bool    `json:"supports_crash_data,omitempty"`
	UnresolvedCrashCount int     `json:"unresolved_crash_count,omitempty"`
	CrashCount           int     `json:"crash_count,omitempty"`
	CrashRate            float64 `json:"crash_rate,omitempty"`
}

MobileApplicationCrashSummary describes a MobileApplication's crash data.

type MobileApplicationSummary

type MobileApplicationSummary struct {
	ActiveUsers     int     `json:"active_users,omitempty"`
	LaunchCount     int     `json:"launch_count,omitempty"`
	Throughput      float64 `json:"throughput,omitempty"`
	ResponseTime    float64 `json:"response_time,omitempty"`
	CallsPerSession float64 `json:"calls_per_session,omitempty"`
	InteractionTime float64 `json:"interaction_time,omitempty"`
	FailedCallRate  float64 `json:"failed_call_rate,omitempty"`
	RemoteErrorRate float64 `json:"remote_error_rate"`
}

MobileApplicationSummary describes an Application's host.

type NotificationChannel

type NotificationChannel struct {
	ID           int                      `json:"id,omitempty"`
	Type         string                   `json:"type,omitempty"`
	DowntimeOnly bool                     `json:"downtime_only,omitempty"`
	URL          string                   `json:"url,omitempty"`
	Name         string                   `json:"name,omitempty"`
	Description  string                   `json:"description,omitempty"`
	Email        string                   `json:"email,omitempty"`
	Subdomain    string                   `json:"subdomain,omitempty"`
	Service      string                   `json:"service,omitempty"`
	MobileAlerts bool                     `json:"mobile_alerts,omitempty"`
	EmailAlerts  bool                     `json:"email_alerts,omitempty"`
	Room         string                   `json:"room,omitempty"`
	Links        NotificationChannelLinks `json:"links,omitempty"`
}

NotificationChannel describes a New Relic notification channel.

type NotificationChannelLinks struct {
	NotificationChannels []int `json:"notification_channels,omitempty"`
	User                 int   `json:"user,omitempty"`
}

NotificationChannelLinks describes object links for notification channels.

type NotificationChannelsFilter

type NotificationChannelsFilter struct {
	Type []string
	IDs  []int
}

NotificationChannelsFilter provides filters for NotificationChannelsOptions.

type NotificationChannelsOptions

type NotificationChannelsOptions struct {
	Filter NotificationChannelsFilter
	Page   int
}

NotificationChannelsOptions is an optional means of filtering when calling GetNotificationChannels.

func (*NotificationChannelsOptions) String

func (o *NotificationChannelsOptions) String() string

type Server

type Server struct {
	ID             int           `json:"id,omitempty"`
	AccountID      int           `json:"account_id,omitempty"`
	Name           string        `json:"name,omitempty"`
	Host           string        `json:"host,omitempty"`
	HealthStatus   string        `json:"health_status,omitempty"`
	Reporting      bool          `json:"reporting,omitempty"`
	LastReportedAt time.Time     `json:"last_reported_at,omitempty"`
	Summary        ServerSummary `json:"summary,omitempty"`
	Links          ServerLinks   `json:"links,omitempty"`
}

Server represents a New Relic Server.

type ServerLinks struct {
	AlertPolicy int `json:"alert_policy,omitempty"`
}

ServerLinks link Servers to the objects to which they pertain.

type ServerSummary

type ServerSummary struct {
	CPU             float64 `json:"cpu,omitempty"`
	CPUStolen       float64 `json:"cpu_stolen,omitempty"`
	DiskIO          float64 `json:"disk_io,omitempty"`
	Memory          float64 `json:"memory,omitempty"`
	MemoryUsed      int64   `json:"memory_used,omitempty"`
	MemoryTotal     int64   `json:"memory_total,omitempty"`
	FullestDisk     float64 `json:"fullest_disk,omitempty"`
	FullestDiskFree int64   `json:"fullest_disk_free,omitempty"`
}

ServerSummary describes the summary component of a Server.

type ServersFilter

type ServersFilter struct {
	Name     string
	Host     string
	IDs      []int
	Labels   []string
	Reported bool
}

ServersFilter is the filtering component of ServersOptions.

type ServersOptions

type ServersOptions struct {
	Filter ServersFilter
	Page   int
}

ServersOptions provides a filtering mechanism for GetServers.

func (*ServersOptions) String

func (o *ServersOptions) String() string

type Settings

type Settings struct {
	AppApdexThreshold        float64 `json:"app_apdex_threshold,omitempty"`
	EndUserApdexThreshold    float64 `json:"end_user_apdex_threshold,omitempty"`
	EnableRealUserMonitoring bool    `json:"enable_real_user_monitoring,omitempty"`
	UseServerSideConfig      bool    `json:"use_server_side_config,omitempty"`
}

Settings describe settings for an Application.

type Usage

type Usage struct {
	From  time.Time `json:"from,omitempty"`
	To    time.Time `json:"to,omitempty"`
	Usage int       `json:"usage,omitempty"`
}

Usage describes usage over a single time period.

type UsageData

type UsageData struct {
	Product string    `json:"product,omitempty"`
	From    time.Time `json:"from,omitempty"`
	To      time.Time `json:"to,omitempty"`
	Unit    string    `json:"unit,omitempty"`
	Usages  []Usage   `json:"usages,omitempty"`
}

UsageData represents usage data for a product over a time frame, including a slice of Usages.

Jump to

Keyboard shortcuts

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