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
be123a07
Commit
be123a07
authored
Mar 09, 2017
by
Mitsuhiro Tanda
Committed by
Torkel Ödegaard
Mar 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(prometheus) adjust annotation step (#7768)
* (prometheus) adjust annotation step * (prometheus) add step option
parent
588955c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
public/app/plugins/datasource/prometheus/datasource.ts
+19
-10
public/app/plugins/datasource/prometheus/partials/annotations.editor.html
+5
-2
No files found.
public/app/plugins/datasource/prometheus/datasource.ts
View file @
be123a07
...
@@ -4,6 +4,7 @@ import angular from 'angular';
...
@@ -4,6 +4,7 @@ import angular from 'angular';
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
kbn
from
'app/core/utils/kbn'
;
import
*
as
dateMath
from
'app/core/utils/datemath'
;
import
*
as
dateMath
from
'app/core/utils/datemath'
;
import
PrometheusMetricFindQuery
from
'./metric_find_query'
;
import
PrometheusMetricFindQuery
from
'./metric_find_query'
;
...
@@ -88,12 +89,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
...
@@ -88,12 +89,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
var
intervalFactor
=
target
.
intervalFactor
||
1
;
var
intervalFactor
=
target
.
intervalFactor
||
1
;
target
.
step
=
query
.
step
=
this
.
calculateInterval
(
interval
,
intervalFactor
);
target
.
step
=
query
.
step
=
this
.
calculateInterval
(
interval
,
intervalFactor
);
var
range
=
Math
.
ceil
(
end
-
start
);
var
range
=
Math
.
ceil
(
end
-
start
);
// Prometheus drop query if range/step > 11000
target
.
step
=
query
.
step
=
this
.
adjustStep
(
query
.
step
,
range
);
// calibrate step if it is too big
if
(
query
.
step
!==
0
&&
range
/
query
.
step
>
11000
)
{
target
.
step
=
query
.
step
=
Math
.
ceil
(
range
/
11000
);
}
queries
.
push
(
query
);
queries
.
push
(
query
);
});
});
...
@@ -126,6 +122,15 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
...
@@ -126,6 +122,15 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
});
});
};
};
this
.
adjustStep
=
function
(
step
,
range
)
{
// Prometheus drop query if range/step > 11000
// calibrate step if it is too big
if
(
step
!==
0
&&
range
/
step
>
11000
)
{
return
Math
.
ceil
(
range
/
11000
);
}
return
step
;
};
this
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
this
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
if
(
start
>
end
)
{
if
(
start
>
end
)
{
throw
{
message
:
'Invalid time range'
};
throw
{
message
:
'Invalid time range'
};
...
@@ -175,15 +180,19 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
...
@@ -175,15 +180,19 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
return
$q
.
reject
(
err
);
return
$q
.
reject
(
err
);
}
}
var
step
=
'60s'
;
if
(
annotation
.
step
)
{
step
=
templateSrv
.
replace
(
annotation
.
step
);
}
var
start
=
this
.
getPrometheusTime
(
options
.
range
.
from
,
false
);
var
end
=
this
.
getPrometheusTime
(
options
.
range
.
to
,
true
);
var
query
=
{
var
query
=
{
expr
:
interpolated
,
expr
:
interpolated
,
step
:
'60
s'
step
:
this
.
adjustStep
(
kbn
.
interval_to_seconds
(
step
),
Math
.
ceil
(
end
-
start
))
+
'
s'
};
};
var
start
=
this
.
getPrometheusTime
(
options
.
range
.
from
,
false
);
var
end
=
this
.
getPrometheusTime
(
options
.
range
.
to
,
true
);
var
self
=
this
;
var
self
=
this
;
return
this
.
performTimeSeriesQuery
(
query
,
start
,
end
).
then
(
function
(
results
)
{
return
this
.
performTimeSeriesQuery
(
query
,
start
,
end
).
then
(
function
(
results
)
{
var
eventList
=
[];
var
eventList
=
[];
tagKeys
=
tagKeys
.
split
(
','
);
tagKeys
=
tagKeys
.
split
(
','
);
...
...
public/app/plugins/datasource/prometheus/partials/annotations.editor.html
View file @
be123a07
<h5
class=
"section-heading"
>
Search expression
</h6>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Search expression
</span>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'ctrl.annotation.expr'
placeholder=
"ALERTS"
></input>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'ctrl.annotation.expr'
placeholder=
"ALERTS"
></input>
</div>
</div>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
step
</span>
<input
type=
"text"
class=
"gf-form-input max-width-6"
ng-model=
'ctrl.annotation.step'
placeholder=
"60s"
></input>
</div>
</div>
</div>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form-group"
>
...
...
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