datadog

package
v1.0.7097-a3fa483 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package datadog contains a basic Datadog API client for retrieving metrics back from Datadog.

Index

Constants

This section is empty.

Variables

View Source
var ErrHTTP = errors.New("datadog HTTP error")
View Source
var ErrInvalidQuery = errors.New("invalid query")

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey     string
	AppKey     string
	BaseURL    *url.URL
	HTTPClient *http.Client
}

func (*Client) Query

func (c *Client) Query(ctx context.Context, q QueryParams) (response QueryResponse, err error)

func (*Client) Validate

func (c *Client) Validate(ctx context.Context) (valid bool, err error)

type DataPoint

type DataPoint struct {
	Time  UnixTime
	Value float64
}

DataPoint is a tuple of UNIX timestamp, value. It has custom JSON serialisation to allow variadic decoding of the JSON array.

func (DataPoint) String

func (d DataPoint) String() string

func (*DataPoint) UnmarshalJSON

func (d *DataPoint) UnmarshalJSON(b []byte) (err error)

type QueryParams

type QueryParams struct {
	From, To time.Time
	Query    string
}

type QueryResponse

type QueryResponse struct {
	Series []Series
	Meta   ResponseMetadata
}

type RateLimit

type RateLimit struct {
	Limit     int64         // X-RateLimit-Limit number of requests allowed in a time period
	Period    time.Duration // X-RateLimit-Period length of time in seconds for resets (calendar aligned)
	Remaining int64         // X-RateLimit-Remaining number of allowed requests left in current time period
	Reset     time.Duration // X-RateLimit-Reset time in seconds until next reset
}

func (*RateLimit) LoadFromHeader

func (r *RateLimit) LoadFromHeader(h *http.Header) (err error)

type ResponseMetadata

type ResponseMetadata struct {
	RateLimit RateLimit
}

type Series

type Series struct {
	Metric      string      `json:"metric"`
	DisplayName string      `json:"display_name"`
	Points      []DataPoint `json:"pointlist"`
	Start       UnixTime    `json:"start"`
	End         UnixTime    `json:"end"`
	Interval    int         `json:"interval"`
	Aggr        string      `json:"aggr"`
	Length      int         `json:"length"`
	Scope       string      `json:"scope"`
	Expression  string      `json:"expression"`
}

type UnixTime

type UnixTime struct {
	time.Time
}

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON converts from milliseconds since the epoch

Jump to

Keyboard shortcuts

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