Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
003fb4a3
Unverified
Commit
003fb4a3
authored
Feb 12, 2020
by
kay delaney
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Datasource/Loki: Fixes issue where live tailing displayed date as invalid (#22128)
Closes #21929
parent
cfe30080
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 deletions
+40
-4
public/app/plugins/datasource/loki/result_transformer.test.ts
+39
-3
public/app/plugins/datasource/loki/result_transformer.ts
+1
-1
No files found.
public/app/plugins/datasource/loki/result_transformer.test.ts
View file @
003fb4a3
import
{
FieldType
,
MutableDataFrame
}
from
'@grafana/data'
;
import
{
LokiLegacyStreamResult
,
LokiStreamResult
}
from
'./types'
;
import
{
FieldType
,
MutableDataFrame
,
CircularDataFrame
}
from
'@grafana/data'
;
import
{
LokiLegacyStreamResult
,
LokiStreamResult
,
LokiTailResponse
}
from
'./types'
;
import
*
as
ResultTransformer
from
'./result_transformer'
;
const
legacyStreamResult
:
LokiLegacyStreamResult
[]
=
[
...
...
@@ -127,7 +127,7 @@ describe('loki result transformer', () => {
});
describe
(
'appendResponseToBufferedData'
,
()
=>
{
it
(
'
appends
response'
,
()
=>
{
it
(
'
should append
response'
,
()
=>
{
const
data
=
new
MutableDataFrame
();
data
.
addField
({
name
:
'ts'
,
type
:
FieldType
.
time
,
config
:
{
title
:
'Time'
}
});
data
.
addField
({
name
:
'line'
,
type
:
FieldType
.
string
});
...
...
@@ -142,5 +142,41 @@ describe('loki result transformer', () => {
id
:
'2764544e18dbc3fcbeee21a573e8cd1b'
,
});
});
it
(
'should return a dataframe with ts in iso format'
,
()
=>
{
const
tailResponse
:
LokiTailResponse
=
{
streams
:
[
{
stream
:
{
filename
:
'/var/log/grafana/grafana.log'
,
job
:
'grafana'
,
},
values
:
[
[
'1581519914265798400'
,
't=2020-02-12T15:04:51+0000 lvl=info msg="Starting Grafana" logger=server version=6.7.0-pre commit=6f09bc9fb4 branch=issue-21929 compiled=2020-02-11T20:43:28+0000'
,
],
],
},
],
};
const
data
=
new
CircularDataFrame
({
capacity
:
1
});
data
.
addField
({
name
:
'ts'
,
type
:
FieldType
.
time
,
config
:
{
title
:
'Time'
}
});
data
.
addField
({
name
:
'tsNs'
,
type
:
FieldType
.
time
,
config
:
{
title
:
'Time ns'
}
});
data
.
addField
({
name
:
'line'
,
type
:
FieldType
.
string
}).
labels
=
{
job
:
'grafana'
};
data
.
addField
({
name
:
'labels'
,
type
:
FieldType
.
other
});
data
.
addField
({
name
:
'id'
,
type
:
FieldType
.
string
});
ResultTransformer
.
appendResponseToBufferedData
(
tailResponse
,
data
);
expect
(
data
.
get
(
0
)).
toEqual
({
ts
:
'2020-02-12T15:05:14.265Z'
,
tsNs
:
'1581519914265798400'
,
line
:
't=2020-02-12T15:04:51+0000 lvl=info msg="Starting Grafana" logger=server version=6.7.0-pre commit=6f09bc9fb4 branch=issue-21929 compiled=2020-02-11T20:43:28+0000'
,
labels
:
{
filename
:
'/var/log/grafana/grafana.log'
},
id
:
'19e8e093d70122b3b53cb6e24efd6e2d'
,
});
});
});
});
public/app/plugins/datasource/loki/result_transformer.ts
View file @
003fb4a3
...
...
@@ -193,7 +193,7 @@ export function appendResponseToBufferedData(response: LokiTailResponse, data: M
// Add each line
for
(
const
[
ts
,
line
]
of
stream
.
values
)
{
data
.
values
.
ts
.
add
(
ts
.
substr
(
0
,
ts
.
length
-
6
));
data
.
values
.
ts
.
add
(
new
Date
(
parseInt
(
ts
.
substr
(
0
,
ts
.
length
-
6
),
10
)).
toISOString
(
));
data
.
values
.
tsNs
.
add
(
ts
);
data
.
values
.
line
.
add
(
line
);
data
.
values
.
labels
.
add
(
unique
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment