Skip to content

Commit

Permalink
Merge #131579
Browse files Browse the repository at this point in the history
131579: cli: improve tsdump datadog discoverability r=aa-joshi a=aa-joshi

Previously, upload id is shared at start of tsdump upload command. This id was getting truncated during command execution due to command line outputs. To address this, we are sharing upload id at the end of command execution. Along with this, we are generating custom datadog dashboard link to visualize uploaded data.

Epic: none
Release note: none

Co-authored-by: Akshay Joshi <[email protected]>
  • Loading branch information
craig[bot] and aa-joshi committed Oct 1, 2024
2 parents 90e4ba0 + b9cbc98 commit 6a7fff7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
/pkg/cli/syncbench/ @cockroachdb/storage @cockroachdb/kv-prs
/pkg/cli/swappable_fs* @cockroachdb/storage
/pkg/cli/testutils.go @cockroachdb/test-eng
/pkg/cli/tsdump.go @cockroachdb/obs-prs @cockroachdb/obs-india-prs
/pkg/cli/tsdump*.go @cockroachdb/obs-prs @cockroachdb/obs-india-prs
/pkg/cli/userfile.go @cockroachdb/disaster-recovery
/pkg/cli/workload* @cockroachdb/sql-foundations
/pkg/cli/zip*.go @cockroachdb/obs-prs @cockroachdb/cli-prs @cockroachdb/obs-india-prs
Expand Down
15 changes: 10 additions & 5 deletions pkg/cli/tsdump_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ var (
"us1-fed": "api.ddog-gov.com",
}

targetURLFormat = "https://%s/api/v2/series"
targetURLFormat = "https://%s/api/v2/series"
datadogDashboardURLFormat = "https://us5.datadoghq.com/dashboard/bif-kwe-gx2/self-hosted-db-console-tsdump?" +
"tpl_var_cluster=%s&tpl_var_upload_id=%s&from_ts=%d&to_ts=%d"
)

// DatadogPoint is a single metric point in Datadog format
Expand Down Expand Up @@ -210,10 +212,6 @@ func (d *datadogWriter) emitDataDogMetrics(data []DatadogSeries) error {

tags = append(tags, makeDDTag(uploadIDTag, d.uploadID))

d.Do(func() {
fmt.Println("Upload ID:", d.uploadID)
})

for i := 0; i < len(data); i++ {
data[i].Tags = append(data[i].Tags, tags...)
data[i].Metric = d.namePrefix + data[i].Metric
Expand Down Expand Up @@ -336,6 +334,13 @@ func (d *datadogWriter) upload(fileName string) error {
}

wg.Wait()
toUnixTimestamp := timeutil.Now().UnixMilli()
//create timestamp for T-30 days.
fromUnixTimestamp := toUnixTimestamp - (30 * 24 * 60 * 60 * 1000)
dashboardLink := fmt.Sprintf(datadogDashboardURLFormat, debugTimeSeriesDumpOpts.clusterLabel, d.uploadID, fromUnixTimestamp, toUnixTimestamp)

fmt.Println("upload id:", d.uploadID)
fmt.Printf("datadog dashboard link: %s\n", dashboardLink)
close(ch)
return nil
}

0 comments on commit 6a7fff7

Please sign in to comment.