mirror of
https://github.com/grafana/grafana.git
synced 2025-01-09 23:53:25 -06:00
Loki: add from JSON to dataframes tests (#44375)
* Loki: add from JSON to dataframes tests * fixed wrong content-type * added -Inf test-case
This commit is contained in:
parent
ea48d131ee
commit
b42161a713
138
pkg/tsdb/loki/framing_test.go
Normal file
138
pkg/tsdb/loki/framing_test.go
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
package loki
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||||
|
"github.com/grafana/grafana-plugin-sdk-go/experimental"
|
||||||
|
"github.com/grafana/loki/pkg/logcli/client"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NOTE: in these tests there several different json-content-types.
|
||||||
|
// different versions of Loki use different json-content-types.
|
||||||
|
// this is probably not important when we will parse them,
|
||||||
|
// but i wanted to test for all of them, to be sure.
|
||||||
|
|
||||||
|
func TestSuccessResponse(t *testing.T) {
|
||||||
|
tt := []struct {
|
||||||
|
name string
|
||||||
|
filepath string
|
||||||
|
}{
|
||||||
|
{name: "parse a simple matrix response", filepath: "matrix_simple"},
|
||||||
|
{name: "parse a matrix response with a time-gap in the middle", filepath: "matrix_gap"},
|
||||||
|
// you can produce NaN by having a metric query and add ` / 0` to the end
|
||||||
|
{name: "parse a matrix response with NaN", filepath: "matrix_nan"},
|
||||||
|
// you can produce Infinity by using `quantile_over_time(42,` (value larger than 1)
|
||||||
|
{name: "parse a matrix response with Infinity", filepath: "matrix_inf"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tt {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
responseFileName := filepath.Join("testdata", test.filepath+".json")
|
||||||
|
goldenFileName := filepath.Join("testdata", test.filepath+".golden.txt")
|
||||||
|
|
||||||
|
bytes, err := os.ReadFile(responseFileName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
frames, err := runQuery(makeMockedClient(200, "application/json", bytes), &lokiQuery{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
dr := &backend.DataResponse{
|
||||||
|
Frames: frames,
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = experimental.CheckGoldenDataResponse(goldenFileName, dr, true)
|
||||||
|
require.NoError(t, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestErrorResponse(t *testing.T) {
|
||||||
|
// NOTE: when there is an error-response, it comes with
|
||||||
|
// HTTP code 400, and the format seems to change between versions:
|
||||||
|
// 2.3.x: content-type=text/plain, content is plaintext
|
||||||
|
// 2.4.0: content-type=application/json, content is plaintext !!!
|
||||||
|
// 2.4.1: same as 2.4.0
|
||||||
|
// 2.4.2: same as 2.4.0 (2.4.2 is currently the latest)
|
||||||
|
// main-branch: content-type=application/json, content is JSON
|
||||||
|
// we should always be able to to return some kind of error message
|
||||||
|
//
|
||||||
|
// also, the returned error message is not what we want to return
|
||||||
|
// to the user, but this is what is currently returned to the user,
|
||||||
|
// so the tests check for that. we will have to change this in the future.
|
||||||
|
|
||||||
|
tt := []struct {
|
||||||
|
name string
|
||||||
|
body []byte
|
||||||
|
contentType string
|
||||||
|
errorMessage string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "parse an error response in JSON",
|
||||||
|
body: []byte(`
|
||||||
|
{
|
||||||
|
"status": "error",
|
||||||
|
"code": 400,
|
||||||
|
"message": "parse error at line 1, col 8: something is wrong"
|
||||||
|
}`),
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
errorMessage: "Run out of attempts while querying the server",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "parse a non-json error body with json content type (loki 2.4.0,2.4.1,2.4.2)",
|
||||||
|
body: []byte("parse error at line 1, col 8: something is wrong"),
|
||||||
|
contentType: "application/json; charset=UTF-8",
|
||||||
|
errorMessage: "Run out of attempts while querying the server",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "parse an error response in plain text",
|
||||||
|
body: []byte("parse error at line 1, col 8: something is wrong"),
|
||||||
|
contentType: "text/plain; charset=utf-8",
|
||||||
|
errorMessage: "Run out of attempts while querying the server",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tt {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
frames, err := runQuery(makeMockedClient(400, test.contentType, test.body), &lokiQuery{})
|
||||||
|
|
||||||
|
require.Len(t, frames, 0)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.EqualError(t, err, test.errorMessage)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type MockedRoundTripper struct {
|
||||||
|
statusCode int
|
||||||
|
responseBytes []byte
|
||||||
|
contentType string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mockedRT *MockedRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
header := http.Header{}
|
||||||
|
header.Add("Content-Type", mockedRT.contentType)
|
||||||
|
return &http.Response{
|
||||||
|
StatusCode: mockedRT.statusCode,
|
||||||
|
Header: header,
|
||||||
|
Body: ioutil.NopCloser(bytes.NewReader(mockedRT.responseBytes)),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeMockedClient(statusCode int, contentType string, responseBytes []byte) *client.DefaultClient {
|
||||||
|
client := &client.DefaultClient{
|
||||||
|
Address: "http://localhost:9999",
|
||||||
|
Tripperware: func(t http.RoundTripper) http.RoundTripper {
|
||||||
|
return &MockedRoundTripper{statusCode: statusCode, responseBytes: responseBytes, contentType: contentType}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return client
|
||||||
|
}
|
@ -131,19 +131,7 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
|||||||
span.SetAttributes("stop_unixnano", query.End, attribute.Key("stop_unixnano").Int64(query.End.UnixNano()))
|
span.SetAttributes("stop_unixnano", query.End, attribute.Key("stop_unixnano").Int64(query.End.UnixNano()))
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
// `limit` only applies to log-producing queries, and we
|
frames, err := runQuery(client, query)
|
||||||
// currently only support metric queries, so this can be set to any value.
|
|
||||||
limit := 1
|
|
||||||
|
|
||||||
// we do not use `interval`, so we set it to zero
|
|
||||||
interval := time.Duration(0)
|
|
||||||
|
|
||||||
value, err := client.QueryRange(query.Expr, limit, query.Start, query.End, logproto.BACKWARD, query.Step, interval, false)
|
|
||||||
if err != nil {
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
frames, err := parseResponse(value, query)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@ -204,6 +192,23 @@ func parseResponse(value *loghttp.QueryResponse, query *lokiQuery) (data.Frames,
|
|||||||
return frames, nil
|
return frames, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we extracted this part of the functionality to make it easy to unit-test it
|
||||||
|
func runQuery(client *client.DefaultClient, query *lokiQuery) (data.Frames, error) {
|
||||||
|
// `limit` only applies to log-producing queries, and we
|
||||||
|
// currently only support metric queries, so this can be set to any value.
|
||||||
|
limit := 1
|
||||||
|
|
||||||
|
// we do not use `interval`, so we set it to zero
|
||||||
|
interval := time.Duration(0)
|
||||||
|
|
||||||
|
value, err := client.QueryRange(query.Expr, limit, query.Start, query.End, logproto.BACKWARD, query.Step, interval, false)
|
||||||
|
if err != nil {
|
||||||
|
return data.Frames{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseResponse(value, query)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Service) getDSInfo(pluginCtx backend.PluginContext) (*datasourceInfo, error) {
|
func (s *Service) getDSInfo(pluginCtx backend.PluginContext) (*datasourceInfo, error) {
|
||||||
i, err := s.im.Get(pluginCtx)
|
i, err := s.im.Get(pluginCtx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
21
pkg/tsdb/loki/testdata/matrix_gap.golden.txt
vendored
Normal file
21
pkg/tsdb/loki/testdata/matrix_gap.golden.txt
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
🌟 This was machine generated. Do not edit. 🌟
|
||||||
|
|
||||||
|
Frame[0]
|
||||||
|
Name: {}
|
||||||
|
Dimensions: 2 Fields by 6 Rows
|
||||||
|
+-------------------------------+-----------------+
|
||||||
|
| Name: time | Name: value |
|
||||||
|
| Labels: | Labels: |
|
||||||
|
| Type: []time.Time | Type: []float64 |
|
||||||
|
+-------------------------------+-----------------+
|
||||||
|
| 2022-01-24 08:54:13 +0000 UTC | 50 |
|
||||||
|
| 2022-01-24 08:59:13 +0000 UTC | 57 |
|
||||||
|
| 2022-01-24 09:04:13 +0000 UTC | 55 |
|
||||||
|
| 2022-01-24 09:34:13 +0000 UTC | 54 |
|
||||||
|
| 2022-01-24 09:39:13 +0000 UTC | 55 |
|
||||||
|
| 2022-01-24 09:44:13 +0000 UTC | 56 |
|
||||||
|
+-------------------------------+-----------------+
|
||||||
|
|
||||||
|
|
||||||
|
====== TEST DATA RESPONSE (arrow base64) ======
|
||||||
|
FRAME=QVJST1cxAAD/////yAEAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAAAAAAAEEAAoADAAAAAgABAAKAAAACAAAAFAAAAACAAAAKAAAAAQAAADI/v//CAAAAAwAAAAAAAAAAAAAAAUAAAByZWZJZAAAAOj+//8IAAAADAAAAAIAAAB7fQAABAAAAG5hbWUAAAAAAgAAANQAAAAEAAAARv///xQAAACcAAAAnAAAAAAAAAOcAAAAAwAAAFAAAAAsAAAABAAAADz///8IAAAAEAAAAAUAAAB2YWx1ZQAAAAQAAABuYW1lAAAAAGD///8IAAAADAAAAAIAAAB7fQAABgAAAGxhYmVscwAAgP///wgAAAAkAAAAGgAAA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AAYAAABjb25maWcAAAAAAACK////AAACAAUAAAB2YWx1ZQASABgAFAAAABMADAAAAAgABAASAAAAFAAAAEQAAABMAAAAAAAACkwAAAABAAAADAAAAAgADAAIAAQACAAAAAgAAAAQAAAABAAAAHRpbWUAAAAABAAAAG5hbWUAAAAAAAAAAAAABgAIAAYABgAAAAAAAwAEAAAAdGltZQAAAADwAQAAQVJST1cx
|
19
pkg/tsdb/loki/testdata/matrix_gap.json
vendored
Normal file
19
pkg/tsdb/loki/testdata/matrix_gap.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"status": "success",
|
||||||
|
"data": {
|
||||||
|
"resultType": "matrix",
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"metric": {},
|
||||||
|
"values": [
|
||||||
|
[1643014453.815, "50"],
|
||||||
|
[1643014753.815, "57"],
|
||||||
|
[1643015053.815, "55"],
|
||||||
|
[1643016853.815, "54"],
|
||||||
|
[1643017153.815, "55"],
|
||||||
|
[1643017453.815, "56"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
17
pkg/tsdb/loki/testdata/matrix_inf.golden.txt
vendored
Normal file
17
pkg/tsdb/loki/testdata/matrix_inf.golden.txt
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
🌟 This was machine generated. Do not edit. 🌟
|
||||||
|
|
||||||
|
Frame[0]
|
||||||
|
Name: {level="info", location="moon", protocol="http"}
|
||||||
|
Dimensions: 2 Fields by 2 Rows
|
||||||
|
+-------------------------------+--------------------------------------------------+
|
||||||
|
| Name: time | Name: value |
|
||||||
|
| Labels: | Labels: level=info, location=moon, protocol=http |
|
||||||
|
| Type: []time.Time | Type: []float64 |
|
||||||
|
+-------------------------------+--------------------------------------------------+
|
||||||
|
| 2022-01-24 10:53:31 +0000 UTC | +Inf |
|
||||||
|
| 2022-01-24 10:58:31 +0000 UTC | -Inf |
|
||||||
|
+-------------------------------+--------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
====== TEST DATA RESPONSE (arrow base64) ======
|
||||||
|
FRAME=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
|
19
pkg/tsdb/loki/testdata/matrix_inf.json
vendored
Normal file
19
pkg/tsdb/loki/testdata/matrix_inf.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"status": "success",
|
||||||
|
"data": {
|
||||||
|
"resultType": "matrix",
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"metric": {
|
||||||
|
"level": "info",
|
||||||
|
"location": "moon",
|
||||||
|
"protocol": "http"
|
||||||
|
},
|
||||||
|
"values": [
|
||||||
|
[1643021611.9, "+Inf"],
|
||||||
|
[1643021911.9, "-Inf"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
17
pkg/tsdb/loki/testdata/matrix_nan.golden.txt
vendored
Normal file
17
pkg/tsdb/loki/testdata/matrix_nan.golden.txt
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
🌟 This was machine generated. Do not edit. 🌟
|
||||||
|
|
||||||
|
Frame[0]
|
||||||
|
Name: {}
|
||||||
|
Dimensions: 2 Fields by 2 Rows
|
||||||
|
+-------------------------------+-----------------+
|
||||||
|
| Name: time | Name: value |
|
||||||
|
| Labels: | Labels: |
|
||||||
|
| Type: []time.Time | Type: []float64 |
|
||||||
|
+-------------------------------+-----------------+
|
||||||
|
| 2022-01-24 08:54:10 +0000 UTC | NaN |
|
||||||
|
| 2022-01-24 08:59:10 +0000 UTC | NaN |
|
||||||
|
+-------------------------------+-----------------+
|
||||||
|
|
||||||
|
|
||||||
|
====== TEST DATA RESPONSE (arrow base64) ======
|
||||||
|
FRAME=QVJST1cxAAD/////yAEAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAAAAAAAEEAAoADAAAAAgABAAKAAAACAAAAFAAAAACAAAAKAAAAAQAAADI/v//CAAAAAwAAAAAAAAAAAAAAAUAAAByZWZJZAAAAOj+//8IAAAADAAAAAIAAAB7fQAABAAAAG5hbWUAAAAAAgAAANQAAAAEAAAARv///xQAAACcAAAAnAAAAAAAAAOcAAAAAwAAAFAAAAAsAAAABAAAADz///8IAAAAEAAAAAUAAAB2YWx1ZQAAAAQAAABuYW1lAAAAAGD///8IAAAADAAAAAIAAAB7fQAABgAAAGxhYmVscwAAgP///wgAAAAkAAAAGgAAAHs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AAKTAAAAAEAAAAMAAAACAAMAAgABAAIAAAACAAAABAAAAAEAAAAdGltZQAAAAAEAAAAbmFtZQAAAAAAAAAAAAAGAAgABgAGAAAAAAADAAQAAAB0aW1lAAAAAPABAABBUlJPVzE=
|
15
pkg/tsdb/loki/testdata/matrix_nan.json
vendored
Normal file
15
pkg/tsdb/loki/testdata/matrix_nan.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"status": "success",
|
||||||
|
"data": {
|
||||||
|
"resultType": "matrix",
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"metric": {},
|
||||||
|
"values": [
|
||||||
|
[1643014450.417, "NaN"],
|
||||||
|
[1643014750.417, "NaN"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
37
pkg/tsdb/loki/testdata/matrix_simple.golden.txt
vendored
Normal file
37
pkg/tsdb/loki/testdata/matrix_simple.golden.txt
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
🌟 This was machine generated. Do not edit. 🌟
|
||||||
|
|
||||||
|
Frame[0]
|
||||||
|
Name: {level="error", location="moon"}
|
||||||
|
Dimensions: 2 Fields by 4 Rows
|
||||||
|
+-------------------------------+------------------------------------+
|
||||||
|
| Name: time | Name: value |
|
||||||
|
| Labels: | Labels: level=error, location=moon |
|
||||||
|
| Type: []time.Time | Type: []float64 |
|
||||||
|
+-------------------------------+------------------------------------+
|
||||||
|
| 2021-12-10 08:36:06 +0000 UTC | 0.4 |
|
||||||
|
| 2021-12-10 08:36:46 +0000 UTC | 0.2 |
|
||||||
|
| 2021-12-10 08:36:56 +0000 UTC | 0.2 |
|
||||||
|
| 2021-12-10 08:37:46 +0000 UTC | 0.6 |
|
||||||
|
+-------------------------------+------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Frame[1]
|
||||||
|
Name: {level="info", location="mars"}
|
||||||
|
Dimensions: 2 Fields by 5 Rows
|
||||||
|
+-------------------------------+-----------------------------------+
|
||||||
|
| Name: time | Name: value |
|
||||||
|
| Labels: | Labels: level=info, location=mars |
|
||||||
|
| Type: []time.Time | Type: []float64 |
|
||||||
|
+-------------------------------+-----------------------------------+
|
||||||
|
| 2021-12-10 08:36:26 +0000 UTC | 0.6 |
|
||||||
|
| 2021-12-10 08:36:36 +0000 UTC | 0.8 |
|
||||||
|
| 2021-12-10 08:36:46 +0000 UTC | 0.8 |
|
||||||
|
| 2021-12-10 08:36:56 +0000 UTC | 0.8 |
|
||||||
|
| 2021-12-10 08:37:56 +0000 UTC | 2.6 |
|
||||||
|
+-------------------------------+-----------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
====== TEST DATA RESPONSE (arrow base64) ======
|
||||||
|
FRAME=QVJST1cxAAD/////KAIAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAAAAAAAEDAAoADAAAAAgABAAKAAAACAAAAHAAAAACAAAAKAAAAAQAAABk/v//CAAAAAwAAAAAAAAAAAAAAAUAAAByZWZJZAAAAIT+//8IAAAALAAAACAAAAB7bGV2ZWw9ImVycm9yIiwgbG9jYXRpb249Im1vb24ifQAAAAAEAAAAbmFtZQAAAAACAAAAGAEAAAQAAAAC////FAAAAOAAAADgAAAAAAAAA+AAAAADAAAAcAAAACwAAAAEAAAA+P7//wgAAAAQAAAABQAAAHZhbHVlAAAABAAAAG5hbWUAAAAAHP///wgAAAAsAAAAIwAAAHsibGV2ZWwiOiJlcnJvciIsImxvY2F0aW9uIjoibW9vbiJ9AAYAAABsYWJlbHMAAFz///8IAAAASAAAADwAAAB7ImRpc3BsYXlOYW1lRnJvbURTIjoie2xldmVsPVwiZXJyb3JcIiwgbG9jYXRpb249XCJtb29uXCJ9In0AAAAABgAAAGNvbmZpZwAAAAAAAIr///8AAAIABQAAAHZhbHVlABIAGAAUAAAAEwAMAAAACAAEABIAAAAUAAAARAAAAEwAAAAAAAAKTAAAAAEAAAAMAAAACAAMAAgABAAIAAAACAAAABAAAAAEAAAAdGltZ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AAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAA5Nqm2le/FgDI5vrcV78WAKzyTt9XvxYAkP6i4Ve/FgDoRZvvV78WMzMzMzMz4z+amZmZmZnpP5qZmZmZmek/mpmZmZmZ6T/NzMzMzMwEQBAAAAAMABQAEgAMAAgABAAMAAAAEAAAACwAAAA8AAAAAAADAAEAAAAwAgAAAAAAAMAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoADAAAAAgABAAKAAAACAAAAGwAAAACAAAAKAAAAAQAAABs/v//CAAAAAwAAAAAAAAAAAAAAAUAAAByZWZJZAAAAIz+//8IAAAAKAAAAB8AAAB7bGV2ZWw9ImluZm8iLCBsb2NhdGlvbj0ibWFycyJ9AAQAAABuYW1lAAAAAAIAAAAUAQAABAAAAAb///8UAAAA3AAAANwAAAAAAAAD3AAAAAMAAABwAAAALAAAAAQAAAD8/v//CAAAABAAAAAFAAAAdmFsdWUAAAAEAAAAbmFtZQAAAAAg////CAAAACwAAAAiAAAAeyJsZXZlbCI6ImluZm8iLCJsb2NhdGlvbiI6Im1hcnMifQAABgAAAGxhYmVscwAAYP///wgAAABEAAAAOwAAAHsiZGlzcGxheU5hbWVGcm9tRFMiOiJ7bGV2ZWw9XCJpbmZvXCIsIGxvY2F0aW9uPVwibWFyc1wifSJ9AAYAAABjb25maWcAAAAAAACK////AAACAAUAAAB2YWx1ZQASABgAFAAAABMADAAAAAgABAASAAAAFAAAAEQAAABMAAAAAAAACkwAAAABAAAADAAAAAgADAAIAAQACAAAAAgAAAAQAAAABAAAAHRpbWUAAAAABAAAAG5hbWUAAAAAAAAAAAAABgAIAAYABgAAAAAAAwAEAAAAdGltZQAAAABQAgAAQVJST1cx
|
33
pkg/tsdb/loki/testdata/matrix_simple.json
vendored
Normal file
33
pkg/tsdb/loki/testdata/matrix_simple.json
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"status": "success",
|
||||||
|
"data": {
|
||||||
|
"resultType": "matrix",
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"metric": {
|
||||||
|
"level": "error",
|
||||||
|
"location": "moon"
|
||||||
|
},
|
||||||
|
"values": [
|
||||||
|
[1639125366.989, "0.4"],
|
||||||
|
[1639125406.989, "0.2"],
|
||||||
|
[1639125416.989, "0.2"],
|
||||||
|
[1639125466.989, "0.6"]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"metric": {
|
||||||
|
"level": "info",
|
||||||
|
"location": "mars"
|
||||||
|
},
|
||||||
|
"values": [
|
||||||
|
[1639125386.989, "0.6"],
|
||||||
|
[1639125396.989, "0.8"],
|
||||||
|
[1639125406.989, "0.8"],
|
||||||
|
[1639125416.989, "0.8"],
|
||||||
|
[1639125476.989, "2.6"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user