Categorygithub.com/zorkian/go-datadog-api
modulepackage
2.30.0+incompatible
Repository: https://github.com/zorkian/go-datadog-api.git
Documentation: pkg.go.dev

# README

GoDoc License Build
status Go Report Card

Datadog API in Go

This is the v2.0 version of the API, and has breaking changes. Use the v1.0 branch if you need legacy code to be supported.

A Go wrapper for the Datadog API. Use this library if you need to interact with the Datadog system. You can post metrics with it if you want, but this library is probably mostly used for automating dashboards/alerting and retrieving data (events, etc).

The source API documentation is here: http://docs.datadoghq.com/api/

Installation

To use the default branch, include it in your code like:

    import "github.com/zorkian/go-datadog-api"

Or, if you need to control which version to use, import using gopkg.in. Like so:

    import "gopkg.in/zorkian/go-datadog-api.v2"

Using go get:

go get gopkg.in/zorkian/go-datadog-api.v2

USAGE

This library uses pointers to be able to verify if values are set or not (vs the default value for the type). Like protobuf there are helpers to enhance the API. You can decide to not use them, but you'll have to be careful handling nil pointers.

Using the client:

    client := datadog.NewClient("api key", "application key")

    dash, err := client.GetDashboard(*datadog.Int(10880))
    if err != nil {
        log.Fatalf("fatal: %s\n", err)
    }
    
    log.Printf("dashboard %d: %s\n", dash.GetId(), dash.GetTitle())

An example using datadog.String(), which allocates a pointer for you:

	m := datadog.Monitor{
		Name: datadog.String("Monitor other things"),
		Creator: &datadog.Creator{
			Name: datadog.String("Joe Creator"),
		},
	}

An example using the SetXx, HasXx, GetXx and GetXxOk accessors:

	m := datadog.Monitor{}
	m.SetName("Monitor all the things")
	m.SetMessage("Electromagnetic energy loss")

	// Use HasMessage(), to verify we have interest in the message.
	// Using GetMessage() always safe as it returns the actual or, if never set, default value for that type.
	if m.HasMessage() {
		fmt.Printf("Found message %s\n", m.GetMessage())
	}

	// Alternatively, use GetMessageOk(), it returns a tuple with the (default) value and a boolean expressing
	// if it was set at all:
	if v, ok := m.GetMessageOk(); ok {
		fmt.Printf("Found message %s\n", v)
	}

Check out the Godoc link for the available API methods and, if you can't find the one you need, let us know (or patches welcome)!

DOCUMENTATION

Please see: https://godoc.org/gopkg.in/zorkian/go-datadog-api.v2

BUGS/PROBLEMS/CONTRIBUTING

There are certainly some, but presently no known major bugs. If you do find something that doesn't work as expected, please file an issue on Github:

https://github.com/zorkian/go-datadog-api/issues

Thanks in advance! And, as always, patches welcome!

DEVELOPMENT

Running tests

  • Run tests tests with make test.
  • Integration tests can be run with make testacc. Run specific integration tests with make testacc TESTARGS='-run=TestCreateAndDeleteMonitor'

The acceptance tests require DATADOG_API_KEY and DATADOG_APP_KEY to be available in your environment variables.

Warning: the integrations tests will create and remove real resources in your Datadog account.

Regenerating code

Accessors HasXx, GetXx, GetOkXx and SetXx are generated for each struct field type type that contains pointers. When structs are updated a contributor has to regenerate these using go generate and commit these changes. Optionally there is a make target for the generation:

make generate

COPYRIGHT AND LICENSE

Please see the LICENSE file for the included license information.

Copyright 2013-2019 by authors and contributors.

# Packages

No description provided by the author

# Functions

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.
Float64AlmostEqual will return true if two floats are within a certain tolerance of each other.
GetBool is a helper routine that returns a boolean representing if a value was set, and if so, dereferences the pointer to it.
GetFloat64Ok is a helper routine that returns a boolean representing if a value was set, and if so, dereferences the pointer to it.
No description provided by the author
GetIntOk is a helper routine that returns a boolean representing if a value was set, and if so, dereferences the pointer to it.
GetJsonNumberOk is a helper routine that returns a boolean representing if a value was set, and if so, dereferences the pointer to it.
GetPrecision is a helper routine that returns a boolean representing if a value was set, and if so, dereferences the pointer to it.
GetStringId is a helper routine that allows screenboards and timeboards to be retrieved by either the legacy numerical format or the new string format.
GetStringOk is a helper routine that returns a boolean representing if a value was set, and if so, dereferences the pointer to it.
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
Int64 is a helper routine that allocates a new int64 value to store v and return a pointer to it.
JsonNumber is a helper routine that allocates a new string value to store v and returns a pointer to it.
NewClient returns a new datadog.Client which can be used to access the API methods.
Precision is a helper routine that allocates a new precision value to store v and returns a pointer to it.
ServiceLevelObjectiveTimeFrameToDuration will convert a timeframe into a duration.
String is a helper routine that allocates a new string value to store v and returns a pointer to it.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
The three downtime type classifications.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
The three downtime type classifications.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Define the available machine-readable SLO types.
Define the available machine-readable SLO types.
No description provided by the author
The three downtime type classifications.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

ServiceLevelObjectiveTypeFromID maps machine-readable type to human-readable type.
Define the available human-readable SLO types.
Define the available human-readable SLO types.
ServiceLevelObjectiveTypeToID maps human-readable type to machine-readable type.

# Structs

Alert represents the data of an alert: a query that can fire and send a message to the users.
AlertGraphDefinition represents the definition for an Alert Graph widget.
AlertValueDefinition represents the definition for an Alert Value widget.
APIKey represents and API key.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
APPKey represents an APP key.
ArithmeticProcessor struct represents unique part of arithmetic processor object from config API.
AttributeRemapper struct represents unique part of attribute remapper object from config API.
Board represents a user created dashboard.
BoardLite represents a simplify dashboard (without widgets, notify list, ...) It's used when we load all boards.
BoardWidget represents the structure of any widget.
Category represents category object from config API.
CategoryProcessor struct represents unique part of category processor object from config API.
ChangeDefinition represents the definition for a Change widget.
No description provided by the author
ChannelSlackRequest defines the Channels struct that is part of the IntegrationSlackRequest.
No description provided by the author
CheckStatusDefinition represents the definition for a Check Status widget.
Client is the object that handles talking to the Datadog API.
Comment is a special form of event that appears in a stream.
No description provided by the author
CreatedBy represents a field from DashboardLite.
Creator contains the creator of the monitor.
Dashboard represents a user created dashboard.
No description provided by the author
DashboardList represents a dashboard list.
DashboardListItem represents a single dashboard in a dashboard list.
DashboardListItemV2 represents a single dashboard in a dashboard list.
DashboardLite represents a user created dashboard.
string array of public_id.
DistributionDefinition represents the definition for a Distribution widget.
No description provided by the author
No description provided by the author
Event is a single event.
EventStreamDefinition represents the definition for an Event Stream widget.
EventTimelineDefinition represents the definition for an Event Timeline widget.
ExclusionFilter represents the index exclusion filter object from config API.
Filter represents the index filter object from config API.
FilterConfiguration struct to represent the json object of filter configuration.
FreeTextDefinition represents the definition for a Free Text widget.
GeoIPParser represents geoIpParser object from config API.
Graph represents a graph that might exist on a dashboard.
GraphApmOrLogQuery represents an APM or a Log query.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GraphDefinitionRequest represents the requests passed into each graph.
GraphDefinitionRequestStyle represents the graph style attributes.
No description provided by the author
No description provided by the author
GrokParser represents the grok parser processor object from config API.
GrokRule represents the rules for grok parser from config API.
No description provided by the author
GroupDefinition represents the definition for an Group widget.
HeatmapDefinition represents the definition for a Heatmap widget.
No description provided by the author
No description provided by the author
No description provided by the author
HostmapDefinition represents the definition for a Hostmap widget.
No description provided by the author
No description provided by the author
No description provided by the author
HostTotalsResp defines response to GET /v1/hosts/totals.
IframeDefinition represents the definition for an Iframe widget.
ImageDefinition represents the definition for an Image widget.
IntegrationAWSAccount defines the request payload for creating & updating Datadog-AWS integration.
IntegrationAWSAccountCreateResponse defines the response payload for creating & updating Datadog-AWS integration.
No description provided by the author
No description provided by the author
IntegrationAWSLambdaARN is only defined to properly parse the AWS logs GET response.
No description provided by the author
IntegrationAWSLogs is only defined to properly parse the AWS logs GET response.
No description provided by the author
IntegrationGCP defines the response for listing Datadog-Google CloudPlatform integration.
IntegrationGCPCreateRequest defines the request payload for creating Datadog-Google CloudPlatform integration.
IntegrationGCPDeleteRequest defines the request payload for deleting Datadog-Google CloudPlatform integration.
IntegrationGCPUpdateRequest defines the request payload for updating Datadog-Google CloudPlatform integration.
IntegrationPDRequest defines the request payload for creating & updating Datadog-PagerDuty integration.
IntegrationSlackRequest defines the request payload for creating & updating Datadog-Slack integration.
IntegrationWebhookRequest defines the structure of the a webhook request.
IP ranges US: https://ip-ranges.datadoghq.com EU: https://ip-ranges.datadoghq.eu Same structure.
Logs represents the data of a log entry and contains the UUID of that entry (which is used for the StartAt option in an API request) as well as the content of that log.
LogsContent respresents the actual log content returned by the list API.
No description provided by the author
LogsIndex represents the Logs index object from config API.
LogsIndexList represents the index list object from config API.
LogsList represents the base API response returned by the list API.
LogsListRequest represents the request body sent to the list API.
LogsListRequestQueryTime represents the time object for the request sent to the list API.
LogsPipeline struct to represent the json object received from Logs Public Config API.
LogsPipelineList struct represents the pipeline order from Logs Public Config API.
LogsProcessor struct represents the processor object from Config API.
LogStreamDefinition represents the definition for a Log Stream widget.
LookupProcessor represents the lookup processor from config API.
ManageStatusDefinition represents the definition for a Manage Status widget.
Metric represents a collection of data points that we might send or receive on one single metric line.
MetricMetadata allows you to edit fields of a metric's metadata.
Monitor allows watching a metric or check that you care about, notifying your team when some defined threshold is exceeded.
No description provided by the author
MonitorQueryOpts contains the options supported by https://docs.datadoghq.com/api/?lang=bash#get-all-monitor-details.
MuteMonitorScope specifies which scope to mute and when to end the mute.
NestedPipeline represents the pipeline as processor from config API.
NoteDefinition represents the definition for a Note widget.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
QueryTableDefinition represents the definition for a Table widget.
No description provided by the author
QueryValueDefinition represents the definition for a Query Value widget.
No description provided by the author
No description provided by the author
No description provided by the author
Response contains common fields that might be present in any API response.
No description provided by the author
No description provided by the author
ScatterplotDefinition represents the definition for a Scatterplot widget.
No description provided by the author
No description provided by the author
Screenboard represents a user created screenboard.
ScreenboardLite represents a user created screenboard.
No description provided by the author
No description provided by the author
Series represents a collection of data points we get when we query for timeseries data.
ServiceHookSlackRequest defines the ServiceHooks struct that is part of the IntegrationSlackRequest.
ServiceLevelObjective defines the Service Level Objective entity.
ServiceLevelObjectiveDefinition represents the definition for a Service Level Objective widget.
ServiceLevelObjectiveDeleteTimeFramesError is the error specific to deleting individual time frames.
ServiceLevelObjectiveDeleteTimeFramesResponse is the response unique to the delete individual time-frames request this is read-only.
ServiceLevelObjectiveHistoryMetricSeries defines the SLO history data response for `metric` type SLOs.
ServiceLevelObjectiveHistoryMetricSeriesData contains the `batch_query` like history data for `metric` based SLOs.
ServiceLevelObjectiveHistoryMonitorSeries defines the SLO history data response for `monitor` type SLOs.
ServiceLevelObjectiveHistoryOverall defines the overall SLO history data response for `monitor` type SLOs there is an additional `History` property that rolls up the overall state correctly.
ServiceLevelObjectiveHistoryResponse is the canonical response for SLO history data.
ServiceLevelObjectiveHistoryResponseData contains the SLO history data response.
ServiceLevelObjectiveMetricQuery represents a metric-based SLO definition query Numerator is the sum of the `good` events Denominator is the sum of the `total` events.
ServiceLevelObjectivesCanDeleteResponse is the response for a check can delete SLO endpoint.
ServiceLevelObjectiveThreshold defines an SLO threshold and timeframe For example it's the `<SLO: ex 99.999%> of <SLI> within <TimeFrame: ex 7d>.
ServicePDRequest defines the Services struct that is part of the IntegrationPDRequest.
SourceRemapper represents the object from config API that contains only a list of sources.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SyntheticsTest represents a synthetics test, either api or browser.
No description provided by the author
Template variable represents a template variable that might exist on a dashboard.
Template variable preset represents a set of template variable values on a dashboard Not available to timeboards and screenboards.
Template variable preset value represents the value for "name" template variable to assume.
No description provided by the author
No description provided by the author
No description provided by the author
TileDefApmOrLogQuery represents an APM or a Log query.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TimeseriesDefinition represents the definition for a Timeseries widget.
No description provided by the author
No description provided by the author
No description provided by the author
ToplistDefinition represents the definition for a Top list widget.
No description provided by the author
TraceServiceDefinition represents the definition for a Trace Service widget.
No description provided by the author
Unit represents a unit definition that we might receive when query for timeseries data.
UnmuteMonitorScopes specifies which scope(s) to unmute.
UrlParser represents the url parser from config API.
No description provided by the author
UserAgentParser represents the user agent parser from config API.
Webhook defines the structure of the a webhook.
No description provided by the author
WidgetApmOrLogQuery represents an APM or a Log query.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WidgetLayout represents the layout for a widget on a "free" dashboard.
No description provided by the author
No description provided by the author
WidgetProcessQuery represents a Process query.
WidgetRequestStyle represents the style that can be apply to a request.
No description provided by the author
No description provided by the author

# Type aliases

DataPoint is a tuple of [UNIX timestamp, value].
DowntimeType are a classification of a given downtime scope.
No description provided by the author
LogsAttributes represents the Content attribute object from the list API.
No description provided by the author
No description provided by the author
ServiceLevelObjectiveHistorySeriesPoint is a convenient wrapper for (timestamp, value) history data response.
ServiceLevelObjectiveThresholds is a sortable array of ServiceLevelObjectiveThreshold(s).
No description provided by the author
TagMap is used to receive the format given to us by the API.
A Series is characterized by 2 units as: x per y One or both could be missing.