mirror of
https://github.com/grafana/grafana.git
synced 2025-01-09 23:53:25 -06:00
Logs: Fix unresponsive log lines if duplicate ids in Elasticsearch (#68569)
* Logs: Fix duplicate uids by appending series refIds * Fix id generation in loki live streams to be consistent * Update public/app/core/logsModel.ts Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com> * Fix test --------- Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
This commit is contained in:
parent
fcef387151
commit
ee9620e4e0
@ -174,7 +174,7 @@ func makeIdField(stringTimeField *data.Field, lineField *data.Field, labelsField
|
||||
}
|
||||
checksums[sum] = sumCount + 1
|
||||
|
||||
ids[i] = sum + idSuffix + "_" + refId
|
||||
ids[i] = sum + idSuffix
|
||||
}
|
||||
return data.NewField("id", nil, ids), nil
|
||||
}
|
||||
|
@ -83,10 +83,10 @@ func TestAdjustFrame(t *testing.T) {
|
||||
require.Equal(t, "id", idField.Name)
|
||||
require.Equal(t, data.FieldTypeString, idField.Type())
|
||||
require.Equal(t, 4, idField.Len())
|
||||
require.Equal(t, "1641092645000000006_a36f4e1b_A", idField.At(0))
|
||||
require.Equal(t, "1641092705000000006_1d77c9ca_A", idField.At(1))
|
||||
require.Equal(t, "1641092705000000006_1d77c9ca_1_A", idField.At(2))
|
||||
require.Equal(t, "1641092765000000006_948c1a7d_A", idField.At(3))
|
||||
require.Equal(t, "1641092645000000006_a36f4e1b", idField.At(0))
|
||||
require.Equal(t, "1641092705000000006_1d77c9ca", idField.At(1))
|
||||
require.Equal(t, "1641092705000000006_1d77c9ca_1", idField.At(2))
|
||||
require.Equal(t, "1641092765000000006_948c1a7d", idField.At(3))
|
||||
}
|
||||
|
||||
frame := makeFrame()
|
||||
|
@ -12,16 +12,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_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 |
|
||||
// +------------------------------------------------+-------------------------------+----------------+---------------------+---------------------------------+
|
||||
// +------------------------------------------------+-------------------------------+----------------+---------------------+------------------------------+
|
||||
// | 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 |
|
||||
// +------------------------------------------------+-------------------------------+----------------+---------------------+------------------------------+
|
||||
//
|
||||
//
|
||||
// 🌟 This was machine generated. Do not edit. 🌟
|
||||
@ -117,10 +117,10 @@
|
||||
"1655448593000000000"
|
||||
],
|
||||
[
|
||||
"1655448591000000000_44cbf4ec_sq",
|
||||
"1655448594000000000_408b3f5b_sq",
|
||||
"1655448592000000000_d1b2086_sq",
|
||||
"1655448593000000000_45714922_sq"
|
||||
"1655448591000000000_44cbf4ec",
|
||||
"1655448594000000000_408b3f5b",
|
||||
"1655448592000000000_d1b2086",
|
||||
"1655448593000000000_45714922"
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@ -120,18 +120,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_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 |
|
||||
// +---------------------------------------+-----------------------------------------+------------------+---------------------+-----------------------------------+
|
||||
// +---------------------------------------+-----------------------------------------+------------------+---------------------+--------------------------------+
|
||||
// | 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 |
|
||||
// +---------------------------------------+-----------------------------------------+------------------+---------------------+--------------------------------+
|
||||
//
|
||||
//
|
||||
// 🌟 This was machine generated. Do not edit. 🌟
|
||||
@ -349,12 +349,12 @@
|
||||
"1645030244091700992"
|
||||
],
|
||||
[
|
||||
"1645030244810757120_1d8c2178_sq",
|
||||
"1645030247027735040_87a7aed2_sq",
|
||||
"1645030246277587968_318d05c9_sq",
|
||||
"1645030246277587968_318d05c9_1_sq",
|
||||
"1645030245539423744_fd17f65c_sq",
|
||||
"1645030244091700992_62ae07f3_sq"
|
||||
"1645030244810757120_1d8c2178",
|
||||
"1645030247027735040_87a7aed2",
|
||||
"1645030246277587968_318d05c9",
|
||||
"1645030246277587968_318d05c9_1",
|
||||
"1645030245539423744_fd17f65c",
|
||||
"1645030244091700992_62ae07f3"
|
||||
]
|
||||
],
|
||||
"nanos": [
|
||||
|
@ -12,16 +12,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_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 |
|
||||
// +------------------------------------------------+-------------------------------+----------------+---------------------+---------------------------------+
|
||||
// +------------------------------------------------+-------------------------------+----------------+---------------------+------------------------------+
|
||||
// | 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 |
|
||||
// +------------------------------------------------+-------------------------------+----------------+---------------------+------------------------------+
|
||||
//
|
||||
//
|
||||
// 🌟 This was machine generated. Do not edit. 🌟
|
||||
@ -117,10 +117,10 @@
|
||||
"1655448593000000000"
|
||||
],
|
||||
[
|
||||
"1655448591000000000_44cbf4ec_sq",
|
||||
"1655448594000000000_408b3f5b_sq",
|
||||
"1655448592000000000_d1b2086_sq",
|
||||
"1655448593000000000_45714922_sq"
|
||||
"1655448591000000000_44cbf4ec",
|
||||
"1655448594000000000_408b3f5b",
|
||||
"1655448592000000000_d1b2086",
|
||||
"1655448593000000000_45714922"
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@ -120,18 +120,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_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 |
|
||||
// +---------------------------------------+-----------------------------------------+------------------+---------------------+-----------------------------------+
|
||||
// +---------------------------------------+-----------------------------------------+------------------+---------------------+--------------------------------+
|
||||
// | 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 |
|
||||
// +---------------------------------------+-----------------------------------------+------------------+---------------------+--------------------------------+
|
||||
//
|
||||
//
|
||||
// 🌟 This was machine generated. Do not edit. 🌟
|
||||
@ -349,12 +349,12 @@
|
||||
"1645030244091700992"
|
||||
],
|
||||
[
|
||||
"1645030244810757120_1d8c2178_sq",
|
||||
"1645030247027735040_87a7aed2_sq",
|
||||
"1645030246277587968_318d05c9_sq",
|
||||
"1645030246277587968_318d05c9_1_sq",
|
||||
"1645030245539423744_fd17f65c_sq",
|
||||
"1645030244091700992_62ae07f3_sq"
|
||||
"1645030244810757120_1d8c2178",
|
||||
"1645030247027735040_87a7aed2",
|
||||
"1645030246277587968_318d05c9",
|
||||
"1645030246277587968_318d05c9_1",
|
||||
"1645030245539423744_fd17f65c",
|
||||
"1645030244091700992_62ae07f3"
|
||||
]
|
||||
],
|
||||
"nanos": [
|
||||
|
@ -299,6 +299,7 @@ describe('dataFrameToLogsModel', () => {
|
||||
meta: {
|
||||
limit: 1000,
|
||||
},
|
||||
refId: 'A',
|
||||
}),
|
||||
];
|
||||
const logsModel = dataFrameToLogsModel(series, 1);
|
||||
@ -310,14 +311,14 @@ describe('dataFrameToLogsModel', () => {
|
||||
labels: { filename: '/var/log/grafana/grafana.log', job: 'grafana' },
|
||||
logLevel: 'info',
|
||||
uniqueLabels: {},
|
||||
uid: 'foo',
|
||||
uid: 'A_foo',
|
||||
},
|
||||
{
|
||||
entry: 't=2019-04-26T16:42:50+0200 lvl=eror msg="new token…t unhashed token=56d9fdc5c8b7400bd51b060eea8ca9d7',
|
||||
labels: { filename: '/var/log/grafana/grafana.log', job: 'grafana' },
|
||||
logLevel: 'error',
|
||||
uniqueLabels: {},
|
||||
uid: 'bar',
|
||||
uid: 'A_bar',
|
||||
},
|
||||
]);
|
||||
|
||||
@ -439,6 +440,7 @@ describe('dataFrameToLogsModel', () => {
|
||||
frameType: 'LabeledTimeValues',
|
||||
},
|
||||
},
|
||||
refId: 'A',
|
||||
}),
|
||||
];
|
||||
const logsModel = dataFrameToLogsModel(series, 1);
|
||||
@ -450,14 +452,14 @@ describe('dataFrameToLogsModel', () => {
|
||||
labels: { filename: '/var/log/grafana/grafana.log', job: 'grafana' },
|
||||
logLevel: 'info',
|
||||
uniqueLabels: {},
|
||||
uid: 'foo',
|
||||
uid: 'A_foo',
|
||||
},
|
||||
{
|
||||
entry: 't=2019-04-26T16:42:50+0200 lvl=eror msg="new token…t unhashed token=56d9fdc5c8b7400bd51b060eea8ca9d7',
|
||||
labels: { filename: '/var/log/grafana/grafana.log', job: 'grafana' },
|
||||
logLevel: 'error',
|
||||
uniqueLabels: {},
|
||||
uid: 'bar',
|
||||
uid: 'A_bar',
|
||||
},
|
||||
]);
|
||||
|
||||
@ -583,6 +585,7 @@ describe('dataFrameToLogsModel', () => {
|
||||
error: 'Error when parsing some of the logs',
|
||||
},
|
||||
},
|
||||
refId: 'A',
|
||||
}),
|
||||
];
|
||||
const logsModel = dataFrameToLogsModel(series, 1);
|
||||
@ -594,14 +597,14 @@ describe('dataFrameToLogsModel', () => {
|
||||
labels: { filename: '/var/log/grafana/grafana.log', job: 'grafana', __error__: 'Failed while parsing' },
|
||||
logLevel: 'info',
|
||||
uniqueLabels: {},
|
||||
uid: 'foo',
|
||||
uid: 'A_foo',
|
||||
},
|
||||
{
|
||||
entry: 't=2019-04-26T16:42:50+0200 lvl=eror msg="new token…t unhashed token=56d9fdc5c8b7400bd51b060eea8ca9d7',
|
||||
labels: { filename: '/var/log/grafana/grafana.log', job: 'grafana', __error__: 'Failed while parsing' },
|
||||
logLevel: 'error',
|
||||
uniqueLabels: {},
|
||||
uid: 'bar',
|
||||
uid: 'A_bar',
|
||||
},
|
||||
]);
|
||||
|
||||
@ -658,6 +661,54 @@ describe('dataFrameToLogsModel', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('given multiple series with duplicate results it should return unique uids', () => {
|
||||
const series: DataFrame[] = [
|
||||
toDataFrame({
|
||||
refId: 'A',
|
||||
fields: [
|
||||
{
|
||||
name: 'ts',
|
||||
type: FieldType.time,
|
||||
values: ['1970-01-01T00:00:01Z'],
|
||||
},
|
||||
{
|
||||
name: 'line',
|
||||
type: FieldType.string,
|
||||
values: ['WARN boooo'],
|
||||
},
|
||||
{
|
||||
name: 'id',
|
||||
type: FieldType.string,
|
||||
values: ['duplicate_uid'],
|
||||
},
|
||||
],
|
||||
}),
|
||||
toDataFrame({
|
||||
refId: 'B',
|
||||
fields: [
|
||||
{
|
||||
name: 'ts',
|
||||
type: FieldType.time,
|
||||
values: ['1970-01-01T00:00:01Z'],
|
||||
},
|
||||
{
|
||||
name: 'line',
|
||||
type: FieldType.string,
|
||||
values: ['WARN boooo'],
|
||||
},
|
||||
{
|
||||
name: 'id',
|
||||
type: FieldType.string,
|
||||
values: ['duplicate_uid'],
|
||||
},
|
||||
],
|
||||
}),
|
||||
];
|
||||
const logsModel = dataFrameToLogsModel(series, 1);
|
||||
const uids = logsModel.rows.map((row) => row.uid);
|
||||
expect(uids).toEqual(['A_duplicate_uid', 'B_duplicate_uid']);
|
||||
});
|
||||
|
||||
it('given multiple series with unique times should return expected logs model', () => {
|
||||
const series: DataFrame[] = [
|
||||
toDataFrame({
|
||||
@ -916,6 +967,7 @@ describe('dataFrameToLogsModel', () => {
|
||||
it('should fallback to row index if no id', () => {
|
||||
const series: DataFrame[] = [
|
||||
toDataFrame({
|
||||
refId: 'A',
|
||||
labels: { foo: 'bar' },
|
||||
fields: [
|
||||
{
|
||||
@ -932,7 +984,7 @@ describe('dataFrameToLogsModel', () => {
|
||||
}),
|
||||
];
|
||||
const logsModel = dataFrameToLogsModel(series, 1);
|
||||
expect(logsModel.rows[0].uid).toBe('0');
|
||||
expect(logsModel.rows[0].uid).toBe('A_0');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -459,7 +459,8 @@ export function logSeriesToLogsModel(logSeries: DataFrame[], queries: DataQuery[
|
||||
entry,
|
||||
raw: message,
|
||||
labels: labels || {},
|
||||
uid: idField ? idField.values[j] : j.toString(),
|
||||
// prepend refId to uid to make it unique across all series in a case when series contain duplicates
|
||||
uid: `${series.refId}_${idField ? idField.values[j] : j.toString()}`,
|
||||
datasourceType,
|
||||
});
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ describe('Live Stream Tests', () => {
|
||||
const last = { ...view.get(view.length - 1) };
|
||||
expect(last).toEqual({
|
||||
Time: '2019-08-28T20:50:40.118Z',
|
||||
id: '25d81461-a66f-53ff-98d5-e39515af4735_A',
|
||||
id: 'A_25d81461-a66f-53ff-98d5-e39515af4735',
|
||||
Line: 'Kittens',
|
||||
});
|
||||
},
|
||||
|
@ -63,12 +63,12 @@ describe('loki result transformer', () => {
|
||||
data.refId = 'C';
|
||||
|
||||
ResultTransformer.appendResponseToBufferedData(tailResponse, data);
|
||||
expect(data.get(0).id).toEqual('75e72b25-8589-5f99-8d10-ccb5eb27c1b4_C');
|
||||
expect(data.get(1).id).toEqual('75e72b25-8589-5f99-8d10-ccb5eb27c1b4_1_C');
|
||||
expect(data.get(2).id).toEqual('3ca99d6b-3ab5-5970-93c0-eb3c9449088e_C');
|
||||
expect(data.get(3).id).toEqual('ec9bea1d-70cb-556c-8519-d5d6ae18c004_C');
|
||||
expect(data.get(4).id).toEqual('75e72b25-8589-5f99-8d10-ccb5eb27c1b4_2_C');
|
||||
expect(data.get(5).id).toEqual('3ca99d6b-3ab5-5970-93c0-eb3c9449088e_1_C');
|
||||
expect(data.get(0).id).toEqual('C_75e72b25-8589-5f99-8d10-ccb5eb27c1b4');
|
||||
expect(data.get(1).id).toEqual('C_75e72b25-8589-5f99-8d10-ccb5eb27c1b4_1');
|
||||
expect(data.get(2).id).toEqual('C_3ca99d6b-3ab5-5970-93c0-eb3c9449088e');
|
||||
expect(data.get(3).id).toEqual('C_ec9bea1d-70cb-556c-8519-d5d6ae18c004');
|
||||
expect(data.get(4).id).toEqual('C_75e72b25-8589-5f99-8d10-ccb5eb27c1b4_2');
|
||||
expect(data.get(5).id).toEqual('C_3ca99d6b-3ab5-5970-93c0-eb3c9449088e_1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -69,7 +69,7 @@ function createUid(
|
||||
}
|
||||
// Return unique id
|
||||
if (refId) {
|
||||
return `${id}_${refId}`;
|
||||
return `${refId}_${id}`;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user