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
5e0b0392
Commit
5e0b0392
authored
May 29, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v4.3.x'
parents
ab44c7d6
0d39852e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
4 deletions
+56
-4
pkg/api/api.go
+1
-0
pkg/api/metrics.go
+27
-0
public/app/plugins/datasource/grafana/datasource.ts
+23
-3
public/app/plugins/datasource/grafana/partials/query.editor.html
+5
-1
No files found.
pkg/api/api.go
View file @
5e0b0392
...
@@ -253,6 +253,7 @@ func (hs *HttpServer) registerRoutes() {
...
@@ -253,6 +253,7 @@ func (hs *HttpServer) registerRoutes() {
r
.
Post
(
"/tsdb/query"
,
bind
(
dtos
.
MetricRequest
{}),
wrap
(
QueryMetrics
))
r
.
Post
(
"/tsdb/query"
,
bind
(
dtos
.
MetricRequest
{}),
wrap
(
QueryMetrics
))
r
.
Get
(
"/tsdb/testdata/scenarios"
,
wrap
(
GetTestDataScenarios
))
r
.
Get
(
"/tsdb/testdata/scenarios"
,
wrap
(
GetTestDataScenarios
))
r
.
Get
(
"/tsdb/testdata/gensql"
,
reqGrafanaAdmin
,
wrap
(
GenerateSqlTestData
))
r
.
Get
(
"/tsdb/testdata/gensql"
,
reqGrafanaAdmin
,
wrap
(
GenerateSqlTestData
))
r
.
Get
(
"/tsdb/testdata/random-walk"
,
wrap
(
GetTestDataRandomWalk
))
// metrics
// metrics
r
.
Get
(
"/metrics"
,
wrap
(
GetInternalMetrics
))
r
.
Get
(
"/metrics"
,
wrap
(
GetInternalMetrics
))
...
...
pkg/api/metrics.go
View file @
5e0b0392
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
...
@@ -144,3 +145,29 @@ func GenerateSqlTestData(c *middleware.Context) Response {
...
@@ -144,3 +145,29 @@ func GenerateSqlTestData(c *middleware.Context) Response {
return
Json
(
200
,
&
util
.
DynMap
{
"message"
:
"OK"
})
return
Json
(
200
,
&
util
.
DynMap
{
"message"
:
"OK"
})
}
}
// GET /api/tsdb/testdata/random-walk
func
GetTestDataRandomWalk
(
c
*
middleware
.
Context
)
Response
{
from
:=
c
.
Query
(
"from"
)
to
:=
c
.
Query
(
"to"
)
intervalMs
:=
c
.
QueryInt64
(
"intervalMs"
)
timeRange
:=
tsdb
.
NewTimeRange
(
from
,
to
)
request
:=
&
tsdb
.
Request
{
TimeRange
:
timeRange
}
request
.
Queries
=
append
(
request
.
Queries
,
&
tsdb
.
Query
{
RefId
:
"A"
,
IntervalMs
:
intervalMs
,
Model
:
simplejson
.
NewFromAny
(
&
util
.
DynMap
{
"scenario"
:
"random_walk"
,
}),
DataSource
:
&
models
.
DataSource
{
Type
:
"grafana-testdata-datasource"
},
})
resp
,
err
:=
tsdb
.
HandleRequest
(
context
.
Background
(),
request
)
if
err
!=
nil
{
return
ApiError
(
500
,
"Metric request error"
,
err
)
}
return
Json
(
200
,
&
resp
)
}
public/app/plugins/datasource/grafana/datasource.ts
View file @
5e0b0392
...
@@ -8,11 +8,31 @@ class GrafanaDatasource {
...
@@ -8,11 +8,31 @@ class GrafanaDatasource {
constructor
(
private
backendSrv
,
private
$q
)
{}
constructor
(
private
backendSrv
,
private
$q
)
{}
query
(
options
)
{
query
(
options
)
{
return
this
.
$q
.
when
({
data
:
[]});
return
this
.
backendSrv
.
get
(
'/api/tsdb/testdata/random-walk'
,
{
from
:
options
.
range
.
from
.
valueOf
(),
to
:
options
.
range
.
to
.
valueOf
(),
intervalMs
:
options
.
intervalMs
,
maxDataPoints
:
options
.
maxDataPoints
,
}).
then
(
res
=>
{
var
data
=
[];
if
(
res
.
results
)
{
_
.
forEach
(
res
.
results
,
queryRes
=>
{
for
(
let
series
of
queryRes
.
series
)
{
data
.
push
({
target
:
series
.
name
,
datapoints
:
series
.
points
});
}
});
}
return
{
data
:
data
};
});
}
}
metricFindQuery
()
{
metricFindQuery
(
options
)
{
return
this
.
$q
.
when
(
[]
);
return
this
.
$q
.
when
(
{
data
:
[]}
);
}
}
annotationQuery
(
options
)
{
annotationQuery
(
options
)
{
...
...
public/app/plugins/datasource/grafana/partials/query.editor.html
View file @
5e0b0392
<query-editor-row
query-ctrl=
"ctrl"
can-collapse=
"false"
>
<query-editor-row
query-ctrl=
"ctrl"
can-collapse=
"false"
>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<div
class=
"gf-form"
>
<label
class=
"gf-form-label"
>
Test metric (fake data source)
</label>
<label
class=
"gf-form-label"
>
Test data: random walk
</label>
</div>
<div
class=
"gf-form gf-form--grow"
>
<div
class=
"gf-form-label gf-form-label--grow"
></div>
</div>
</div>
</div>
</div>
</query-editor-row>
</query-editor-row>
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