Documentation
¶
Overview ¶
Package datadog provides a client for the Datadog API.
Index ¶
- type Client
- func (c *Client) GetSLOHistory(ctx context.Context, sloID string, from, to time.Time) (*SLOHistorySLIData, error)
- func (c *Client) ListMonitorEvents(ctx context.Context, tagsQuery string, from, to time.Time) ([]MonitorEvent, error)
- func (c *Client) ListMonitors(ctx context.Context, teamTag string) ([]Monitor, error)
- func (c *Client) ListSLOEvents(ctx context.Context, from, to time.Time) ([]SLOEvent, error)
- func (c *Client) ListSLOs(ctx context.Context, tagsQuery string) ([]SLOData, error)
- func (c *Client) TestConnection(ctx context.Context) error
- type Credentials
- type Monitor
- type MonitorEvent
- type SLOData
- type SLOErrorBudget
- type SLOEvent
- type SLOHistorySLIData
- type SLOThreshold
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 ¶
ListMonitors lists monitors filtered by a team tag, e.g. "team:my-team". Pass an empty string to list all monitors.
func (*Client) ListSLOEvents ¶
ListSLOEvents fetches SLO violation events from the Events v2 API.
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.