Prometheus: Fix timestamp truncation (#46302)

* avoid truncation to seconding by using time.Time directly

* update test coverage
This commit is contained in:
Todd Treece 2022-03-08 10:55:25 -05:00 committed by GitHub
parent f7894db99c
commit db5f480a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 32 deletions

View File

@ -8,15 +8,15 @@ Frame[0] {
}
Name: prometheus_http_requests_total{code="200", handler="/api/v1/query_range", job="prometheus"}
Dimensions: 2 Fields by 3 Rows
+-------------------------------+--------------------------------------------------------------------------------------------------------+
| Name: Time | Name: Value |
| Labels: | Labels: __name__=prometheus_http_requests_total, code=200, handler=/api/v1/query_range, job=prometheus |
| Type: []time.Time | Type: []*float64 |
+-------------------------------+--------------------------------------------------------------------------------------------------------+
| 2022-01-11 08:25:30 +0000 UTC | 21 |
| 2022-01-11 08:25:31 +0000 UTC | 32 |
| 2022-01-11 08:25:32 +0000 UTC | 43 |
+-------------------------------+--------------------------------------------------------------------------------------------------------+
+-----------------------------------+--------------------------------------------------------------------------------------------------------+
| Name: Time | Name: Value |
| Labels: | Labels: __name__=prometheus_http_requests_total, code=200, handler=/api/v1/query_range, job=prometheus |
| Type: []time.Time | Type: []*float64 |
+-----------------------------------+--------------------------------------------------------------------------------------------------------+
| 2022-01-11 08:25:30.123 +0000 UTC | 21 |
| 2022-01-11 08:25:31.123 +0000 UTC | 32 |
| 2022-01-11 08:25:32.123 +0000 UTC | 43 |
+-----------------------------------+--------------------------------------------------------------------------------------------------------+
@ -28,17 +28,17 @@ Frame[1] {
}
Name: prometheus_http_requests_total{code="400", handler="/api/v1/query_range", job="prometheus"}
Dimensions: 2 Fields by 3 Rows
+-------------------------------+--------------------------------------------------------------------------------------------------------+
| Name: Time | Name: Value |
| Labels: | Labels: __name__=prometheus_http_requests_total, code=400, handler=/api/v1/query_range, job=prometheus |
| Type: []time.Time | Type: []*float64 |
+-------------------------------+--------------------------------------------------------------------------------------------------------+
| 2022-01-11 08:25:30 +0000 UTC | 54 |
| 2022-01-11 08:25:31 +0000 UTC | 65 |
| 2022-01-11 08:25:32 +0000 UTC | 76 |
+-------------------------------+--------------------------------------------------------------------------------------------------------+
+-----------------------------------+--------------------------------------------------------------------------------------------------------+
| Name: Time | Name: Value |
| Labels: | Labels: __name__=prometheus_http_requests_total, code=400, handler=/api/v1/query_range, job=prometheus |
| Type: []time.Time | Type: []*float64 |
+-----------------------------------+--------------------------------------------------------------------------------------------------------+
| 2022-01-11 08:25:30.123 +0000 UTC | 54 |
| 2022-01-11 08:25:31.123 +0000 UTC | 65 |
| 2022-01-11 08:25:32.123 +0000 UTC | 76 |
+-----------------------------------+--------------------------------------------------------------------------------------------------------+
====== TEST DATA RESPONSE (arrow base64) ======
FRAME=QVJST1cxAAD/////oAMAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAAAAAAAEEAAoADAAAAAgABAAKAAAACAAAABQBAAADAAAApAAAACgAAAAEAAAAAP3//wgAAAAMAAAAAAAAAAAAAAAFAAAAcmVmSWQAAAAg/f//CAAAAGQAAABbAAAAcHJvbWV0aGV1c19odHRwX3JlcXVlc3RzX3RvdGFse2NvZGU9IjIwMCIsIGhhbmRsZXI9Ii9hcGkvdjEvcXVlcnlfcmFuZ2UiLCBqb2I9InByb21ldGhldXMifQAEAAAAbmFtZQAAAACY/f//CAAAAFQAAABLAAAAeyJjdXN0b20iOnsicmVzdWx0VHlwZSI6Im1hdHJpeCJ9LCJleGVjdXRlZFF1ZXJ5U3RyaW5nIjoiRXhwcjogXG5TdGVwOiAxcyJ9AAQAAABtZXRhAAAAAAIAAAC0AQAAGAAAAAAAEgAYABQAEwASAAwAAAAIAAQAEgAAABQAAABoAQAAaAEAAAAAAwFoAQAAAwAAALwAAAAsAAAABAAAAEj+//8IAAAAEAAAAAUAAABWYWx1ZQAAAAQAAABuYW1lAAAAAGz+//8IAAAAeAAAAG0AAAB7Il9fbmFtZV9fIjoicHJvbWV0aGV1c19odHRwX3JlcXVlc3RzX3RvdGFsIiwiY29kZSI6IjI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AAAAAAGAAgABgAGAAAAAAADAAQAAABUaW1lAAAAAMgDAABBUlJPVzE=

View File

@ -11,9 +11,9 @@
"job": "prometheus"
},
"values": [
[1641889530, "21"],
[1641889531, "32"],
[1641889532, "43"]
[1641889530.123, "21"],
[1641889531.123, "32"],
[1641889532.123, "43"]
]
},
{
@ -24,9 +24,9 @@
"job": "prometheus"
},
"values": [
[1641889530, "54"],
[1641889531, "65"],
[1641889532, "76"]
[1641889530.123, "54"],
[1641889531.123, "65"],
[1641889532.123, "76"]
]
}
]

View File

@ -328,7 +328,7 @@ func matrixToDataFrames(matrix model.Matrix, query *PrometheusQuery, frames data
valueField := data.NewFieldFromFieldType(data.FieldTypeNullableFloat64, len(v.Values))
for i, k := range v.Values {
timeField.Set(i, time.Unix(k.Timestamp.Unix(), 0).UTC())
timeField.Set(i, k.Timestamp.Time().UTC())
value := float64(k.Value)
if !math.IsNaN(value) {
@ -353,7 +353,7 @@ func matrixToDataFrames(matrix model.Matrix, query *PrometheusQuery, frames data
}
func scalarToDataFrames(scalar *model.Scalar, query *PrometheusQuery, frames data.Frames) data.Frames {
timeVector := []time.Time{time.Unix(scalar.Timestamp.Unix(), 0).UTC()}
timeVector := []time.Time{scalar.Timestamp.Time().UTC()}
values := []float64{float64(scalar.Value)}
name := fmt.Sprintf("%g", values[0])
@ -372,7 +372,7 @@ func vectorToDataFrames(vector model.Vector, query *PrometheusQuery, frames data
for _, v := range vector {
name := formatLegend(v.Metric, query)
tags := make(map[string]string, len(v.Metric))
timeVector := []time.Time{time.Unix(v.Timestamp.Unix(), 0).UTC()}
timeVector := []time.Time{v.Timestamp.Time().UTC()}
values := []float64{float64(v.Value)}
for k, v := range v.Metric {
@ -401,7 +401,7 @@ func exemplarToDataFrames(response []apiv1.ExemplarQueryResult, query *Prometheu
for _, exemplarData := range response {
for _, exemplar := range exemplarData.Exemplars {
event := ExemplarEvent{}
exemplarTime := time.Unix(exemplar.Timestamp.Unix(), 0).UTC()
exemplarTime := exemplar.Timestamp.Time().UTC()
event.Time = exemplarTime
event.Value = float64(exemplar.Value)
event.Labels = make(map[string]string)

View File

@ -731,7 +731,7 @@ func TestPrometheus_parseTimeSeriesResponse(t *testing.T) {
&p.Sample{
Metric: p.Metric{"app": "Application", "tag2": "tag2"},
Value: 1,
Timestamp: 1000,
Timestamp: 123,
},
}
query := &PrometheusQuery{
@ -754,13 +754,14 @@ func TestPrometheus_parseTimeSeriesResponse(t *testing.T) {
// Ensure the timestamps are UTC zoned
testValue := res[0].Fields[0].At(0)
require.Equal(t, "UTC", testValue.(time.Time).Location().String())
require.Equal(t, int64(123), testValue.(time.Time).UnixMilli())
})
t.Run("scalar response should be parsed normally", func(t *testing.T) {
value := make(map[TimeSeriesQueryType]interface{})
value[RangeQueryType] = &p.Scalar{
Value: 1,
Timestamp: 1000,
Timestamp: 123,
}
query := &PrometheusQuery{}
@ -778,6 +779,7 @@ func TestPrometheus_parseTimeSeriesResponse(t *testing.T) {
// Ensure the timestamps are UTC zoned
testValue := res[0].Fields[0].At(0)
require.Equal(t, "UTC", testValue.(time.Time).Location().String())
require.Equal(t, int64(123), testValue.(time.Time).UnixMilli())
})
}