wavefront

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

Golang Wavefront Client GoDoc Build Status

Golang SDK for interacting with the Wavefront v2 API, and sending metrics through a Wavefront proxy.

Usage

API Client

Presently support for:

  • Querying
  • Searching
  • Dashboard Management
  • Alert (and Alert Target) Management
  • Events Management

Please see the examples directory for an example on how to use each, or check out the documentation.

package main

import (
    "log"

    wavefront "github.com/spaceapegames/go-wavefront"
)

func main() {
    client, err := wavefront.NewClient{
        &wavefront.Config{
            Address: "test.wavefront.com",
            Token:   "xxxx-xxxx-xxxx-xxxx-xxxx",
        },
    }

    query := client.NewQuery(
        wavefront.NewQueryParams(`ts("cpu.load.1m.avg", dc=dc1)`),
    )

    if result, err := query.Execute(); err != nil {
        log.Fatal(err)
    }

    fmt.Println(result.TimeSeries[0].Label)
    fmt.Println(result.TimeSeries[0].DataPoints[0])
}
Writer

Writer has full support for metric tagging etc.

Again, see examples for a more detailed explanation.

package main

import (
    "log"
    "os"

    wavefront "github.com/spaceapegames/go-wavefront/writer"
)

func main() {
    source, _ := os.Hostname()

    wf, err := wavefront.NewWriter("wavefront-proxy.example.com", 2878, source, nil)
    if err != nil {
        log.Fatal(err)
    }
    defer wf.Close()

    wf.Write(wavefront.NewMetric("something.very.good.count", 33))
}

Contributing

Pull requests are welcomed.

If you'd like to contribute to this project, please raise an issue and indicate that you'd like to take on the work prior to submitting a pull request.

Documentation

Overview

Package wavefront provides a library for interacting with the Wavefront API, along with a writer for sending metrics to a Wavefront proxy.

Index

Constants

View Source
const (
	AlertTypeThreshold = "THRESHOLD"
	AlertTypeClassic   = "CLASSIC"
)
View Source
const (

	// some constants provided for time convenience
	LastHour    = 60 * 60
	Last3Hours  = LastHour * 3
	Last6Hours  = LastHour * 6
	Last24Hours = LastHour * 24
	LastDay     = Last24Hours
	LastWeek    = LastDay * 7
)
View Source
const (
	AGENT_MANAGEMENT           = "agent_management"
	ALERTS_MANAGEMENT          = "alerts_management"
	DASHBOARD_MANAGEMENT       = "dashboard_management"
	EMBEDDED_CHARTS_MANAGEMENT = "embedded_charts"
	EVENTS_MANAGEMENT          = "events_management"
	EXTERNAL_LINKS_MANAGEMENT  = "external_links_management"
	HOST_TAG_MANAGEMENT        = "host_tag_management"
	METRICS_MANAGEMENT         = "metrics_management"
	USER_MANAGEMENT            = "user_management"
	INTEGRATIONS_MANAGEMENT    = "application_management"
	DIRECT_INGESTION           = "ingestion"
	BATCH_QUERY_PRIORITY       = "batch_query_priority"
	DERIVED_METRICS_MANAGEMENT = "derived_metrics_management"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	// Name is the name given to an Alert
	Name string `json:"name"`

	// ID is the Wavefront-assigned ID of an existing Alert
	ID *string `json:"id,omitempty"`

	// AlertType should be either CLASSIC or THRESHOLD
	AlertType string `json:"alertType,omitempty"`

	// AdditionalInfo is any extra information about the Alert
	AdditionalInfo string `json:"additionalInformation"`

	// Target is a comma-separated list of targets for the Alert
	Target string `json:"target,omitempty"`

	// For THRESHOLD alerts. Targets is a map[string]string. This maps severity to lists of targets.
	// Valid keys are: severe, smoke, warn or info
	Targets map[string]string `json:"targets"`

	// Condition is the condition under which the Alert will fire
	Condition string `json:"condition"`

	// For THRESHOLD alerts. Conditions is a map[string]string. This maps severity to respective conditions.
	// Valid keys are: severe, smoke, warn or info
	Conditions map[string]string `json:"conditions"`

	// DisplayExpression is the ts query to generate a graph of this Alert, in the UI
	DisplayExpression string `json:"displayExpression,omitempty"`

	// Minutes is the number of minutes the Condition must be met, before the
	// Alert will fire
	Minutes int `json:"minutes"`

	// ResolveAfterMinutes is the number of minutes the Condition must be un-met
	// before the Alert is considered resolved
	ResolveAfterMinutes int `json:"resolveAfterMinutes,omitempty"`

	// Minutes to wait before re-sending notification of firing alert.
	NotificationResendFrequencyMinutes int `json:"notificationResendFrequencyMinutes"`

	// Severity is the severity of the Alert, and can be one of SEVERE,
	// SMOKE, WARN or INFO
	Severity string `json:"severity,omitempty"`

	// For THRESHOLD alerts. SeverityList is a list of strings. Different severities applicable to this alert.
	// Valid elements are: SEVERE, SMOKE, WARN or INFO
	SeverityList []string `json:"severityList"`

	// Status is the current status of the Alert
	Status []string `json:"status"`

	// Tags are the tags applied to the Alert
	Tags []string

	FailingHostLabelPairs       []SourceLabelPair `json:"failingHostLabelPairs,omitempty"`
	InMaintenanceHostLabelPairs []SourceLabelPair `json:"inMaintenanceHostLabelPairs,omitempty"`
}

Alert represents a single Wavefront Alert

func (*Alert) MarshalJSON

func (a *Alert) MarshalJSON() ([]byte, error)

func (*Alert) UnmarshalJSON

func (a *Alert) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom JSON unmarshaller for an Alert, used in order to populate the Tags field in a more intuitive fashion

type Alerts

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

Alerts is used to perform alert-related operations against the Wavefront API

func (Alerts) Create

func (a Alerts) Create(alert *Alert) error

Create is used to create an Alert in Wavefront. If successful, the ID field of the alert will be populated.

func (Alerts) Delete

func (a Alerts) Delete(alert *Alert) error

Delete is used to delete an existing Alert. The ID field of the alert must be populated

func (Alerts) Find

func (a Alerts) Find(filter []*SearchCondition) ([]*Alert, error)

Find returns all alerts filtered by the given search conditions. If filter is nil, all alerts are returned.

func (Alerts) Get

func (a Alerts) Get(alert *Alert) error

Get is used to retrieve an existing Alert by ID. The ID field must be provided

func (Alerts) Update

func (a Alerts) Update(alert *Alert) error

Update is used to update an existing Alert. The ID field of the alert must be populated

type Chart

type Chart struct {
	// Name is the name of a chart
	Name string `json:"name"`

	// Description is the description of the chart
	Description string `json:"description"`

	// Base (unknown usage, defaults to 1)
	Base int `json:"base"`

	// Include obsolete metrics older than 4 weeks ago into current time window
	IncludeObsoleteMetrics bool `json:"includeObsoleteMetrics"`

	// Interpolate points that existed in past/future into current time window
	InterpolatePoints bool `json:"interpolatePoints"`

	// Don't include default events on the chart
	NoDefaultEvents bool `json:"noDefaultEvents"`

	// Strategy to use when aggregating metric points (LAST, AVERAGE, COUNT, etc)
	Summarization string `json:"summarization"`

	// Sources is an Array of Source
	Sources []Source `json:"sources"`

	// Units are the units to use for the y axis
	Units string `json:"units,omitempty"`

	// ChartSettings are custom settings for the chart
	ChartSettings ChartSetting `json:"chartSettings"`
}

Chart represents a single Chart, on a single Row with in Section of a Wavefront Dashboard

type ChartSetting

type ChartSetting struct {
	AutoColumnTags                     bool      `json:"autoColumnTags,omitempty"`
	ColumnTags                         string    `json:"columnTags,omitempty"`
	CustomTags                         []string  `json:"customTags,omitempty"`
	ExpectedDataSpacing                int       `json:"expectedDataSpacing,omitempty"`
	FixedLegendDisplayStats            []string  `json:"fixedLegendDisplayStats,omitempty"`
	FixedLegendEnabled                 bool      `json:"fixedLegendEnabled,omitempty"`
	FixedLegendFilterField             string    `json:"fixedLegendFilterField,omitempty"`
	FixedLegendFilterLimit             int       `json:"fixedLegendFilterLimit,omitempty"`
	FixedLegendFilterSort              string    `json:"fixedLegendFilterSort,omitempty"`
	FixedLegendHideLabel               bool      `json:"fixedLegendHideLabel,omitempty"`
	FixedLegendPosition                string    `json:"fixedLegendPosition,omitempty"`
	FixedLegendUseRawStats             bool      `json:"fixedLegendUseRawStats,omitempty"`
	GroupBySource                      bool      `json:"groupBySource,omitempty"`
	InvertDynamicLegendHoverControl    bool      `json:"invertDynamicLegendHoverControl,omitempty"`
	LineType                           string    `json:"lineType,omitempty"`
	Max                                float32   `json:"max,omitempty"`
	Min                                float32   `json:"min,omitempty"`
	NumTags                            int       `json:"numTags,omitempty"`
	PlainMarkdownContent               string    `json:"plainMarkdownContent,omitempty"`
	ShowHosts                          bool      `json:"showHosts,omitempty"`
	ShowLabels                         bool      `json:"showLabels,omitempty"`
	ShowRawValues                      bool      `json:"showRawValues,omitempty"`
	SortValuesDescending               bool      `json:"sortValuesDescending,omitempty"`
	SparklineDecimalPrecision          int       `json:"sparklineDecimalPrecision,omitempty"`
	SparklineDisplayColor              string    `json:"sparklineDisplayColor,omitempty"`
	SparklineDisplayFontSize           string    `json:"sparklineDisplayFontSize,omitempty"`
	SparklineDisplayHorizontalPosition string    `json:"sparklineDisplayHorizontalPosition,omitempty"`
	SparklineDisplayPostfix            string    `json:"sparklineDisplayPostfix,omitempty"`
	SparklineDisplayPrefix             string    `json:"sparklineDisplayPrefix,omitempty"`
	SparklineDisplayValueType          string    `json:"sparklineDisplayValueType,omitempty"`
	SparklineDisplayVerticalPosition   string    `json:"sparklineDisplayVerticalPosition,omitempty"`
	SparklineFillColor                 string    `json:"sparklineFillColor,omitempty"`
	SparklineLineColor                 string    `json:"sparklineLineColor,omitempty"`
	SparklineSize                      string    `json:"sparklineSize,omitempty"`
	SparklineValueColorMapApplyTo      string    `json:"sparklineValueColorMapApplyTo,omitempty"`
	SparklineValueColorMapColors       []string  `json:"sparklineValueColorMapColors,omitempty"`
	SparklineValueColorMapValues       []int     `json:"sparklineValueColorMapValues,omitempty"`
	SparklineValueColorMapValuesV2     []float32 `json:"sparklineValueColorMapValuesV2,omitempty"`
	SparklineValueTextMapText          []string  `json:"sparklineValueTextMapText,omitempty"`
	SparklineValueTextMapThresholds    []float32 `json:"sparklineValueTextMapThresholds,omitempty"`
	StackType                          string    `json:"stackType,omitempty"`
	TagMode                            string    `json:"tagMode,omitempty"`
	TimeBasedColoring                  bool      `json:"timeBasedColoring,omitempty"`
	Type                               string    `json:"type,omitempty"`
	Windowing                          string    `json:"windowing,omitempty"`
	WindowSize                         int       `json:"windowSize,omitempty"`
	Xmax                               float32   `json:"xmax,omitempty"`
	Xmin                               float32   `json:"xmin,omitempty"`
	Y0ScaleSIBy1024                    bool      `json:"y0ScaleSIBy1024,omitempty"`
	Y0UnitAutoscaling                  bool      `json:"y0UnitAutoscaling,omitempty"`
	Y1Max                              float32   `json:"y1Max,omitempty"`
	Y1Min                              float32   `json:"y1Min,omitempty"`
	Y1ScaleSIBy1024                    bool      `json:"y1ScaleSIBy1024,omitempty"`
	Y1UnitAutoscaling                  bool      `json:"y1UnitAutoscaling,omitempty"`
	Y1Units                            string    `json:"y1Units,omitempty"`
	Ymax                               float32   `json:"ymax,omitempty"`
	Ymin                               float32   `json:"ymin,omitempty"`
}

ChartSetting represents various custom settings for a Chart

type Client

type Client struct {
	// Config is a Config object that will be used to construct requests
	Config *Config

	// BaseURL is the full URL of the Wavefront API, of the form
	// https://example.wavefront.com/api/v2
	BaseURL *url.URL
	// contains filtered or unexported fields
}

Client is used to generate API requests against the Wavefront API.

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient returns a new Wavefront client according to the given Config

func (*Client) Alerts

func (c *Client) Alerts() *Alerts

Alerts is used to return a client for alert-related operations

func (*Client) Dashboards

func (c *Client) Dashboards() *Dashboards

Dashboards is used to return a client for Dashboard-related operations

func (*Client) Debug

func (c *Client) Debug(enable bool)

Debug enables dumping http request objects to stdout

func (*Client) DerivedMetrics added in v1.6.3

func (c *Client) DerivedMetrics() *DerivedMetrics

func (Client) Do

func (c Client) Do(req *http.Request) (io.ReadCloser, error)

Do executes a request against the Wavefront API. The response body is returned if the request is successful, and should be closed by the requester.

func (*Client) Events

func (c *Client) Events() *Events

Events is used to return a client for event-related operations

func (c *Client) ExternalLinks() *ExternalLinks

func (*Client) NewQuery

func (c *Client) NewQuery(params *QueryParams) *Query

NewQuery returns a Query based on QueryParams

func (Client) NewRequest

func (c Client) NewRequest(method, path string, params *map[string]string, body []byte) (*http.Request, error)

NewRequest creates a request object to query the Wavefront API. Path is a relative URI that should be specified with no trailing slash, it will be resolved against the BaseURL of the client. Params should be passed as a map[string]string, these will be converted to query parameters.

func (*Client) NewSearch

func (c *Client) NewSearch(searchType string, params *SearchParams) *Search

NewSearch returns a Search based on SearchParams. searchType is the type of entity to be searched for (i.e. alert, event, dashboard, extlink, cloudintegration etc.)

func (*Client) Targets

func (c *Client) Targets() *Targets

Targets is used to return a client for target-related operations

func (*Client) UserGroups added in v1.6.3

func (c *Client) UserGroups() *UserGroups

UserGroups is used to return a client for user-group related operations

func (*Client) Users added in v1.6.3

func (c *Client) Users() *Users

Users is used to return a client for user-related operations

type Config

type Config struct {
	// Address is the address of the Wavefront API, of the form example.wavefront.com
	Address string

	// Token is an authentication token that will be passed with all requests
	Token string

	// SET HTTP Proxy configuration
	HttpProxy string

	// SkipTLSVerify disables SSL certificate checking and should be used for
	// testing only
	SkipTLSVerify bool
}

Config is used to hold configuration used when constructing a Client

type Dashboard

type Dashboard struct {
	// Name is the name given to an Dashboard
	Name string `json:"name"`

	// ID is the Wavefront-assigned ID of an existing Dashboard
	ID string `json:"id"`

	// Tags are the tags applied to the Dashboard
	Tags []string `json:"-"`

	// Description is a description given to the Dashboard
	Description string `json:"description"`

	// Url is the relative url to access the dashboard by on a cluster
	Url string `json:"url"`

	// Sections is an array of Section that split up the dashboard
	Sections []Section `json:"sections"`

	// Additional dashboard settings
	ChartTitleBgColor             string `json:"chartTitleBgColor,omitempty"`
	ChartTitleColor               string `json:"chartTitleColor,omitempty"`
	ChartTitleScalar              int    `json:"chartTitleScalar,omitempty"`
	DefaultEndTime                int    `json:"defaultEndTime,omitempty"`
	DefaultStartTime              int    `json:"defaultStartTime,omitempty"`
	DefaultTimeWindow             string `json:"defaultTimeWindow"`
	DisplayDescription            bool   `json:"displayDescription"`
	DisplayQueryParameters        bool   `json:"displayQueryParameters"`
	DisplaySectionTableOfContents bool   `json:"displaySectionTableOfContents"`
	EventFilterType               string `json:"eventFilterType"`
	EventQuery                    string `json:"eventQuery"`
	Favorite                      bool   `json:"favorite"`

	// Additional dashboard information
	Customer           string `json:"customer,omitempty"`
	Deleted            bool   `json:"deleted,omitempty"`
	Hidden             bool   `json:"hidden,omitempty"`
	NumCharts          int    `json:"numCharts,omitempty"`
	NumFavorites       int    `json:"numFavorites,omitempty"`
	CreatorId          string `json:"creatorId,omitempty"`
	UpdaterId          string `json:"updaterId,omitempty"`
	SystemOwned        bool   `json:"systemOwned,omitempty"`
	ViewsLastDay       int    `json:"viewsLastDay,omitempty"`
	ViewsLastMonth     int    `json:"viewsLastMonth,omitempty"`
	ViewsLastWeek      int    `json:"viewsLastWeek,omitempty"`
	CreatedEpochMillis int64  `json:"createdEpochMillis,omitempty"`
	UpdatedEpochMillis int64  `json:"updatedEpochMillis,omitempty"`

	// Parameters (reserved - usage unknown at this time)
	Parameters struct{} `json:"parameters"`

	// ParameterDetails sets variables that can be used within queries
	ParameterDetails map[string]ParameterDetail `json:"parameterDetails"`
}

Dashboard represents a single Wavefront Dashboard

func (*Dashboard) MarshalJSON

func (a *Dashboard) MarshalJSON() ([]byte, error)

func (*Dashboard) UnmarshalJSON

func (a *Dashboard) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom JSON unmarshaller for an Dashboard, used in order to populate the Tags field in a more intuitive fashion

type Dashboards

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

Dashboards is used to perform Dashboard-related operations against the Wavefront API

func (Dashboards) Create

func (a Dashboards) Create(dashboard *Dashboard) error

Create is used to create an Dashboard in Wavefront. If successful, the ID field of the Dashboard will be populated.

func (Dashboards) Delete

func (a Dashboards) Delete(dashboard *Dashboard) error

Delete is used to delete an existing Dashboard. The ID field of the Dashboard must be populated

func (Dashboards) Find

func (a Dashboards) Find(filter []*SearchCondition) ([]*Dashboard, error)

Find returns all Dashboards filtered by the given search conditions. If filter is nil, all Dashboards are returned.

func (Dashboards) Get

func (a Dashboards) Get(dashboard *Dashboard) error

Get is used to retrieve an existing Dashboard by ID. The ID field must be provided

func (Dashboards) Update

func (a Dashboards) Update(dashboard *Dashboard) error

Update is used to update an existing Dashboard. The ID field of the Dashboard must be populated

type DataPoint

type DataPoint []float64

DataPoint represents a single timestamp/value data point as returned by Wavefront

type DerivedMetric added in v1.6.3

type DerivedMetric struct {
	ID                       *string  `json:"id,omitempty"`
	Name                     string   `json:"name,omitempty"`
	Query                    string   `json:"query,omitempty"`
	Minutes                  int      `json:"minutes,omitempty"`
	Tags                     WFTags   `json:"tags,omitempty"`
	Status                   []string `json:"status,omitempty"`
	InTrash                  bool     `json:"inTrash,omitempty"`
	QueryFailing             bool     `json:"queryFailing,omitempty"`
	LastFailedTime           int      `json:"lastFailedTime,omitempty"`
	LastErrorMessage         string   `json:"lastErrorMessage,omitempty"`
	AdditionalInformation    string   `json:"additionalInformation,omitempty"`
	HostsUsed                []string `json:"hostsUsed,omitempty"`
	UpdateUserId             string   `json:"updateUserId,omitempty"`
	CreateUserId             string   `json:"createUserId,omitempty"`
	LastProcessedMillis      int      `json:"lastProcessedMillis,omitempty"`
	ProcessRateMinutes       int      `json:"processRateMinutes,omitempty"`
	PointsScannedAtLastQuery int      `json:"pointsScannedAtLastQuery,omitempty"`
	IncludeObsoleteMetrics   bool     `json:"includeObsoleteMetrics,omitempty"`
	LastQueryTime            int      `json:"lastQueryTime,omitempty"`
	MetricsUsed              []string `json:"metricsUsed,omitempty"`
	QueryQBEnabled           bool     `json:"queryQBEnabled,omitempty"`
	UpdatedEpochMillis       int      `json:"updatedEpochMillis,omitempty"`
	CreatedEpochMillis       int      `json:"createdEpochMillis,omitempty"`
	Deleted                  bool     `json:"deleted,omitempty"`
}

type DerivedMetrics added in v1.6.3

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

func (DerivedMetrics) Create added in v1.6.3

func (dm DerivedMetrics) Create(metric *DerivedMetric) error

Create a DerivedMetric, name, query, and minutes are required

func (DerivedMetrics) Delete added in v1.6.3

func (dm DerivedMetrics) Delete(metric *DerivedMetric) error

Delete a DerivedMetric all fields are optional except for ID

func (DerivedMetrics) Find added in v1.6.3

func (dm DerivedMetrics) Find(filter []*SearchCondition) ([]*DerivedMetric, error)

Find returns all DerivedMetrics filtered by the given search conditions. If filter is nil, all DerivedMetrics are returned.

func (DerivedMetrics) Get added in v1.6.3

func (dm DerivedMetrics) Get(metric *DerivedMetric) error

Get is used to retrieve an existing DerivedMetric by ID. The ID field must be specified

func (DerivedMetrics) Update added in v1.6.3

func (dm DerivedMetrics) Update(metric *DerivedMetric) error

Update a DerivedMetric all fields are optional except for ID

type Event

type Event struct {
	// Name is the name given to the Event
	Name string `json:"name"`

	// ID is the Wavefront-assigned ID of an existing Event
	ID *string `json:"id,omitempty"`

	// StartTime is the start time, in epoch milliseconds, of the Event.
	// If zero, it will be set to current time
	StartTime int64 `json:"startTime"`

	// EndTime is the end time, in epoch milliseconds, of the Event
	EndTime int64 `json:"endTime,omitempty"`

	// Tags are the tags associated with the Event
	Tags []string `json:"tags"`

	// Severity is the severity category of the Event, can be INFO, WARN,
	// SEVERE or UNCLASSIFIED
	Severity string

	// Type is the type of the Event, e.g. "Alert", "Deploy" etc.
	Type string

	// Details is a description of the Event
	Details string

	// Instantaneous, if true, creates a point-in-time Event (i.e. with no duration)
	Instantaneous bool `json:"isEphemeral"`
}

Event represents a single Wavefront Event

func (*Event) MarshalJSON

func (e *Event) MarshalJSON() ([]byte, error)

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom JSON unmarshaller for an Event, used to explode the annotations.

type Events

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

Events is used to perform event-related operations against the Wavefront API

func (Events) Close

func (e Events) Close(event *Event) error

Close is used to close an existing Event

func (Events) Create

func (a Events) Create(event *Event) error

Create is used to create an Event in Wavefront. If successful, the ID field of the event will be populated.

func (Events) Delete

func (e Events) Delete(event *Event) error

Delete is used to delete an existing Event. The ID field of the Event must be populated

func (Events) Find

func (e Events) Find(filter []*SearchCondition, timeRange *TimeRange) ([]*Event, error)

Find returns all events filtered by the given search conditions. If filter is nil then all Events are returned. The result set is limited to the first 100 entries. If more results are required the Search type can be used directly.

func (Events) FindByID

func (e Events) FindByID(id string) (*Event, error)

FindByID returns the Event with the Wavefront-assigned ID. If not found an error is returned

func (Events) Update

func (e Events) Update(event *Event) error

Update is used to update an existing Event. The ID field of the Event must be populated

type ExternalLink struct {
	ID                    *string           `json:"id"`
	Name                  string            `json:"name"`
	Description           string            `json:"description"`
	CreatorId             string            `json:"creatorId"`
	UpdaterId             string            `json:"updaterId"`
	UpdatedEpochMillis    int               `json:"updatedEpochMillis"`
	CreatedEpochMillis    int               `json:"createdEpochMillis"`
	Template              string            `json:"template"`
	MetricFilterRegex     string            `json:"metricFilterRegex,omitempty"`
	SourceFilterRegex     string            `json:"SourceFilterRegex,omitempty"`
	PointTagFilterRegexes map[string]string `json:"PointTagFilterRegexes,omitempty"`
}
type ExternalLinks struct {
	// contains filtered or unexported fields
}

func (ExternalLinks) Create added in v1.6.3

func (e ExternalLinks) Create(link *ExternalLink) error

func (ExternalLinks) Delete added in v1.6.3

func (e ExternalLinks) Delete(link *ExternalLink) error

func (ExternalLinks) Find added in v1.6.3

func (e ExternalLinks) Find(conditions []*SearchCondition) ([]*ExternalLink, error)

func (ExternalLinks) Get added in v1.6.3

func (e ExternalLinks) Get(link *ExternalLink) error

func (ExternalLinks) Update added in v1.6.3

func (e ExternalLinks) Update(link *ExternalLink) error

type NewUserRequest added in v1.6.3

type NewUserRequest struct {
	// The only time it is referred to as emailAddress is when it's a new user
	EmailAddress string `json:"emailAddress"`

	// The permissions granted to this user
	Permissions []string `json:"groups,omitempty"`

	// Groups this user belongs to
	// This is wrapped with a Wrapper to manage the serialization between what we send to the API
	// And what the API sends back (which is to say, we send just IDs but we always receive a complete object)
	Groups UserGroupsWrapper `json:"userGroups,omitempty"`
}

type ParameterDetail

type ParameterDetail struct {
	// Label represents the name of the variable
	Label string `json:"label"`

	// DefaultValue maps to keys in the map ValuesToReadableStrings
	DefaultValue string `json:"defaultValue"`

	// HideFromView Whether to hide from the view of the user viewing the Dashboard
	HideFromView bool `json:"hideFromView"`

	// ParameterType (SIMPLE, LIST, DYNAMIC)
	ParameterType string `json:"parameterType"`

	// ValuesToReadableStrings
	ValuesToReadableStrings map[string]string `json:"valuesToReadableStrings"`

	// QueryValue
	QueryValue string `json:"queryValue,omitempty"`

	// TagKey Only required for a DynamicFieldType of TAG_KEY
	TagKey string `json:"tagKey,omitempty"`

	// DynamicFieldType (TAG_KEY, MATCHING_SOURCE_TAG, SOURCE_TAG, SOURCE, METRIC_NAME) Only required for a Parameter type of Dynamic.
	DynamicFieldType string `json:"dynamicFieldType,omitempty"`
}

ParameterDetail represents a parameter to dashboard that can be consumed in queries

type Query

type Query struct {

	// Params is the set of parameters that will be used when executing the Query
	Params *QueryParams

	// Response will be the response of the last executed Query
	Response *QueryResponse
	// contains filtered or unexported fields
}

Query represents a query to be made against the Charts API

func (*Query) Execute

func (q *Query) Execute() (*QueryResponse, error)

Execute is used to execute a query against the Wavefront Chart API

func (*Query) SetEndTime

func (q *Query) SetEndTime(endTime time.Time)

SetEndTime sets the time at which the query should end

func (*Query) SetStartTime

func (q *Query) SetStartTime(seconds int64) error

SetStartTime sets the time from which to query for points. 'seconds' is the number of seconds before the end-time that the query will be inclusive of. EndTime must be set before calling this function. Some constants are provided for convenience: LastHour, Last3Hours, LastDay etc.

type QueryParams

type QueryParams struct {
	// Name is an optional name to identify the query
	Name string `query:"n"`

	// QueryString is the actual timeseries query to be executed
	QueryString string `query:"q"`

	// StartTime is the start time for the query in epoch milliseconds
	StartTime string `query:"s"`

	// EndTime is the end time for the query in epoch milliseconds
	EndTime string `query:"e"`

	// Granularity is the granularity of the points returned, and can be one of
	// d,h,m or s
	Granularity string `query:"g"`

	// MaxPoints is the maximum number of points to return
	MaxPoints string `query:"p"`

	// SeriesOutsideTimeWindow is a boolean to indicate whether series with only
	// points that are outside  of the query window will be returned
	SeriesOutsideTimeWindow bool `query:"i"`

	// AutoEvents is a boolean to indicate whether to return Events for sources
	// included in the query
	AutoEvents bool `query:"autoEvents"`

	// SummarizationStrategy is the strategy to be used when grouping points together.
	// Valid values are MEAN, MEDIAN, MIN, MAX, SUN, COUNT, LAST, FIRST
	SummarizationStrategy string `query:"summarization"`

	// ListMode is a boolean to indicate whether to retrieve events more optimally
	// displayed for a list.
	ListMode bool `query:"listmode"`

	// StrictMode is a boolean which, if true, will not return points outside of the
	// query window. Defaults to false if ommitted.
	StrictMode bool `query:"strict"`

	// IncludeObsoleteMetrics is a boolean to indicate whether to return points from
	// sources which have stopped reporting. Defaults to false if ommitted.
	IncludeObsoleteMetrics bool `query:"includeObsoleteMetrics"`
}

QueryParams represents parameters that will be passed when making a Query

func NewQueryParams

func NewQueryParams(query string) *QueryParams

NewQueryParams takes a query string and returns a set of QueryParams with a query window of one hour since now and a set of sensible default vakues

func NewQueryParamsNoStrict

func NewQueryParamsNoStrict(query string) *QueryParams

type QueryResponse

type QueryResponse struct {
	RawResponse *bytes.Reader
	TimeSeries  []TimeSeries   `json:"timeseries"`
	Query       string         `json:"query"`
	Stats       map[string]int `json:"stats"`
	Name        string         `json:"name"`
	Granularity int            `json:"granularity"`
	Hosts       []string       `json:"hostsUsed"`
	Warnings    string         `json:"warnings"`
}

QueryResponse is used to represent a Wavefront query response

func (QueryResponse) String

func (qr QueryResponse) String() string

String outputs the time-series of a QueryResponse object in a human-readable format

func (*QueryResponse) UnmarshalJSON

func (qr *QueryResponse) UnmarshalJSON(data []byte) error

type Row

type Row struct {
	// Name represents the display name of the Row
	Name string `json:"name"`

	// HeightFactor sets the height of the Row
	HeightFactor int `json:"heightFactor"`

	// Charts is an array of Chart that this row contains
	Charts []Chart `json:"charts"`
}

Row represents a single Row withing a Section of a Wavefront Dashboard

type Search struct {

	// Type is the type of entity to be searched for (i.e. alert, event, dashboard,
	// extlink, cloudintegration etc.)
	Type string

	// Params are the Search parameters to be applied
	Params *SearchParams

	// Deleted is whether to search against the /{entity}/deleted endpoint (for
	// deleted items) instead of the normal one. Defaults to false.
	Deleted bool
	// contains filtered or unexported fields
}

Search represents a search to be made against the Search API

func (*Search) Execute

func (s *Search) Execute() (*SearchResponse, error)

Execute is used to carry out a search

type SearchCondition

type SearchCondition struct {
	// Key is the type of parameter to be matched (e.g. tags, status, id)
	Key string `json:"key"`

	// Value is the value of Key to be searched for (e.g. the tag name, or snoozed)
	Value string `json:"value"`

	// MatchingMethod must be one of CONTAINS, STARTSWITH, EXACT, TAGPATH
	MatchingMethod string `json:"matchingMethod"`
}

SearchCondition represents a single search condition. Multiple conditions can be applied to one search, they will act as a logical AND.

type SearchParams

type SearchParams struct {
	// Conditions are the search conditions to be matched.
	// If multiple are given they will act like a logical AND
	Conditions []*SearchCondition `json:"query"`

	// Limit is the max number of results to be returned. Defaults to 100.
	Limit int `json:"limit"`

	// Offset is the offset from the first result to be returned.
	// For instance, an Offset of 100 will yield results 101 - 200
	// (assuming a Limit of 100). Defaults to 0.
	Offset int `json:"offset"`

	// TimeRange is the range between which results will be searched.
	// This is only valid for certain search types (e.g. Events)
	TimeRange *TimeRange `json:"timeRange,omitempty"`
}

SearchParams represents paramaters used to effect a Search. If multiple search terms are given they will act like a logical AND. If Conditions is nil, all items of the given Type will be returned

type SearchResponse

type SearchResponse struct {
	// RawResponse is the raw JSON response returned by Wavefront from a Search
	// operation
	RawResponse *bytes.Reader

	// Response is the response body of a Search operation
	Response struct {
		// Items will be the Wavefront entities returned by a successful search
		// operation (i.e. the Alerts, or Dashboards etc.)
		Items json.RawMessage

		// MoreResults indicates whether there are further items to be returned in a
		// paginated response.
		MoreItems bool `json:"moreItems"`
	} `json:"response"`

	// NextOffset is the offset that should be used to retrieve the next page of
	// results in a paginated response. If there are no more results, it will be zero.
	NextOffset int
}

SearchResponse represents the result of a successful search operation

type Section

type Section struct {
	// Name is the name given to this section
	Name string `json:"name"`

	// Rows is an array of Rows in this section
	Rows []Row `json:"rows"`
}

Section Represents a Single section within a Dashboard

type Source

type Source struct {
	// Name is the name given to the source
	Name string `json:"name"`

	// Query is a wavefront Query
	Query string `json:"query"`

	// Disabled indicated whether the source is disabled from being rendered on the chart
	Disabled bool `json:"disabled,omitempty"`

	// ScatterPlotSource
	ScatterPlotSource string `json:"scatterPlotSource"`

	// QuerybuilderEnabled
	QuerybuilderEnabled bool `json:"querybuilderEnabled"`

	// SourceDescription
	SourceDescription string `json:"sourceDescription"`

	// SourceColor
	SourceColor string `json:"sourceColor,omitempty"`
}

Source represents a single Source for a Chart

type SourceLabelPair

type SourceLabelPair struct {
	Host   string `json:"host"`
	Firing int    `json:"firing"`
}

type Target

type Target struct {
	// Description is a description of the target Target
	Description string `json:"description"`

	// ID is the Wavefront-assigned ID of an existing Target
	ID *string `json:"id"`

	// Template is the Mustache template for the notification body
	Template string `json:"template"`

	// Title is the title(name) of the Target
	Title string `json:"title"`

	// Method must be EMAIL, WEBHOOK or PAGERDUTY
	Method string `json:"method"`

	// Recipient is a comma-separated list of email addresses, webhook URL,
	// or 32-digit PagerDuty key  to which notifications will be sent for this Target
	Recipient string `json:"recipient"`

	// EmailSubject is the subject of the email which will be sent for this Target
	// (EMAIL targets only)
	EmailSubject string `json:"emailSubject"`

	// IsHTMLContent is a boolean value for wavefront to add HTML Boilerplate
	// while using HTML Templates as email.
	// (EMAIL targets only)
	IsHtmlContent bool `json:"isHtmlContent"`

	// ContentType is the content type for webhook posts (e.g. application/json)
	// (WEBHOOK targets only)
	ContentType string `json:"contentType"`

	// CustomHeaders are any custom HTTP headers that should be sent with webhook,
	// in key:value syntax (WEBHOOK targets only)
	CustomHeaders map[string]string `json:"customHttpHeaders"`

	// Triggers is a list of Alert states that will trigger this notification
	// and can include ALERT_OPENED, ALERT_RESOLVED, ALERT_STATUS_RESOLVED,
	// ALERT_AFFECTED_BY_MAINTENANCE_WINDOW, ALERT_SNOOZED, ALERT_NO_DATA,
	// ALERT_NO_DATA_RESOLVED
	Triggers []string `json:"triggers"`
}

Target represents a Wavefront Alert Target, for routing notifications associated with Alerts. Targets can be either email or webhook targets, and the Method must be set appropriately.

type Targets

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

Targets is used to perform target-related operations against the Wavefront API

func (Targets) Create

func (t Targets) Create(target *Target) error

Create is used to create a Target in Wavefront. If successful, the ID field of the target will be populated.

func (Targets) Delete

func (t Targets) Delete(target *Target) error

Delete is used to delete an existing Target. The ID field of the target must be populated

func (Targets) Find

func (t Targets) Find(filter []*SearchCondition) ([]*Target, error)

Find returns all targets filtered by the given search conditions. If filter is nil, all targets are returned.

func (Targets) Get

func (t Targets) Get(target *Target) error

Get is used to retrieve an existing Target by ID. The ID field must be provided

func (Targets) Update

func (t Targets) Update(target *Target) error

Update is used to update an existing Target. The ID field of the target must be populated

type TimeRange

type TimeRange struct {
	// StartTime is the time, in epoch milliseconds from which search results
	// will be returned.
	StartTime int64 `json:"earliestStartTimeEpochMillis"`

	// EndTime is the time, in epoch milliseconds up to which search results
	// will be returned.
	EndTime int64 `json:"latestStartTimeEpochMillis"`
}

TimeRange represents a range of times to search between. It is only valid for certain search types (e.g. Events)

func NewTimeRange

func NewTimeRange(endTime, period int64) (*TimeRange, error)

NewTimeRange returns a *TimeRange encompassing the period seconds before the given endTime. If endTime is 0, the current time will be used.

type TimeSeries

type TimeSeries struct {
	DataPoints []DataPoint       `json:"data"`
	Label      string            `json:"label"`
	Host       string            `json:"host"`
	Tags       map[string]string `json:"tags"`
}

TimeSeries represents a single TimeSeries as returned by Wavefront

type User added in v1.6.3

type User struct {
	// The email identifier for a user
	ID *string `json:"identifier"`

	// The customer the user is a member of
	Customer string `json:"customer,omitempty"`

	// Last successful login in epoch millis
	LastSuccessfulLogin uint `json:"lastSuccessfulLogin,omitempty"`

	// The permissions granted to this user
	Permissions []string `json:"groups,omitempty"`

	// Groups this user belongs to
	// This is wrapped with a Wrapper to manage the serialization between what we send to the API
	// And what the API sends back (which is to say, we send just IDs but we always receive a complete object)
	Groups UserGroupsWrapper `json:"userGroups,omitempty"`

	// Used during an PUT call to modify a users password
	Credential string `json:"credential,omitempty"`
}

User represents a Wavefront User

type UserGroup added in v1.6.3

type UserGroup struct {
	// Unique ID for the user group
	ID *string `json:"id,omitempty"`

	// Name of the user group
	Name string `json:"name,omitempty"`

	// Permission(s) assigned to the user group
	Permissions []string `json:"permissions,omitempty"`

	// Customer
	Customer string `json:"customer,omitempty"`

	// Users that are members of the group
	Users []string `json:"users,omitempty"`

	// Total number of users that are members of the user group
	UserCount int `json:"userCount,omitempty"`

	// Which properties of the user group are editable
	Properties UserGroupPropertiesDTO `json:"properties,omitempty"`

	// Description of the Group purpose
	Description string `json:"description,omitempty"`

	// When the group was created
	CreatedEpochMillis int `json:"createdEpochMillis,omitempty"`
}

type UserGroupPropertiesDTO added in v1.6.3

type UserGroupPropertiesDTO struct {
	NameEditable bool `json:"nameEditable"`

	PermissionsEditable bool `json:"permissionsEditable"`

	UsersEditable bool `json:"usersEditable"`
}

type UserGroups added in v1.6.3

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

func (UserGroups) AddUsers added in v1.6.3

func (g UserGroups) AddUsers(id *string, users *[]string) error

Adds the specified users to the group

func (UserGroups) Create added in v1.6.3

func (g UserGroups) Create(userGroup *UserGroup) error

func (UserGroups) Delete added in v1.6.3

func (g UserGroups) Delete(userGroup *UserGroup) error

func (UserGroups) Find added in v1.6.3

func (g UserGroups) Find(filter []*SearchCondition) ([]*UserGroup, error)

Find returns all UsersGroups filtered by the given search conditions. If filter is nil, all UserGroups are returned.

func (UserGroups) Get added in v1.6.3

func (g UserGroups) Get(userGroup *UserGroup) error

Gets a specific UserGroup by ID The ID field must be specified

func (UserGroups) RemoveUsers added in v1.6.3

func (g UserGroups) RemoveUsers(id *string, users *[]string) error

Removes the specified users from the group

func (UserGroups) Update added in v1.6.3

func (g UserGroups) Update(userGroup *UserGroup) error

Update does not support updating the users on the group To update the users in a group use AddUsers and RemoveUsers The ID field must be specified

type UserGroupsWrapper added in v1.6.3

type UserGroupsWrapper struct {
	UserGroups []UserGroup
}

func (*UserGroupsWrapper) MarshalJSON added in v1.6.3

func (w *UserGroupsWrapper) MarshalJSON() ([]byte, error)

During a POST/PUT/DELETE on a User only the UserGroup.ID is transmitted

func (*UserGroupsWrapper) UnmarshalJSON added in v1.6.3

func (w *UserGroupsWrapper) UnmarshalJSON(data []byte) error

During a GET operation or returned AFTER a POST/PUT/DELETE we receive a complete UserGroup struct

type Users added in v1.6.3

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

Users is used to perform user-related operations against the Wavefront API

func (Users) Create added in v1.6.3

func (u Users) Create(newUser *NewUserRequest, user *User, sendEmail bool) error

Does not support specifying a credential The EmailAddress field must be specified

func (Users) Delete added in v1.6.3

func (u Users) Delete(user *User) error

Deletes the specified user The ID field must be specified

func (Users) Find added in v1.6.3

func (u Users) Find(filter []*SearchCondition) ([]*User, error)

Find returns all Users filtered by the given search conditions. If filter is nil, all Users are returned. UserGroups returned on the User from this call will be ID only

func (Users) Get added in v1.6.3

func (u Users) Get(user *User) error

Get is used to retrieve an existing User by ID. The identifier field must be specified

func (Users) Update added in v1.6.3

func (u Users) Update(user *User) error

Supports specifying the credential The identifier field must be specified

type WFTags added in v1.6.3

type WFTags struct {
	CustomerTags []string `json:"customerTags"`
}

type Wavefronter

type Wavefronter interface {
	NewRequest(method, path string, params *map[string]string, body []byte) (*http.Request, error)
	Do(req *http.Request) (io.ReadCloser, error)
}

Wavefronter is an interface that a Wavefront client must satisfy (generally this is abstracted for easier testing)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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