loki: Fix adding refId to rowId (#53932)

This commit is contained in:
Gábor Farkas 2022-08-22 13:09:33 +02:00 committed by GitHub
parent 895616a231
commit 395e443932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 38 deletions

View File

@ -128,7 +128,7 @@ func adjustLogsFrame(frame *data.Frame, query *lokiQuery) error {
// so we send a separate timestamp-as-string field too. it is provided by the
// loki-json-parser-code
idField, err := makeIdField(stringTimeField, lineField, labelsField, frame.RefID)
idField, err := makeIdField(stringTimeField, lineField, labelsField, query.RefID)
if err != nil {
return err
}

View File

@ -66,11 +66,10 @@ func TestAdjustFrame(t *testing.T) {
}),
)
frame.RefID = "A"
query := &lokiQuery{
Expr: `{type="important"}`,
QueryType: QueryTypeRange,
RefID: "A",
}
err := adjustFrame(frame, query)

View File

@ -19,9 +19,9 @@ import (
// but i wanted to test for all of them, to be sure.
func TestSuccessResponse(t *testing.T) {
matrixQuery := lokiQuery{Expr: "up(ALERTS)", Step: time.Second * 42, QueryType: QueryTypeRange, Direction: DirectionBackward}
vectorQuery := lokiQuery{Expr: "query1", QueryType: QueryTypeInstant, Direction: DirectionBackward}
streamsQuery := lokiQuery{Expr: "query1", QueryType: QueryTypeRange, Direction: DirectionBackward}
matrixQuery := lokiQuery{Expr: "up(ALERTS)", Step: time.Second * 42, QueryType: QueryTypeRange, Direction: DirectionBackward, RefID: "mq"}
vectorQuery := lokiQuery{Expr: "query1", QueryType: QueryTypeInstant, Direction: DirectionBackward, RefID: "vq"}
streamsQuery := lokiQuery{Expr: "query1", QueryType: QueryTypeRange, Direction: DirectionBackward, RefID: "sq"}
tt := []struct {
name string

View File

@ -8,16 +8,16 @@
// }
// Name:
// Dimensions: 5 Fields by 4 Rows
// +------------------------------------------------+-------------------------------+----------------+---------------------+-------------------------------+
// | Name: labels | Name: Time | Name: Line | Name: tsNs | Name: id |
// | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []json.RawMessage | Type: []time.Time | Type: []string | Type: []string | Type: []string |
// +------------------------------------------------+-------------------------------+----------------+---------------------+-------------------------------+
// | {"__error__":"LogfmtParserErr","place":"moon"} | 2022-06-17 06:49:51 +0000 UTC | "hello1 | 1655448591000000000 | 1655448591000000000_44cbf4ec_ |
// | {"__error__":"LogfmtParserErr","place":"moon"} | 2022-06-17 06:49:54 +0000 UTC | "hello4 | 1655448594000000000 | 1655448594000000000_408b3f5b_ |
// | {"place":"moon","text":"hello3"} | 2022-06-17 06:49:52 +0000 UTC | text=hello2 | 1655448592000000000 | 1655448592000000000_d1b2086_ |
// | {"place":"moon","text":"hello4"} | 2022-06-17 06:49:53 +0000 UTC | text=hello3 | 1655448593000000000 | 1655448593000000000_45714922_ |
// +------------------------------------------------+-------------------------------+----------------+---------------------+-------------------------------+
// +------------------------------------------------+-------------------------------+----------------+---------------------+---------------------------------+
// | Name: labels | Name: Time | Name: Line | Name: tsNs | Name: id |
// | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []json.RawMessage | Type: []time.Time | Type: []string | Type: []string | Type: []string |
// +------------------------------------------------+-------------------------------+----------------+---------------------+---------------------------------+
// | {"__error__":"LogfmtParserErr","place":"moon"} | 2022-06-17 06:49:51 +0000 UTC | "hello1 | 1655448591000000000 | 1655448591000000000_44cbf4ec_sq |
// | {"__error__":"LogfmtParserErr","place":"moon"} | 2022-06-17 06:49:54 +0000 UTC | "hello4 | 1655448594000000000 | 1655448594000000000_408b3f5b_sq |
// | {"place":"moon","text":"hello3"} | 2022-06-17 06:49:52 +0000 UTC | text=hello2 | 1655448592000000000 | 1655448592000000000_d1b2086_sq |
// | {"place":"moon","text":"hello4"} | 2022-06-17 06:49:53 +0000 UTC | text=hello3 | 1655448593000000000 | 1655448593000000000_45714922_sq |
// +------------------------------------------------+-------------------------------+----------------+---------------------+---------------------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
@ -108,10 +108,10 @@
"1655448593000000000"
],
[
"1655448591000000000_44cbf4ec_",
"1655448594000000000_408b3f5b_",
"1655448592000000000_d1b2086_",
"1655448593000000000_45714922_"
"1655448591000000000_44cbf4ec_sq",
"1655448594000000000_408b3f5b_sq",
"1655448592000000000_d1b2086_sq",
"1655448593000000000_45714922_sq"
]
]
}

View File

@ -116,18 +116,18 @@
// }
// Name:
// Dimensions: 5 Fields by 6 Rows
// +---------------------------------------+-----------------------------------------+------------------+---------------------+---------------------------------+
// | Name: labels | Name: Time | Name: Line | Name: tsNs | Name: id |
// | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []json.RawMessage | Type: []time.Time | Type: []string | Type: []string | Type: []string |
// +---------------------------------------+-----------------------------------------+------------------+---------------------+---------------------------------+
// | {"code":"one\",","location":"moon🌙"} | 2022-02-16 16:50:44.81075712 +0000 UTC | log line error 1 | 1645030244810757120 | 1645030244810757120_1d8c2178_ |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:47.02773504 +0000 UTC | log line info 1 | 1645030247027735040 | 1645030247027735040_87a7aed2_ |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:46.277587968 +0000 UTC | log line info 2 | 1645030246277587968 | 1645030246277587968_318d05c9_ |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:46.277587968 +0000 UTC | log line info 2 | 1645030246277587968 | 1645030246277587968_318d05c9_1_ |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:45.539423744 +0000 UTC | log line info 3 | 1645030245539423744 | 1645030245539423744_fd17f65c_ |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:44.091700992 +0000 UTC | log line info 4 | 1645030244091700992 | 1645030244091700992_62ae07f3_ |
// +---------------------------------------+-----------------------------------------+------------------+---------------------+---------------------------------+
// +---------------------------------------+-----------------------------------------+------------------+---------------------+-----------------------------------+
// | Name: labels | Name: Time | Name: Line | Name: tsNs | Name: id |
// | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []json.RawMessage | Type: []time.Time | Type: []string | Type: []string | Type: []string |
// +---------------------------------------+-----------------------------------------+------------------+---------------------+-----------------------------------+
// | {"code":"one\",","location":"moon🌙"} | 2022-02-16 16:50:44.81075712 +0000 UTC | log line error 1 | 1645030244810757120 | 1645030244810757120_1d8c2178_sq |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:47.02773504 +0000 UTC | log line info 1 | 1645030247027735040 | 1645030247027735040_87a7aed2_sq |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:46.277587968 +0000 UTC | log line info 2 | 1645030246277587968 | 1645030246277587968_318d05c9_sq |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:46.277587968 +0000 UTC | log line info 2 | 1645030246277587968 | 1645030246277587968_318d05c9_1_sq |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:45.539423744 +0000 UTC | log line info 3 | 1645030245539423744 | 1645030245539423744_fd17f65c_sq |
// | {"code":"\",two","location":"moon🌙"} | 2022-02-16 16:50:44.091700992 +0000 UTC | log line info 4 | 1645030244091700992 | 1645030244091700992_62ae07f3_sq |
// +---------------------------------------+-----------------------------------------+------------------+---------------------+-----------------------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
@ -340,12 +340,12 @@
"1645030244091700992"
],
[
"1645030244810757120_1d8c2178_",
"1645030247027735040_87a7aed2_",
"1645030246277587968_318d05c9_",
"1645030246277587968_318d05c9_1_",
"1645030245539423744_fd17f65c_",
"1645030244091700992_62ae07f3_"
"1645030244810757120_1d8c2178_sq",
"1645030247027735040_87a7aed2_sq",
"1645030246277587968_318d05c9_sq",
"1645030246277587968_318d05c9_1_sq",
"1645030245539423744_fd17f65c_sq",
"1645030244091700992_62ae07f3_sq"
]
]
}