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
ed0c2296
Commit
ed0c2296
authored
Oct 02, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added slow queries scenario to test data source, added new panel test dashboard with slow queries
parent
9e72588c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
51 deletions
+61
-51
devenv/dev-dashboards/panel_tests_slow_queries_and_annotations.json
+0
-0
pkg/tsdb/testdata/scenarios.go
+46
-29
public/app/plugins/datasource/testdata/datasource.ts
+15
-22
No files found.
devenv/dev-dashboards/panel_tests_slow_queries_and_annotations.json
0 → 100644
View file @
ed0c2296
This diff is collapsed.
Click to expand it.
pkg/tsdb/testdata/scenarios.go
View file @
ed0c2296
...
...
@@ -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
)
},
})
...
...
@@ -223,23 +216,24 @@ func init() {
})
registerScenario
(
&
Scenario
{
Id
:
"
annotations
"
,
Name
:
"
Annotations
"
,
Id
:
"
table_static
"
,
Name
:
"
Table Static
"
,
Handler
:
func
(
query
*
tsdb
.
Query
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
*
tsdb
.
QueryResult
{
timeWalkerMs
:=
tsdbQuery
.
TimeRange
.
GetFromAsMsEpoch
()
to
:=
tsdbQuery
.
TimeRange
.
GetToAsMsEpoch
()
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
:
"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
),
"
hello"
})
table
.
Rows
=
append
(
table
.
Rows
,
tsdb
.
RowValues
{
float64
(
timeWalkerMs
),
"
This is a message"
,
"Description"
,
23.1
})
timeWalkerMs
+=
query
.
IntervalMs
}
...
...
@@ -250,6 +244,29 @@ func init() {
})
}
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
)
{
ScenarioRegistry
[
scenario
.
Id
]
=
scenario
}
...
...
public/app/plugins/datasource/testdata/datasource.ts
View file @
ed0c2296
...
...
@@ -68,29 +68,22 @@ class TestDataDatasource {
}
annotationQuery
(
options
)
{
return
this
.
backendSrv
.
datasourceRequest
({
method
:
'POST'
,
url
:
'/api/tsdb/query'
,
data
:
{
from
:
options
.
range
.
from
.
valueOf
().
toString
(),
to
:
options
.
range
.
to
.
valueOf
().
toString
(),
queries
:
[
{
refId
:
'A'
,
scenarioId
:
'annotations'
,
intervalMs
:
100
,
maxDataPoints
:
100
,
stringInput
:
''
,
datasourceId
:
this
.
id
,
},
],
},
})
.
then
(
resp
=>
{
console
.
log
(
resp
);
return
[];
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
);
}
}
...
...
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