CLI tool for querying Datadog from the terminal.
datadogV2.LogsApi: ListLogsGet (search, tail), AggregateLogsdatadogV1.LogsIndexesApi: ListLogIndexes, GetLogsIndex, CreateLogsIndex, UpdateLogsIndex, DeleteLogsIndexdatadogV1.LogsPipelinesApi: ListLogsPipelines, GetLogsPipeline, CreateLogsPipeline, UpdateLogsPipeline, DeleteLogsPipelinedatadogV2.LogsArchivesApi: ListLogsArchives, GetLogsArchive, CreateLogsArchive, UpdateLogsArchive, DeleteLogsArchivedatadogV2.LogsMetricsApi: ListLogsMetrics, GetLogsMetric, CreateLogsMetric, UpdateLogsMetric, DeleteLogsMetricdatadogV2.LogsCustomDestinationsApi: ListLogsCustomDestinations, GetLogsCustomDestination, CreateLogsCustomDestination, UpdateLogsCustomDestination, DeleteLogsCustomDestinationdatadogV2.LogsRestrictionQueriesApi: ListRestrictionQueries, GetRestrictionQuery, CreateRestrictionQuery, UpdateRestrictionQuery, DeleteRestrictionQuery
datadogV1.MetricsApi: QueryMetrics, ListMetrics, ListActiveMetrics, GetMetricMetadata, UpdateMetricMetadatadatadogV2.MetricsApi: QueryScalarData, QueryTimeseriesData, SubmitMetrics, ListTagConfigurations, GetTagConfiguration, CreateTagConfiguration, UpdateTagConfiguration, DeleteTagConfiguration, ListTagsByMetricName, ListVolumesByMetricName, ListMetricAssets, EstimateMetricsOutputSeries
datadogV2.SpansApi: ListSpansGet, AggregateSpansdatadogV2.APMApi: GetServiceListdatadogV2.APMRetentionFiltersApi: ListApmRetentionFilters, GetApmRetentionFilter, CreateApmRetentionFilter, UpdateApmRetentionFilter, DeleteApmRetentionFilterdatadogV2.SpansMetricsApi: ListSpansMetrics, GetSpansMetric, CreateSpansMetric, UpdateSpansMetric, DeleteSpansMetric
datadogV2.CIVisibilityPipelinesApi: ListCIAppPipelineEvents, AggregateCIAppPipelineEvents, CreateCIAppPipelineEventdatadogV2.CIVisibilityTestsApi: ListCIAppTestEvents, AggregateCIAppTestEvents
datadogV1.DashboardsApi: ListDashboards, GetDashboard, CreateDashboard, UpdateDashboard, DeleteDashboarddatadogV1.DashboardListsApi: ListDashboardLists, GetDashboardList, CreateDashboardList, UpdateDashboardList, DeleteDashboardListdatadogV2.DashboardListsApi: CreateDashboardListItems, DeleteDashboardListItems
datadogV2.EventsApi: ListEvents, SearchEvents, GetEvent, CreateEvent- Note: CreateEvent requires unstable operation flag:
c.GetConfig().SetUnstableOperationEnabled("v2.EventsApi.CreateEvent", true) AlertEventCustomAttributesStatushas three values: OK, WARN, ERROR (no SUCCESS constant)
datadogV1.HostsApi: ListHosts, GetHostTotals, MuteHost, UnmuteHostdatadogV1.TagsApi: ListHostTags, GetHostTags, CreateHostTags, UpdateHostTags, DeleteHostTags
datadogV1.MonitorsApi: ListMonitors, GetMonitor, SearchMonitors, CreateMonitor, UpdateMonitor, DeleteMonitor
datadogV2.DowntimesApi: ListDowntimes, GetDowntime, CreateDowntime, UpdateDowntime, CancelDowntime
datadogV2.MonitorsApi: ListMonitorConfigPolicies, GetMonitorConfigPolicy, CreateMonitorConfigPolicy, UpdateMonitorConfigPolicy, DeleteMonitorConfigPolicy
datadogV1.ServiceLevelObjectivesApi: ListSLOs, GetSLO, CreateSLO, UpdateSLO, DeleteSLO, CheckCanDeleteSLO, GetSLOHistorydatadogV1.ServiceLevelObjectiveCorrectionsApi: ListSLOCorrection, GetSLOCorrection, CreateSLOCorrection, UpdateSLOCorrection, DeleteSLOCorrection
datadogV1.SyntheticsApi: ListTests, SearchTests, GetTest, GetAPITest, GetBrowserTest, GetMobileTestdatadogV1.SyntheticsApi: CreateSyntheticsAPITest, CreateSyntheticsBrowserTest, DeleteTestsdatadogV1.SyntheticsApi: GetAPITestLatestResults, GetAPITestResult, GetBrowserTestLatestResults, GetBrowserTestResultdatadogV1.SyntheticsApi: TriggerTests, GetSyntheticsCIBatchdatadogV1.SyntheticsApi: ListGlobalVariables, GetGlobalVariable, CreateGlobalVariable, EditGlobalVariable, DeleteGlobalVariabledatadogV1.SyntheticsApi: ListLocations, GetSyntheticsDefaultLocations, GetPrivateLocation, CreatePrivateLocation, DeletePrivateLocationdatadogV1.SyntheticsApi: FetchUptimes- Note: SyntheticsApi is in datadogV1, not datadogV2
datadogV2.UsersApi: ListUsers, GetUser, CreateUser, UpdateUser, DisableUser, SendInvitations
datadogV2.RolesApi: ListRoles, GetRole, CreateRole, UpdateRole, DeleteRole, ListRolePermissions, AddPermissionToRole, RemovePermissionFromRole
datadogV2.TeamsApi: ListTeams, GetTeam, CreateTeam, UpdateTeam, DeleteTeam, GetTeamMemberships, CreateTeamMembership, DeleteTeamMembership
datadogV2.IncidentsApi: ListIncidents, SearchIncidents, GetIncident, CreateIncident, UpdateIncident, DeleteIncidentdatadogV2.IncidentsApi: ListIncidentTodos, GetIncidentTodo, CreateIncidentTodo, UpdateIncidentTodo, DeleteIncidentTododatadogV2.IncidentsApi: ListIncidentIntegrations, GetIncidentIntegration, CreateIncidentIntegration, UpdateIncidentIntegration, DeleteIncidentIntegrationdatadogV2.IncidentsApi: ListIncidentTypes, GetIncidentType, CreateIncidentType, UpdateIncidentType, DeleteIncidentTypedatadogV2.IncidentServicesApi: ListIncidentServices, GetIncidentService, CreateIncidentService, UpdateIncidentService, DeleteIncidentServicedatadogV2.IncidentTeamsApi: ListIncidentTeams, GetIncidentTeam, CreateIncidentTeam, UpdateIncidentTeam, DeleteIncidentTeam- Note: All Incidents API operations require unstable operation flags via
ddCfg.SetUnstableOperationEnabled("v2.<OperationName>", true)
datadogV2.SecurityMonitoringApi: ListSecurityMonitoringSignals, GetSecurityMonitoringSignal, EditSecurityMonitoringSignalState, EditSecurityMonitoringSignalAssignee, EditSecurityMonitoringSignalIncidentsdatadogV2.SecurityMonitoringApi: ListSecurityMonitoringRules, GetSecurityMonitoringRule, CreateSecurityMonitoringRule, UpdateSecurityMonitoringRule, DeleteSecurityMonitoringRule, ValidateSecurityMonitoringRuledatadogV2.SecurityMonitoringApi: ListSecurityMonitoringSuppressions, GetSecurityMonitoringSuppression, CreateSecurityMonitoringSuppression, UpdateSecurityMonitoringSuppression, DeleteSecurityMonitoringSuppressiondatadogV2.SecurityMonitoringApi: ListSecurityFilters, GetSecurityFilter, CreateSecurityFilter, UpdateSecurityFilter, DeleteSecurityFilterdatadogV2.SecurityMonitoringApi: ListFindings, GetFinding, MuteFindings- Note: Findings operations require unstable operation flags:
cfg.SetUnstableOperationEnabled("v2.ListFindings", true), same forv2.GetFindingandv2.MuteFindings
Group imports in order, separated by blank lines:
- Standard library
- External packages
- Local packages (
datadog-cli/...)
import (
"context"
"fmt"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
"datadog-cli/internal/config"
)- Package names: short, lowercase, no underscores (
config,query,output) - Exported types: PascalCase (
Config,LogEntry,SpanResult) - Unexported: camelCase (
buildFilter,formatTimestamp) - Acronyms: consistent case (
URL,HTTP,APIorurl,http,api) - Receivers: short, 1-2 letters (
cfor*Client,qfor*Query) - Errors:
Errprefix for sentinel errors (ErrAuthRequired)
- Early returns for error handling
- Group related functions together
- Wrap errors with context:
fmt.Errorf("operation: %w", err) - Check all errors (enforced by
errchecklinter) - Use
errors.Is/errors.Asfor error comparison - Sentinel errors as package-level variables
- Only for non-obvious logic
- English, lowercase, brief
- No comments for self-explanatory code
- JSON tags on all exported fields:
json:"field_name" - Use
omitemptyfor optional fields - Pointer types for optional values (
*float64,*int) - Group related fields together
- Package-level constants in
constblock - Related constants grouped together
- Unexported package variables with
var
- Use
rangewith index for modifying slices - Prefer
for i := range noverfor i := 0; i < n; i++(Go 1.22+) - Use
switchover longif-elsechains
- Use
context.Contextas first parameter - Use
sync.Mutexfor simple locking - Use
errgroupfor parallel operations
- Use table-driven tests for multiple scenarios
- Use stdlib
testingpackage only (no testify) - Test error paths: timeouts, context cancellation
- Run with race detector:
go test -race ./... - Use
t.Parallel()for independent tests - Test files:
*_test.goin same package
All documentation, comments, and text must be in English.
- Always build with
make build(runs linter automatically) - Direct
go buildskips linting - avoid it
- Run
golangci-lint runbefore committing (executed automatically viamake build) - Fix formatting issues with
goimports -w <file>orgofmt -w <file> - Config:
.golangci.ymldefines enabled linters - No trailing whitespace, proper import grouping (stdlib, external, local)