CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/golang-github-com-data-dog--datadog-api-client-go-v2

Comprehensive Go API client for the Datadog monitoring and analytics platform with strongly-typed interfaces for all Datadog API v1 and v2 endpoints

Overview
Eval results
Files

observability-core.mddocs/v2/

V2 Core Observability APIs

Monitoring, logs, metrics, RUM, APM, and spans APIs in v2.

Package Import

import (
    "context"
    "github.com/DataDog/datadog-api-client-go/v2/api/datadog"
    "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

Monitors API

Enhanced monitor configuration and notification management.

API Client

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

func NewMonitorsApi(client *datadog.APIClient) *MonitorsApi

Methods

func (a *MonitorsApi) CreateMonitorConfigPolicy(
    ctx context.Context,
    body datadogV2.MonitorConfigPolicyCreateRequest,
) (datadogV2.MonitorConfigPolicyResponse, *http.Response, error)

Create a monitor configuration policy.

func (a *MonitorsApi) CreateMonitorNotificationRule(
    ctx context.Context,
    body datadogV2.MonitorNotificationRuleCreateRequest,
) (datadogV2.MonitorNotificationRuleResponse, *http.Response, error)

Create a monitor notification rule.

func (a *MonitorsApi) DeleteMonitorConfigPolicy(
    ctx context.Context,
    policyId string,
) (*http.Response, error)
func (a *MonitorsApi) GetMonitorConfigPolicy(
    ctx context.Context,
    policyId string,
) (datadogV2.MonitorConfigPolicyResponse, *http.Response, error)
func (a *MonitorsApi) ListMonitorConfigPolicies(
    ctx context.Context,
) (datadogV2.MonitorConfigPolicyListResponse, *http.Response, error)

Downtimes API

Enhanced downtime scheduling.

API Client

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

func NewDowntimesApi(client *datadog.APIClient) *DowntimesApi

Methods

func (a *DowntimesApi) CancelDowntime(
    ctx context.Context,
    downtimeId string,
) (*http.Response, error)
func (a *DowntimesApi) CreateDowntime(
    ctx context.Context,
    body datadogV2.DowntimeCreateRequest,
) (datadogV2.DowntimeResponse, *http.Response, error)
func (a *DowntimesApi) GetDowntime(
    ctx context.Context,
    downtimeId string,
    o ...GetDowntimeOptionalParameters,
) (datadogV2.DowntimeResponse, *http.Response, error)
func (a *DowntimesApi) ListDowntimes(
    ctx context.Context,
    o ...ListDowntimesOptionalParameters,
) (datadogV2.ListDowntimesResponse, *http.Response, error)
func (a *DowntimesApi) ListDowntimesWithPagination(
    ctx context.Context,
    o ...ListDowntimesOptionalParameters,
) (<-chan datadog.PaginationResult[datadogV2.DowntimeResponseData], func())
func (a *DowntimesApi) ListMonitorDowntimes(
    ctx context.Context,
    monitorId int64,
    o ...ListMonitorDowntimesOptionalParameters,
) (datadogV2.MonitorDowntimeMatchResponse, *http.Response, error)
func (a *DowntimesApi) UpdateDowntime(
    ctx context.Context,
    downtimeId string,
    body datadogV2.DowntimeUpdateRequest,
) (datadogV2.DowntimeResponse, *http.Response, error)

Logs API

Enhanced log querying and aggregation.

API Client

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

func NewLogsApi(client *datadog.APIClient) *LogsApi

Methods

func (a *LogsApi) AggregateLogs(
    ctx context.Context,
    body datadogV2.LogsAggregateRequest,
) (datadogV2.LogsAggregateResponse, *http.Response, error)

Aggregate logs with metrics-style queries.

func (a *LogsApi) ListLogs(
    ctx context.Context,
    o ...ListLogsOptionalParameters,
) (datadogV2.LogsListResponse, *http.Response, error)

Search logs. Use ListLogsOptionalParameters to specify the request body.

func (a *LogsApi) ListLogsWithPagination(
    ctx context.Context,
    o ...ListLogsOptionalParameters,
) (<-chan datadog.PaginationResult[datadogV2.Log], func())

Search logs with pagination.

func (a *LogsApi) ListLogsGet(
    ctx context.Context,
    o ...ListLogsGetOptionalParameters,
) (datadogV2.LogsListResponse, *http.Response, error)

Search logs using GET request.

func (a *LogsApi) ListLogsGetWithPagination(
    ctx context.Context,
    o ...ListLogsGetOptionalParameters,
) (<-chan datadog.PaginationResult[datadogV2.Log], func())

Search logs using GET request with pagination.

func (a *LogsApi) SubmitLog(
    ctx context.Context,
    body []datadogV2.HTTPLogItem,
    o ...SubmitLogOptionalParameters,
) (interface{}, *http.Response, error)

Submit logs via HTTP.

Key Types

type LogsAggregateRequest struct {
    Compute []datadogV2.LogsCompute
    Filter  *datadogV2.LogsQueryFilter
    GroupBy []datadogV2.LogsGroupBy
    Options *datadogV2.LogsQueryOptions
    Page    *datadogV2.LogsAggregateRequestPage
}

Example Usage

// Aggregate logs
compute := []datadogV2.LogsCompute{
    {
        Aggregation: datadogV2.LOGSAGGREGATIONFUNCTION_COUNT,
        Metric:      datadog.PtrString("*"),
        Type:        datadogV2.LOGSCOMPUTETYPE_TOTAL.Ptr(),
    },
}

filter := &datadogV2.LogsQueryFilter{
    From:  datadog.PtrString("now-1h"),
    Query: datadog.PtrString("status:error"),
    To:    datadog.PtrString("now"),
}

groupBy := []datadogV2.LogsGroupBy{
    {
        Facet: "service",
        Limit: datadog.PtrInt64(10),
        Sort:  &datadogV2.LogsAggregateSort{
            Aggregation: datadogV2.LOGSAGGREGATIONFUNCTION_COUNT,
            Order:       datadogV2.LOGSSORTORDER_DESCENDING.Ptr(),
        },
    },
}

body := datadogV2.LogsAggregateRequest{
    Compute: compute,
    Filter:  filter,
    GroupBy: groupBy,
}

resp, r, err := logsApi.AggregateLogs(ctx, body)
if err != nil {
    fmt.Fprintf(os.Stderr, "Error: %v\n", err)
    return
}

fmt.Printf("Log aggregation results: %+v\n", resp)

Logs Archives API

Manage log archives for long-term storage.

API Client

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

func NewLogsArchivesApi(client *datadog.APIClient) *LogsArchivesApi

Methods

func (a *LogsArchivesApi) AddReadRoleToArchive(
    ctx context.Context,
    archiveId string,
    body datadogV2.RelationshipToRole,
) (*http.Response, error)
func (a *LogsArchivesApi) CreateLogsArchive(
    ctx context.Context,
    body datadogV2.LogsArchiveCreateRequest,
) (datadogV2.LogsArchive, *http.Response, error)
func (a *LogsArchivesApi) DeleteLogsArchive(
    ctx context.Context,
    archiveId string,
) (*http.Response, error)
func (a *LogsArchivesApi) GetLogsArchive(
    ctx context.Context,
    archiveId string,
) (datadogV2.LogsArchive, *http.Response, error)
func (a *LogsArchivesApi) ListLogsArchives(
    ctx context.Context,
) (datadogV2.LogsArchives, *http.Response, error)
func (a *LogsArchivesApi) UpdateLogsArchive(
    ctx context.Context,
    archiveId string,
    body datadogV2.LogsArchiveUpdateRequest,
) (datadogV2.LogsArchive, *http.Response, error)

Logs Metrics API

Create logs-based metrics.

API Client

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

func NewLogsMetricsApi(client *datadog.APIClient) *LogsMetricsApi

Methods

func (a *LogsMetricsApi) CreateLogsMetric(
    ctx context.Context,
    body datadogV2.LogsMetricCreateRequest,
) (datadogV2.LogsMetricResponse, *http.Response, error)
func (a *LogsMetricsApi) DeleteLogsMetric(
    ctx context.Context,
    metricId string,
) (*http.Response, error)
func (a *LogsMetricsApi) GetLogsMetric(
    ctx context.Context,
    metricId string,
) (datadogV2.LogsMetricResponse, *http.Response, error)
func (a *LogsMetricsApi) ListLogsMetrics(
    ctx context.Context,
) (datadogV2.LogsMetricsResponse, *http.Response, error)
func (a *LogsMetricsApi) UpdateLogsMetric(
    ctx context.Context,
    metricId string,
    body datadogV2.LogsMetricUpdateRequest,
) (datadogV2.LogsMetricResponse, *http.Response, error)

Metrics API

Enhanced metric management with tag configuration.

API Client

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

func NewMetricsApi(client *datadog.APIClient) *MetricsApi

Methods

func (a *MetricsApi) CreateBulkTagsMetricsConfiguration(
    ctx context.Context,
    body datadogV2.MetricBulkTagConfigCreateRequest,
) (datadogV2.MetricBulkTagConfigResponse, *http.Response, error)

Bulk create tag configurations.

func (a *MetricsApi) CreateTagConfiguration(
    ctx context.Context,
    metricName string,
    body datadogV2.MetricTagConfigurationCreateRequest,
) (datadogV2.MetricTagConfigurationResponse, *http.Response, error)

Create tag configuration for a metric.

func (a *MetricsApi) DeleteTagConfiguration(
    ctx context.Context,
    metricName string,
) (*http.Response, error)
func (a *MetricsApi) EstimateMetricsOutputSeries(
    ctx context.Context,
    metricName string,
    o ...EstimateMetricsOutputSeriesOptionalParameters,
) (datadogV2.MetricEstimateResponse, *http.Response, error)

Estimate output series for a metric query.

func (a *MetricsApi) ListTagConfigurationByName(
    ctx context.Context,
    metricName string,
) (datadogV2.MetricTagConfigurationResponse, *http.Response, error)
func (a *MetricsApi) QueryScalarData(
    ctx context.Context,
    body datadogV2.ScalarFormulaQueryRequest,
) (datadogV2.ScalarFormulaQueryResponse, *http.Response, error)

Query scalar metrics data.

func (a *MetricsApi) QueryTimeseriesData(
    ctx context.Context,
    body datadogV2.TimeseriesFormulaQueryRequest,
) (datadogV2.TimeseriesFormulaQueryResponse, *http.Response, error)

Query timeseries metrics data.

func (a *MetricsApi) SubmitMetrics(
    ctx context.Context,
    body datadogV2.MetricPayload,
    o ...SubmitMetricsOptionalParameters,
) (datadogV2.IntakePayloadAccepted, *http.Response, error)

Submit metrics.

func (a *MetricsApi) UpdateTagConfiguration(
    ctx context.Context,
    metricName string,
    body datadogV2.MetricTagConfigurationUpdateRequest,
) (datadogV2.MetricTagConfigurationResponse, *http.Response, error)

Update tag configuration.

RUM API

Real User Monitoring for frontend applications.

API Client

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

func NewRUMApi(client *datadog.APIClient) *RUMApi

Methods

func (a *RUMApi) AggregateRUMEvents(
    ctx context.Context,
    body datadogV2.RUMAggregateRequest,
) (datadogV2.RUMAnalyticsAggregateResponse, *http.Response, error)

Aggregate RUM events.

func (a *RUMApi) CreateRUMApplication(
    ctx context.Context,
    body datadogV2.RUMApplicationCreateRequest,
) (datadogV2.RUMApplicationResponse, *http.Response, error)

Create a RUM application.

func (a *RUMApi) DeleteRUMApplication(
    ctx context.Context,
    id string,
) (*http.Response, error)
func (a *RUMApi) GetRUMApplication(
    ctx context.Context,
    id string,
) (datadogV2.RUMApplicationResponse, *http.Response, error)
func (a *RUMApi) GetRUMApplications(
    ctx context.Context,
) (datadogV2.RUMApplicationsResponse, *http.Response, error)
func (a *RUMApi) ListRUMEvents(
    ctx context.Context,
    o ...ListRUMEventsOptionalParameters,
) (datadogV2.RUMEventsResponse, *http.Response, error)

List RUM events.

func (a *RUMApi) ListRUMEventsWithPagination(
    ctx context.Context,
    o ...ListRUMEventsOptionalParameters,
) (<-chan datadog.PaginationResult[datadogV2.RUMEvent], func())
func (a *RUMApi) SearchRUMEvents(
    ctx context.Context,
    body datadogV2.RUMSearchEventsRequest,
) (datadogV2.RUMEventsResponse, *http.Response, error)

Search RUM events.

func (a *RUMApi) UpdateRUMApplication(
    ctx context.Context,
    id string,
    body datadogV2.RUMApplicationUpdateRequest,
) (datadogV2.RUMApplicationResponse, *http.Response, error)

Example Usage

// Create a RUM application
attrs := datadogV2.NewRUMApplicationCreateAttributes(
    "My Web App",
    datadogV2.RUMAPPLICATIONCREATETYPE_BROWSER,
)

data := datadogV2.NewRUMApplicationCreateData(*attrs, datadogV2.RUMAPPLICATIONTYPE_RUM_APPLICATION)
body := datadogV2.NewRUMApplicationCreateRequest(*data)

resp, r, err := rumApi.CreateRUMApplication(ctx, *body)
if err != nil {
    fmt.Fprintf(os.Stderr, "Error: %v\n", err)
    return
}

fmt.Printf("RUM application created: %s (Client token: %s)\n",
    resp.Data.Attributes.GetName(),
    resp.Data.Attributes.GetClientToken())

RUM Metrics API

Create RUM-based metrics.

API Client

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

func NewRumMetricsApi(client *datadog.APIClient) *RumMetricsApi

Methods

func (a *RumMetricsApi) CreateRumMetric(
    ctx context.Context,
    body datadogV2.RumMetricCreateRequest,
) (datadogV2.RumMetricResponse, *http.Response, error)
func (a *RumMetricsApi) DeleteRumMetric(
    ctx context.Context,
    metricId string,
) (*http.Response, error)
func (a *RumMetricsApi) GetRumMetric(
    ctx context.Context,
    metricId string,
) (datadogV2.RumMetricResponse, *http.Response, error)
func (a *RumMetricsApi) ListRumMetrics(
    ctx context.Context,
) (datadogV2.RumMetricsResponse, *http.Response, error)
func (a *RumMetricsApi) UpdateRumMetric(
    ctx context.Context,
    metricId string,
    body datadogV2.RumMetricUpdateRequest,
) (datadogV2.RumMetricResponse, *http.Response, error)

APM API

Application Performance Monitoring.

API Client

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

func NewAPMApi(client *datadog.APIClient) *APMApi

Methods

func (a *APMApi) GetServiceList(
    ctx context.Context,
) (datadogV2.ServiceListResponse, *http.Response, error)

Get list of APM services.

APM Retention Filters API

Configure APM trace retention.

API Client

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

func NewAPMRetentionFiltersApi(client *datadog.APIClient) *APMRetentionFiltersApi

Methods

func (a *APMRetentionFiltersApi) CreateApmRetentionFilter(
    ctx context.Context,
    body datadogV2.RetentionFilterCreateRequest,
) (datadogV2.RetentionFilterResponse, *http.Response, error)
func (a *APMRetentionFiltersApi) DeleteApmRetentionFilter(
    ctx context.Context,
    filterId string,
) (*http.Response, error)
func (a *APMRetentionFiltersApi) GetApmRetentionFilter(
    ctx context.Context,
    filterId string,
) (datadogV2.RetentionFilterResponse, *http.Response, error)
func (a *APMRetentionFiltersApi) ListApmRetentionFilters(
    ctx context.Context,
) (datadogV2.RetentionFiltersResponse, *http.Response, error)
func (a *APMRetentionFiltersApi) ReorderApmRetentionFilters(
    ctx context.Context,
    body datadogV2.ReorderRetentionFiltersRequest,
) (*http.Response, error)
func (a *APMRetentionFiltersApi) UpdateApmRetentionFilter(
    ctx context.Context,
    filterId string,
    body datadogV2.RetentionFilterUpdateRequest,
) (datadogV2.RetentionFilterResponse, *http.Response, error)

Spans API

Query and aggregate spans from APM traces.

API Client

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

func NewSpansApi(client *datadog.APIClient) *SpansApi

Methods

func (a *SpansApi) AggregateSpans(
    ctx context.Context,
    body datadogV2.SpansAggregateRequest,
) (datadogV2.SpansAggregateResponse, *http.Response, error)
func (a *SpansApi) ListSpans(
    ctx context.Context,
    body datadogV2.SpansListRequest,
) (datadogV2.SpansListResponse, *http.Response, error)
func (a *SpansApi) ListSpansWithPagination(
    ctx context.Context,
    body datadogV2.SpansListRequest,
) (<-chan datadog.PaginationResult[datadogV2.Span], func())
func (a *SpansApi) ListSpansGet(
    ctx context.Context,
    o ...ListSpansGetOptionalParameters,
) (datadogV2.SpansListResponse, *http.Response, error)

Spans Metrics API

Create span-based metrics.

API Client

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

func NewSpansMetricsApi(client *datadog.APIClient) *SpansMetricsApi

Methods

func (a *SpansMetricsApi) CreateSpansMetric(
    ctx context.Context,
    body datadogV2.SpansMetricCreateRequest,
) (datadogV2.SpansMetricResponse, *http.Response, error)
func (a *SpansMetricsApi) DeleteSpansMetric(
    ctx context.Context,
    metricId string,
) (*http.Response, error)
func (a *SpansMetricsApi) GetSpansMetric(
    ctx context.Context,
    metricId string,
) (datadogV2.SpansMetricResponse, *http.Response, error)
func (a *SpansMetricsApi) ListSpansMetrics(
    ctx context.Context,
) (datadogV2.SpansMetricsResponse, *http.Response, error)
func (a *SpansMetricsApi) UpdateSpansMetric(
    ctx context.Context,
    metricId string,
    body datadogV2.SpansMetricUpdateRequest,
) (datadogV2.SpansMetricResponse, *http.Response, error)

Install with Tessl CLI

npx tessl i tessl/golang-github-com-data-dog--datadog-api-client-go-v2

docs

common-package.md

index.md

tile.json