add configuration ForceUseServerTS (#1128)

This commit is contained in:
ulricqin 2022-08-22 23:22:58 +08:00 committed by GitHub
parent 640b6e6825
commit 3963470603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -190,6 +190,7 @@ type Config struct {
EngineDelay int64
DisableUsageReport bool
ReaderFrom string
ForceUseServerTS bool
Log logx.Config
HTTP httpx.Config
BasicAuth gin.Accounts

View File

@ -55,6 +55,16 @@ func (w WriterType) Write(index int, items []*prompb.TimeSeries, headers ...map[
}
}()
if config.C.ForceUseServerTS {
ts := start.UnixMilli()
for i := 0; i < len(items); i++ {
if len(items[i].Samples) == 0 {
continue
}
items[i].Samples[0].Timestamp = ts
}
}
req := &prompb.WriteRequest{
Timeseries: items,
}