Help us shape the future of Go! Take the 2026 Go Developer Survey

datadog

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package datadog provides a client for the Datadog API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the main Datadog API client.

func NewClient

func NewClient(creds Credentials) *Client

NewClient creates a new Datadog API client.

func NewClientWithHTTPDoer

func NewClientWithHTTPDoer(doer httputil.HTTPDoer, creds Credentials) *Client

NewClientWithHTTPDoer creates a Datadog client with an injectable HTTP doer (for testing).

func (*Client) GetSLOHistory

func (c *Client) GetSLOHistory(ctx context.Context, sloID string, from, to time.Time) (*SLOHistorySLIData, error)

GetSLOHistory retrieves historical SLI data for a specific SLO.

func (*Client) ListMonitorEvents

func (c *Client) ListMonitorEvents(ctx context.Context, tagsQuery string, from, to time.Time) ([]MonitorEvent, error)

ListMonitorEvents fetches monitor alert events from the Events v2 API. It returns events where a monitor transitioned to Alert (or Warn/No Data). Pass a non-empty tagsQuery to filter by team tag, e.g. "team:my-team".

func (*Client) ListMonitors

func (c *Client) ListMonitors(ctx context.Context, teamTag string) ([]Monitor, error)

ListMonitors lists monitors filtered by a team tag, e.g. "team:my-team". Pass an empty string to list all monitors.

func (*Client) ListSLOEvents

func (c *Client) ListSLOEvents(ctx context.Context, from, to time.Time) ([]SLOEvent, error)

ListSLOEvents fetches SLO violation events from the Events v2 API.

func (*Client) ListSLOs

func (c *Client) ListSLOs(ctx context.Context, tagsQuery string) ([]SLOData, error)

ListSLOs lists SLOs filtered by a tags query string.

func (*Client) TestConnection

func (c *Client) TestConnection(ctx context.Context) error

TestConnection verifies the Datadog credentials work.

type Credentials

type Credentials struct {
	APIKey          string // Datadog API key
	AppKey          string // Datadog Application key
	Site            string // Datadog site (default "datadoghq.com")
	BaseURLOverride string // If set, use instead of https://api.<site> (for testing)
}

Credentials holds Datadog authentication details.

func (*Credentials) BaseURL

func (c *Credentials) BaseURL() string

BaseURL returns the standard Datadog API base URL.

type Monitor

type Monitor struct {
	ID           int64    `json:"id"`
	Name         string   `json:"name"`
	Type         string   `json:"type"`
	Tags         []string `json:"tags"`
	OverallState string   `json:"overall_state"` // "Alert", "Warn", "No Data", "OK", "Ignored", "Skipped", "Unknown"
}

Monitor represents a Datadog monitor definition.

type MonitorEvent

type MonitorEvent struct {
	ID          string
	MonitorID   int64 // extracted from nested attributes or tags
	MonitorName string
	Status      string // "Alert", "Warn", "No Data", "Recovered", etc.
	Priority    string
	Timestamp   time.Time
	Tags        []string
}

MonitorEvent represents a monitor alert event from the Events v2 API.

type SLOData

type SLOData struct {
	ID         string         `json:"id"`
	Name       string         `json:"name"`
	Type       string         `json:"type"`
	Tags       []string       `json:"tags"`
	Thresholds []SLOThreshold `json:"thresholds"`
}

SLOData represents a Datadog SLO definition.

type SLOErrorBudget

type SLOErrorBudget = sloErrorBudget

type SLOEvent

type SLOEvent struct {
	ID        string
	SLOID     string // SLO ID, extracted from nested attributes or tags
	Title     string
	Timestamp time.Time
	Tags      []string
}

SLOEvent represents an SLO violation event from the Events v2 API.

type SLOHistorySLIData

type SLOHistorySLIData struct {
	SLIValue             float64        `json:"sli_value"`
	ErrorBudgetRemaining sloErrorBudget `json:"error_budget_remaining"`
}

SLOHistorySLIData holds history data for a single SLO.

type SLOThreshold

type SLOThreshold struct {
	Timeframe string  `json:"timeframe"`
	Target    float64 `json:"target"`
	Warning   float64 `json:"warning"`
}

SLOThreshold represents a target threshold for an SLO.

Jump to

Keyboard shortcuts

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