diff --git a/pkg/metrics/providers/splunk.go b/pkg/metrics/providers/splunk.go index c535fa7b6..df458ff9a 100644 --- a/pkg/metrics/providers/splunk.go +++ b/pkg/metrics/providers/splunk.go @@ -82,7 +82,7 @@ func NewSplunkProvider(metricInterval string, return nil, fmt.Errorf("error parsing metric interval: %w", err) } - sp.fromDelta = int64(signalFxFromDeltaMultiplierOnMetricInterval * md.Seconds()) + sp.fromDelta = int64(signalFxFromDeltaMultiplierOnMetricInterval * md.Milliseconds()) return &sp, nil } @@ -95,7 +95,7 @@ func (p *SplunkProvider) RunQuery(query string) (float64, error) { } req.Header.Set(signalFxTokenHeaderKey, p.token) - now := time.Now().Unix() + now := time.Now().UnixMilli() q := req.URL.Query() q.Add("query", query) q.Add("startMS", strconv.FormatInt(now-p.fromDelta, 10)) diff --git a/pkg/metrics/providers/splunk_test.go b/pkg/metrics/providers/splunk_test.go index cb77669ca..f154322c1 100644 --- a/pkg/metrics/providers/splunk_test.go +++ b/pkg/metrics/providers/splunk_test.go @@ -45,7 +45,7 @@ func TestNewSplunkProvider(t *testing.T) { require.NoError(t, err) assert.Equal(t, "https://api.us1.signalfx.com/v1/timeserieswindow", sp.metricsQueryEndpoint) assert.Equal(t, "https://api.us1.signalfx.com/v2/metric?limit=1", sp.apiValidationEndpoint) - assert.Equal(t, int64(md.Seconds()*signalFxFromDeltaMultiplierOnMetricInterval), sp.fromDelta) + assert.Equal(t, int64(md.Milliseconds()*signalFxFromDeltaMultiplierOnMetricInterval), sp.fromDelta) assert.Equal(t, token, sp.token) } @@ -54,7 +54,7 @@ func TestSplunkProvider_RunQuery(t *testing.T) { t.Run("ok", func(t *testing.T) { expected := 1.11111 eq := `sf_metric:service.request.count AND http_status_code:*` - now := time.Now().Unix() + now := time.Now().UnixMilli() ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { aq := r.URL.Query().Get("query") assert.Equal(t, eq, aq)