Skip to content

Commit 3226165

Browse files
committed
/pkg/cli (tsdump): add interval to metrics before uploading
This commit adds a new `interval` field to the `DatadogSeries` struct to represent the interval in seconds. The interval is encoded in the keys used to store metrics in the TSDB. It can either be 10s or 1800s (30min). Recent metrics use a 10s interval, while older metrics (typically 10 days or older) that have been rolled up use a 30min interval. Part of: CC-32614 Release note: None
1 parent 8d598cb commit 3226165

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/cli/tsdump_upload.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type DatadogSeries struct {
8686
Metric string `json:"metric"`
8787
Type int `json:"type"`
8888
Points []DatadogPoint `json:"points"`
89+
Interval int `json:"interval,omitempty"`
8990
Resources []struct {
9091
Name string `json:"name"`
9192
Type string `json:"type"`
@@ -201,7 +202,7 @@ func appendTag(series *DatadogSeries, tagKey, tagValue string) {
201202
}
202203

203204
func (d *datadogWriter) dump(kv *roachpb.KeyValue) (*DatadogSeries, error) {
204-
name, source, _, _, err := ts.DecodeDataKey(kv.Key)
205+
name, source, res, _, err := ts.DecodeDataKey(kv.Key)
205206
if err != nil {
206207
return nil, err
207208
}
@@ -211,10 +212,11 @@ func (d *datadogWriter) dump(kv *roachpb.KeyValue) (*DatadogSeries, error) {
211212
}
212213

213214
series := &DatadogSeries{
214-
Metric: name,
215-
Tags: []string{},
216-
Type: d.resolveMetricType(name),
217-
Points: make([]DatadogPoint, idata.SampleCount()),
215+
Metric: name,
216+
Tags: []string{},
217+
Type: d.resolveMetricType(name),
218+
Points: make([]DatadogPoint, idata.SampleCount()),
219+
Interval: int(res.SlabDuration()) / int(time.Second), // covert from time.Duration to number of seconds.
218220
}
219221

220222
sl := reCrStoreNode.FindStringSubmatch(name)

0 commit comments

Comments
 (0)