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
4d1b969a
Unverified
Commit
4d1b969a
authored
Oct 31, 2019
by
Ryan McKinley
Committed by
GitHub
Oct 31, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GEL: include the expression count in the request (#20114)
parent
bbff282b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
8 deletions
+15
-8
pkg/api/api.go
+3
-1
pkg/api/metrics.go
+1
-1
public/app/features/dashboard/state/runRequest.ts
+0
-2
public/app/features/expressions/ExpressionDatasource.ts
+11
-4
No files found.
pkg/api/api.go
View file @
4d1b969a
...
...
@@ -327,11 +327,13 @@ func (hs *HTTPServer) registerRoutes() {
// metrics
apiRoute
.
Post
(
"/tsdb/query"
,
bind
(
dtos
.
MetricRequest
{}),
Wrap
(
hs
.
QueryMetrics
))
apiRoute
.
Post
(
"/tsdb/query/v2"
,
bind
(
dtos
.
MetricRequest
{}),
Wrap
(
hs
.
QueryMetricsV2
))
apiRoute
.
Get
(
"/tsdb/testdata/scenarios"
,
Wrap
(
GetTestDataScenarios
))
apiRoute
.
Get
(
"/tsdb/testdata/gensql"
,
reqGrafanaAdmin
,
Wrap
(
GenerateSQLTestData
))
apiRoute
.
Get
(
"/tsdb/testdata/random-walk"
,
Wrap
(
GetTestDataRandomWalk
))
// DataSource w/ expressions
apiRoute
.
Post
(
"/ds/query"
,
bind
(
dtos
.
MetricRequest
{}),
Wrap
(
hs
.
QueryMetricsV2
))
apiRoute
.
Group
(
"/alerts"
,
func
(
alertsRoute
routing
.
RouteRegister
)
{
alertsRoute
.
Post
(
"/test"
,
bind
(
dtos
.
AlertTestCommand
{}),
Wrap
(
AlertTest
))
alertsRoute
.
Post
(
"/:alertId/pause"
,
reqEditorRole
,
bind
(
dtos
.
PauseAlertCommand
{}),
Wrap
(
PauseAlert
))
...
...
pkg/api/metrics.go
View file @
4d1b969a
...
...
@@ -16,7 +16,7 @@ import (
"github.com/grafana/grafana/pkg/util"
)
// POST /api/
tsdb/query/v2
// POST /api/
ds/query DataSource query w/ expressions
func
(
hs
*
HTTPServer
)
QueryMetricsV2
(
c
*
m
.
ReqContext
,
reqDto
dtos
.
MetricRequest
)
Response
{
if
!
setting
.
IsExpressionsEnabled
()
{
return
Error
(
404
,
"Expressions feature toggle is not enabled"
,
nil
)
...
...
public/app/features/dashboard/state/runRequest.ts
View file @
4d1b969a
...
...
@@ -137,8 +137,6 @@ function cancelNetworkRequestsOnUnsubscribe(req: DataQueryRequest) {
}
export
function
callQueryMethod
(
datasource
:
DataSourceApi
,
request
:
DataQueryRequest
)
{
console
.
log
(
'CALL'
,
request
.
targets
);
// If any query has an expression, use the expression endpoint
for
(
const
target
of
request
.
targets
)
{
if
(
target
.
datasource
===
ExpressionDatasourceID
)
{
...
...
public/app/features/expressions/ExpressionDatasource.ts
View file @
4d1b969a
...
...
@@ -12,7 +12,7 @@ import { config } from '@grafana/runtime';
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
/**
* This is a singleton
that is not actually instantiated
* This is a singleton
instance that just pretends to be a DataSource
*/
export
class
ExpressionDatasourceApi
extends
DataSourceApi
<
ExpressionQuery
>
{
constructor
(
instanceSettings
:
DataSourceInstanceSettings
)
{
...
...
@@ -26,30 +26,37 @@ export class ExpressionDatasourceApi extends DataSourceApi<ExpressionQuery> {
query
(
request
:
DataQueryRequest
):
Observable
<
DataQueryResponse
>
{
const
{
targets
,
intervalMs
,
maxDataPoints
,
range
}
=
request
;
let
expressionCount
=
0
;
const
orgId
=
(
window
as
any
).
grafanaBootData
.
user
.
orgId
;
const
queries
=
targets
.
map
(
q
=>
{
if
(
q
.
datasource
===
ExpressionDatasourceID
)
{
expressionCount
++
;
return
{
...
q
,
datasourceId
:
this
.
id
,
orgId
,
};
}
const
ds
=
config
.
datasources
[
q
.
datasource
||
config
.
defaultDatasource
];
const
dsName
=
q
.
datasource
&&
q
.
datasource
!==
'default'
?
q
.
datasource
:
config
.
defaultDatasource
;
const
ds
=
config
.
datasources
[
dsName
];
if
(
!
ds
)
{
throw
new
Error
(
'Unknown Datasource: '
+
q
.
datasource
);
}
return
{
...
q
,
datasourceId
:
ds
.
id
,
intervalMs
,
maxDataPoints
,
orgId
,
// ?? alias: templateSrv.replace(q.alias || ''),
};
});
const
req
:
Promise
<
DataQueryResponse
>
=
getBackendSrv
()
.
post
(
'/api/
tsdb/query/v2
'
,
{
.
post
(
'/api/
ds/query
'
,
{
from
:
range
.
from
.
valueOf
().
toString
(),
to
:
range
.
to
.
valueOf
().
toString
(),
queries
:
queries
,
range
,
expressionCount
,
})
.
then
((
rsp
:
any
)
=>
{
return
this
.
toDataQueryResponse
(
rsp
);
...
...
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