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
e4c2476f
Commit
e4c2476f
authored
Jul 31, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Weird execution order for the tests...
parent
3d4a346c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
24 deletions
+15
-24
public/app/plugins/datasource/prometheus/datasource.ts
+6
-1
public/app/plugins/datasource/prometheus/result_transformer.ts
+6
-1
public/app/plugins/datasource/prometheus/specs/_datasource.jest.ts
+3
-22
No files found.
public/app/plugins/datasource/prometheus/datasource.ts
View file @
e4c2476f
...
@@ -175,8 +175,12 @@ export class PrometheusDatasource {
...
@@ -175,8 +175,12 @@ export class PrometheusDatasource {
responseIndex: index,
responseIndex: index,
refId: activeTargets[index].refId,
refId: activeTargets[index].refId,
};
};
console.log('
format
:
' + transformerOptions.format);
console.log('
resultType
:
' + response.data.data.resultType);
console.log('
legendFormat
:
' + transformerOptions.legendFormat);
// console.log(result);
this.resultTransformer.transform(result, response, transformerOptions);
this.resultTransformer.transform(result, response, transformerOptions);
// console.log(result);
});
});
return { data: result };
return { data: result };
...
@@ -233,6 +237,7 @@ export class PrometheusDatasource {
...
@@ -233,6 +237,7 @@ export class PrometheusDatasource {
if (start > end) {
if (start > end) {
throw { message: '
Invalid
time
range
' };
throw { message: '
Invalid
time
range
' };
}
}
// console.log(query.expr);
var url = '
/
api
/
v1
/
query_range
';
var url = '
/
api
/
v1
/
query_range
';
var data = {
var data = {
...
...
public/app/plugins/datasource/prometheus/result_transformer.ts
View file @
e4c2476f
...
@@ -6,7 +6,9 @@ export class ResultTransformer {
...
@@ -6,7 +6,9 @@ export class ResultTransformer {
transform
(
result
:
any
,
response
:
any
,
options
:
any
)
{
transform
(
result
:
any
,
response
:
any
,
options
:
any
)
{
let
prometheusResult
=
response
.
data
.
data
.
result
;
let
prometheusResult
=
response
.
data
.
data
.
result
;
console
.
log
(
prometheusResult
);
// console.log(options);
// console.log(result);
if
(
options
.
format
===
'table'
)
{
if
(
options
.
format
===
'table'
)
{
result
.
push
(
this
.
transformMetricDataToTable
(
prometheusResult
,
options
.
responseListLength
,
options
.
refId
));
result
.
push
(
this
.
transformMetricDataToTable
(
prometheusResult
,
options
.
responseListLength
,
options
.
refId
));
}
else
if
(
options
.
format
===
'heatmap'
)
{
}
else
if
(
options
.
format
===
'heatmap'
)
{
...
@@ -26,6 +28,7 @@ export class ResultTransformer {
...
@@ -26,6 +28,7 @@ export class ResultTransformer {
}
}
}
}
}
}
// console.log(result);
}
}
transformMetricData
(
metricData
,
options
,
start
,
end
)
{
transformMetricData
(
metricData
,
options
,
start
,
end
)
{
...
@@ -137,6 +140,7 @@ export class ResultTransformer {
...
@@ -137,6 +140,7 @@ export class ResultTransformer {
if
(
!
label
||
label
===
'{}'
)
{
if
(
!
label
||
label
===
'{}'
)
{
label
=
options
.
query
;
label
=
options
.
query
;
}
}
console
.
log
(
label
);
return
label
;
return
label
;
}
}
...
@@ -156,6 +160,7 @@ export class ResultTransformer {
...
@@ -156,6 +160,7 @@ export class ResultTransformer {
var
labelPart
=
_
.
map
(
_
.
toPairs
(
labelData
),
function
(
label
)
{
var
labelPart
=
_
.
map
(
_
.
toPairs
(
labelData
),
function
(
label
)
{
return
label
[
0
]
+
'="'
+
label
[
1
]
+
'"'
;
return
label
[
0
]
+
'="'
+
label
[
1
]
+
'"'
;
}).
join
(
','
);
}).
join
(
','
);
console
.
log
(
metricName
);
return
metricName
+
'{'
+
labelPart
+
'}'
;
return
metricName
+
'{'
+
labelPart
+
'}'
;
}
}
...
...
public/app/plugins/datasource/prometheus/specs/_datasource.jest.ts
View file @
e4c2476f
...
@@ -21,23 +21,7 @@ let backendSrv = <any>{
...
@@ -21,23 +21,7 @@ let backendSrv = <any>{
};
};
let
templateSrv
=
{
let
templateSrv
=
{
replace
:
(
target
,
scopedVars
,
format
)
=>
{
replace
:
jest
.
fn
(
str
=>
str
),
if
(
!
target
)
{
return
target
;
}
let
variable
,
value
,
fmt
;
return
target
.
replace
(
scopedVars
,
(
match
,
var1
,
var2
,
fmt2
,
var3
,
fmt3
)
=>
{
variable
=
this
.
index
[
var1
||
var2
||
var3
];
fmt
=
fmt2
||
fmt3
||
format
;
if
(
scopedVars
)
{
value
=
scopedVars
[
var1
||
var2
||
var3
];
if
(
value
)
{
return
this
.
formatValue
(
value
.
value
,
fmt
,
variable
);
}
}
});
},
};
};
let
timeSrv
=
{
let
timeSrv
=
{
...
@@ -63,10 +47,7 @@ describe('PrometheusDatasource', function() {
...
@@ -63,10 +47,7 @@ describe('PrometheusDatasource', function() {
// })
// })
// );
// );
beforeEach
(()
=>
{
describe
(
'When querying prometheus with one target using query editor target spec'
,
async
()
=>
{
ctx
.
ds
=
new
PrometheusDatasource
(
instanceSettings
,
$q
,
<
any
>
backendSrv
,
templateSrv
,
timeSrv
);
});
describe
(
'When querying prometheus with one target using query editor target spec'
,
function
()
{
var
results
;
var
results
;
var
query
=
{
var
query
=
{
range
:
{
from
:
time
({
seconds
:
63
}),
to
:
time
({
seconds
:
183
})
},
range
:
{
from
:
time
({
seconds
:
63
}),
to
:
time
({
seconds
:
183
})
},
...
@@ -106,7 +87,7 @@ describe('PrometheusDatasource', function() {
...
@@ -106,7 +87,7 @@ describe('PrometheusDatasource', function() {
expect
(
res
.
method
).
toBe
(
'GET'
);
expect
(
res
.
method
).
toBe
(
'GET'
);
expect
(
res
.
url
).
toBe
(
urlExpected
);
expect
(
res
.
url
).
toBe
(
urlExpected
);
});
});
it
(
'should return series list'
,
function
()
{
it
(
'should return series list'
,
async
()
=>
{
expect
(
results
.
data
.
length
).
toBe
(
1
);
expect
(
results
.
data
.
length
).
toBe
(
1
);
expect
(
results
.
data
[
0
].
target
).
toBe
(
'test{job="testjob"}'
);
expect
(
results
.
data
[
0
].
target
).
toBe
(
'test{job="testjob"}'
);
});
});
...
...
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