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
b867050c
Unverified
Commit
b867050c
authored
Sep 03, 2020
by
Ryan McKinley
Committed by
GitHub
Sep 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotations: improve datasource annotation types and add basic query properties (#27342)
parent
cac0e6ec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
10 deletions
+29
-10
packages/grafana-data/src/types/datasource.ts
+16
-9
public/app/features/annotations/annotations_srv.ts
+10
-1
public/app/plugins/datasource/loki/datasource.test.ts
+3
-0
No files found.
packages/grafana-data/src/types/datasource.ts
View file @
b867050c
...
...
@@ -155,7 +155,8 @@ export interface DataSourceConstructor<
*/
export
abstract
class
DataSourceApi
<
TQuery
extends
DataQuery
=
DataQuery
,
TOptions
extends
DataSourceJsonData
=
DataSourceJsonData
TOptions
extends
DataSourceJsonData
=
DataSourceJsonData
,
TAnno
=
TQuery
// defatult to direct query
>
{
/**
* Set in constructor
...
...
@@ -270,7 +271,7 @@ export abstract class DataSourceApi<
* Can be optionally implemented to allow datasource to be a source of annotations for dashboard. To be visible
* in the annotation editor `annotations` capability also needs to be enabled in plugin.json.
*/
annotationQuery
?(
options
:
AnnotationQueryRequest
<
T
Query
>
):
Promise
<
AnnotationEvent
[]
>
;
annotationQuery
?(
options
:
AnnotationQueryRequest
<
T
Anno
>
):
Promise
<
AnnotationEvent
[]
>
;
interpolateVariablesInQueries
?(
queries
:
TQuery
[],
scopedVars
:
ScopedVars
|
{}):
TQuery
[];
}
...
...
@@ -466,6 +467,12 @@ export interface MetricFindValue {
expandable
?:
boolean
;
}
export
interface
BaseAnnotationQuery
{
datasource
:
string
;
enable
:
boolean
;
name
:
string
;
}
export
interface
DataSourceJsonData
{
authType
?:
string
;
defaultRegion
?:
string
;
...
...
@@ -535,19 +542,19 @@ export interface DataSourceSelectItem {
/**
* Options passed to the datasource.annotationQuery method. See docs/plugins/developing/datasource.md
*/
export
interface
AnnotationQueryRequest
<
MoreOptions
=
{}
>
{
export
interface
AnnotationQueryRequest
<
TAnno
=
{}
>
{
range
:
TimeRange
;
rangeRaw
:
RawTimeRange
;
interval
:
string
;
intervalMs
:
number
;
maxDataPoints
?:
number
;
app
:
CoreApp
|
string
;
// Should be DataModel but cannot import that here from the main app. Needs to be moved to package first.
dashboard
:
any
;
// The annotation query, typically extends DataQuery
annotation
:
{
datasource
:
string
;
enable
:
boolean
;
name
:
string
;
}
&
MoreOptions
;
// The annotation query and common properties
annotation
:
BaseAnnotationQuery
&
TAnno
;
}
export
interface
HistoryItem
<
TQuery
extends
DataQuery
=
DataQuery
>
{
...
...
public/app/features/annotations/annotations_srv.ts
View file @
b867050c
...
...
@@ -8,10 +8,11 @@ import coreModule from 'app/core/core_module';
import
{
dedupAnnotations
}
from
'./events_processing'
;
// Types
import
{
DashboardModel
,
PanelModel
}
from
'../dashboard/state'
;
import
{
AnnotationEvent
,
AppEvents
,
DataSourceApi
,
PanelEvents
,
TimeRange
}
from
'@grafana/data'
;
import
{
AnnotationEvent
,
AppEvents
,
DataSourceApi
,
PanelEvents
,
TimeRange
,
CoreApp
}
from
'@grafana/data'
;
import
{
getBackendSrv
,
getDataSourceSrv
}
from
'@grafana/runtime'
;
import
{
appEvents
}
from
'app/core/core'
;
import
{
getTimeSrv
}
from
'../dashboard/services/TimeSrv'
;
import
kbn
from
'app/core/utils/kbn'
;
export
class
AnnotationsSrv
{
globalAnnotationsPromise
:
any
;
...
...
@@ -113,6 +114,9 @@ export class AnnotationsSrv {
const
promises
=
[];
const
dsPromises
=
[];
// No more points than pixels
const
maxDataPoints
=
window
.
innerWidth
||
document
.
documentElement
.
clientWidth
||
document
.
body
.
clientWidth
;
for
(
const
annotation
of
dashboard
.
annotations
.
list
)
{
if
(
!
annotation
.
enable
)
{
continue
;
...
...
@@ -130,7 +134,12 @@ export class AnnotationsSrv {
return
[];
}
// Add interval to annotation queries
const
interval
=
kbn
.
calculateInterval
(
range
,
maxDataPoints
,
datasource
.
interval
);
return
datasource
.
annotationQuery
({
...
interval
,
app
:
CoreApp
.
Dashboard
,
range
,
rangeRaw
:
range
.
raw
,
annotation
:
annotation
,
...
...
public/app/plugins/datasource/loki/datasource.test.ts
View file @
b867050c
...
...
@@ -539,6 +539,9 @@ function makeAnnotationQueryRequest(): AnnotationQueryRequest<LokiQuery> {
raw
:
timeRange
,
},
rangeRaw
:
timeRange
,
app
:
'test'
,
interval
:
'1m'
,
intervalMs
:
6000
,
};
}
...
...
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