loki: fix bug in labels framing (#51015)

This commit is contained in:
Gábor Farkas
2022-06-17 12:50:10 +02:00
committed by GitHub
parent 8745fadb2d
commit fd63ed540f
8 changed files with 330 additions and 0 deletions

View File

@@ -695,6 +695,9 @@ func readStream(iter *jsoniter.Iterator) *backend.DataResponse {
for l1Field := iter.ReadObject(); l1Field != ""; l1Field = iter.ReadObject() {
switch l1Field {
case "stream":
// we need to clear `labels`, because `iter.ReadVal`
// only appends to it
labels := data.Labels{}
iter.ReadVal(&labels)
labelJson, err = labelsToRawJson(labels)
if err != nil {

View File

@@ -32,6 +32,7 @@ func TestReadPromFrames(t *testing.T) {
"prom-exemplars",
"loki-streams-a",
"loki-streams-b",
"loki-streams-c",
}
for _, name := range files {

View File

@@ -0,0 +1,79 @@
// 🌟 This was machine generated. Do not edit. 🌟
//
// Frame[0] {}
// Name:
// Dimensions: 4 Fields by 2 Rows
// +-------------------------+-------------------------------+----------------+---------------------+
// | Name: __labels | Name: Time | Name: Line | Name: TS |
// | Labels: | Labels: | Labels: | Labels: |
// | Type: []json.RawMessage | Type: []time.Time | Type: []string | Type: []string |
// +-------------------------+-------------------------------+----------------+---------------------+
// | {"label1":"value1"} | 2022-06-17 06:49:51 +0000 UTC | text1 | 1655448591000000000 |
// | {"label2":"value2"} | 2022-06-17 06:49:52 +0000 UTC | text2 | 1655448592000000000 |
// +-------------------------+-------------------------------+----------------+---------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
{
"frames": [
{
"schema": {
"meta": {},
"fields": [
{
"name": "__labels",
"type": "other",
"typeInfo": {
"frame": "json.RawMessage"
}
},
{
"name": "Time",
"type": "time",
"typeInfo": {
"frame": "time.Time"
}
},
{
"name": "Line",
"type": "string",
"typeInfo": {
"frame": "string"
}
},
{
"name": "TS",
"type": "string",
"typeInfo": {
"frame": "string"
}
}
]
},
"data": {
"values": [
[
{
"label1": "value1"
},
{
"label2": "value2"
}
],
[
1655448591000,
1655448592000
],
[
"text1",
"text2"
],
[
"1655448591000000000",
"1655448592000000000"
]
]
}
}
]
}

View File

@@ -0,0 +1,79 @@
// 🌟 This was machine generated. Do not edit. 🌟
//
// Frame[0] {}
// Name:
// Dimensions: 4 Fields by 2 Rows
// +-------------------------+-------------------------------+----------------+---------------------+
// | Name: __labels | Name: Time | Name: Line | Name: TS |
// | Labels: | Labels: | Labels: | Labels: |
// | Type: []json.RawMessage | Type: []time.Time | Type: []string | Type: []string |
// +-------------------------+-------------------------------+----------------+---------------------+
// | {"label1":"value1"} | 2022-06-17 06:49:51 +0000 UTC | text1 | 1655448591000000000 |
// | {"label2":"value2"} | 2022-06-17 06:49:52 +0000 UTC | text2 | 1655448592000000000 |
// +-------------------------+-------------------------------+----------------+---------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
{
"frames": [
{
"schema": {
"meta": {},
"fields": [
{
"name": "__labels",
"type": "other",
"typeInfo": {
"frame": "json.RawMessage"
}
},
{
"name": "Time",
"type": "time",
"typeInfo": {
"frame": "time.Time"
}
},
{
"name": "Line",
"type": "string",
"typeInfo": {
"frame": "string"
}
},
{
"name": "TS",
"type": "string",
"typeInfo": {
"frame": "string"
}
}
]
},
"data": {
"values": [
[
{
"label1": "value1"
},
{
"label2": "value2"
}
],
[
1655448591000,
1655448592000
],
[
"text1",
"text2"
],
[
"1655448591000000000",
"1655448592000000000"
]
]
}
}
]
}

View File

@@ -0,0 +1,17 @@
{
"status": "success",
"data": {
"resultType": "streams",
"result": [
{
"stream": { "label1": "value1" },
"values": [["1655448591000000000", "text1"]
]
},
{
"stream": { "label2": "value2"},
"values": [["1655448592000000000", "text2"]]
}
]
}
}