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
c3a8dd28
Unverified
Commit
c3a8dd28
authored
Oct 03, 2018
by
Torkel Ödegaard
Committed by
GitHub
Oct 03, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13500 from grafana/testdata-tables
Testdata tables
parents
4a77a629
ed0c2296
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
33 deletions
+102
-33
devenv/dev-dashboards/panel_tests_slow_queries_and_annotations.json
+0
-0
pkg/tsdb/testdata/scenarios.go
+64
-20
public/app/plugins/datasource/testdata/datasource.ts
+37
-12
public/app/plugins/datasource/testdata/module.ts
+1
-1
No files found.
devenv/dev-dashboards/panel_tests_slow_queries_and_annotations.json
0 → 100644
View file @
c3a8dd28
This diff is collapsed.
Click to expand it.
pkg/tsdb/testdata/scenarios.go
View file @
c3a8dd28
...
...
@@ -95,27 +95,20 @@ func init() {
Id
:
"random_walk"
,
Name
:
"Random Walk"
,
Handler
:
func
(
query
*
tsdb
.
Query
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
*
tsdb
.
QueryResult
{
timeWalkerMs
:=
tsdbQuery
.
TimeRange
.
GetFromAsMsEpoch
()
to
:=
tsdbQuery
.
TimeRange
.
GetToAsMsEpoch
()
series
:=
newSeriesForQuery
(
query
)
points
:=
make
(
tsdb
.
TimeSeriesPoints
,
0
)
walker
:=
rand
.
Float64
()
*
100
for
i
:=
int64
(
0
);
i
<
10000
&&
timeWalkerMs
<
to
;
i
++
{
points
=
append
(
points
,
tsdb
.
NewTimePoint
(
null
.
FloatFrom
(
walker
),
float64
(
timeWalkerMs
)))
walker
+=
rand
.
Float64
()
-
0.5
timeWalkerMs
+=
query
.
IntervalMs
}
series
.
Points
=
points
Handler
:
func
(
query
*
tsdb
.
Query
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
QueryResult
{
return
getRandomWalk
(
query
,
context
)
},
})
queryRes
:=
tsdb
.
NewQueryResult
()
queryRes
.
Series
=
append
(
queryRes
.
Series
,
series
)
return
queryRes
registerScenario
(
&
Scenario
{
Id
:
"slow_query"
,
Name
:
"Slow Query"
,
StringInput
:
"5s"
,
Handler
:
func
(
query
*
tsdb
.
Query
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
QueryResult
{
stringInput
:=
query
.
Model
.
Get
(
"stringInput"
)
.
MustString
()
parsedInterval
,
_
:=
time
.
ParseDuration
(
stringInput
)
time
.
Sleep
(
parsedInterval
)
return
getRandomWalk
(
query
,
context
)
},
})
...
...
@@ -221,6 +214,57 @@ func init() {
return
queryRes
},
})
registerScenario
(
&
Scenario
{
Id
:
"table_static"
,
Name
:
"Table Static"
,
Handler
:
func
(
query
*
tsdb
.
Query
,
context
*
tsdb
.
TsdbQuery
)
*
tsdb
.
QueryResult
{
timeWalkerMs
:=
context
.
TimeRange
.
GetFromAsMsEpoch
()
to
:=
context
.
TimeRange
.
GetToAsMsEpoch
()
table
:=
tsdb
.
Table
{
Columns
:
[]
tsdb
.
TableColumn
{
{
Text
:
"Time"
},
{
Text
:
"Message"
},
{
Text
:
"Description"
},
{
Text
:
"Value"
},
},
Rows
:
[]
tsdb
.
RowValues
{},
}
for
i
:=
int64
(
0
);
i
<
10
&&
timeWalkerMs
<
to
;
i
++
{
table
.
Rows
=
append
(
table
.
Rows
,
tsdb
.
RowValues
{
float64
(
timeWalkerMs
),
"This is a message"
,
"Description"
,
23.1
})
timeWalkerMs
+=
query
.
IntervalMs
}
queryRes
:=
tsdb
.
NewQueryResult
()
queryRes
.
Tables
=
append
(
queryRes
.
Tables
,
&
table
)
return
queryRes
},
})
}
func
getRandomWalk
(
query
*
tsdb
.
Query
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
*
tsdb
.
QueryResult
{
timeWalkerMs
:=
tsdbQuery
.
TimeRange
.
GetFromAsMsEpoch
()
to
:=
tsdbQuery
.
TimeRange
.
GetToAsMsEpoch
()
series
:=
newSeriesForQuery
(
query
)
points
:=
make
(
tsdb
.
TimeSeriesPoints
,
0
)
walker
:=
rand
.
Float64
()
*
100
for
i
:=
int64
(
0
);
i
<
10000
&&
timeWalkerMs
<
to
;
i
++
{
points
=
append
(
points
,
tsdb
.
NewTimePoint
(
null
.
FloatFrom
(
walker
),
float64
(
timeWalkerMs
)))
walker
+=
rand
.
Float64
()
-
0.5
timeWalkerMs
+=
query
.
IntervalMs
}
series
.
Points
=
points
queryRes
:=
tsdb
.
NewQueryResult
()
queryRes
.
Series
=
append
(
queryRes
.
Series
,
series
)
return
queryRes
}
func
registerScenario
(
scenario
*
Scenario
)
{
...
...
public/app/plugins/datasource/testdata/datasource.ts
View file @
c3a8dd28
import
_
from
'lodash'
;
import
TableModel
from
'app/core/table_model'
;
class
TestDataDatasource
{
id
:
any
;
...
...
@@ -29,16 +30,29 @@ class TestDataDatasource {
}
return
this
.
backendSrv
.
post
(
'/api/tsdb/query'
,
{
from
:
options
.
range
.
from
.
valueOf
().
toString
(),
to
:
options
.
range
.
to
.
valueOf
().
toString
(),
queries
:
queries
,
.
datasourceRequest
({
method
:
'POST'
,
url
:
'/api/tsdb/query'
,
data
:
{
from
:
options
.
range
.
from
.
valueOf
().
toString
(),
to
:
options
.
range
.
to
.
valueOf
().
toString
(),
queries
:
queries
,
},
})
.
then
(
res
=>
{
const
data
=
[];
if
(
res
.
results
)
{
_
.
forEach
(
res
.
results
,
queryRes
=>
{
if
(
res
.
data
.
results
)
{
_
.
forEach
(
res
.
data
.
results
,
queryRes
=>
{
if
(
queryRes
.
tables
)
{
for
(
const
table
of
queryRes
.
tables
)
{
const
model
=
new
TableModel
();
model
.
rows
=
table
.
rows
;
model
.
columns
=
table
.
columns
;
data
.
push
(
model
);
}
}
for
(
const
series
of
queryRes
.
series
)
{
data
.
push
({
target
:
series
.
name
,
...
...
@@ -48,17 +62,28 @@ class TestDataDatasource {
});
}
console
.
log
(
res
);
return
{
data
:
data
};
});
}
annotationQuery
(
options
)
{
return
this
.
backendSrv
.
get
(
'/api/annotations'
,
{
from
:
options
.
range
.
from
.
valueOf
(),
to
:
options
.
range
.
to
.
valueOf
(),
limit
:
options
.
limit
,
type
:
options
.
type
,
});
let
timeWalker
=
options
.
range
.
from
.
valueOf
();
const
to
=
options
.
range
.
to
.
valueOf
();
const
events
=
[];
const
eventCount
=
10
;
const
step
=
(
to
-
timeWalker
)
/
eventCount
;
for
(
let
i
=
0
;
i
<
eventCount
;
i
++
)
{
events
.
push
({
annotation
:
options
.
annotation
,
time
:
timeWalker
,
text
:
'This is the text, <a href="https://grafana.com">Grafana.com</a>'
,
tags
:
[
'text'
,
'server'
],
});
timeWalker
+=
step
;
}
return
this
.
$q
.
when
(
events
);
}
}
...
...
public/app/plugins/datasource/testdata/module.ts
View file @
c3a8dd28
...
...
@@ -6,7 +6,7 @@ class TestDataAnnotationsQueryCtrl {
constructor
()
{}
static
template
=
'<h2>
test data
</h2>'
;
static
template
=
'<h2>
Annotation scenario
</h2>'
;
}
export
{
...
...
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