diff --git a/pkg/collector/handler_clb_private.go b/pkg/collector/handler_clb_private.go index 933a383..44a9d57 100644 --- a/pkg/collector/handler_clb_private.go +++ b/pkg/collector/handler_clb_private.go @@ -145,7 +145,6 @@ func (h *ClbPrivateHandler) GetSeriesByCustom(m *metric.TcmMetric) ([]*metric.Tc } return slist, nil } - func (h *ClbPrivateHandler) getSeriesByMetricType(m *metric.TcmMetric, ins instance.TcInstance) ([]*metric.TcmSeries, error) { var dimensions []string for _, v := range m.Meta.SupportDimensions { diff --git a/pkg/metric/metric.go b/pkg/metric/metric.go index a120e4f..9031ed7 100644 --- a/pkg/metric/metric.go +++ b/pkg/metric/metric.go @@ -61,10 +61,11 @@ func (m *TcmMetric) GetLatestPromMetrics(repo TcmMetricRepository) (pms []promet et := int64(0) now := time.Now().Unix() if m.Conf.StatDelaySeconds > 0 { - st = now - m.Conf.StatPeriodSeconds - m.Conf.StatDelaySeconds + st = now - m.Conf.StatNumSamples*m.Conf.StatPeriodSeconds - m.Conf.StatDelaySeconds et = now - m.Conf.StatDelaySeconds } else { st = now - m.Conf.StatNumSamples*m.Conf.StatPeriodSeconds + et = now } samplesList, err := repo.ListSamples(m, st, et) diff --git a/pkg/util/time.go b/pkg/util/time.go index 6c7b31f..e5bd6db 100644 --- a/pkg/util/time.go +++ b/pkg/util/time.go @@ -6,10 +6,6 @@ import "time" func FormatTime(t time.Time, format string) string { var local time.Time _, offset := t.Zone() - if offset == 0 { - local = t.Add(8 * time.Hour) - } else { - local = t - } + local = t.Add(time.Duration(8*3600-offset) * time.Second) return local.Format(format) }