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
bd4f0734
Commit
bd4f0734
authored
Mar 30, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql: minor update
parent
998f04e1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
4 deletions
+24
-4
pkg/api/api.go
+1
-0
pkg/api/metrics.go
+9
-0
pkg/models/test_data.go
+1
-0
pkg/services/sqlstore/migrations/stats_mig.go
+1
-1
pkg/services/sqlstore/sql_test_data.go
+12
-3
No files found.
pkg/api/api.go
View file @
bd4f0734
...
@@ -252,6 +252,7 @@ func (hs *HttpServer) registerRoutes() {
...
@@ -252,6 +252,7 @@ func (hs *HttpServer) registerRoutes() {
// metrics
// metrics
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
))
// metrics
// metrics
r
.
Get
(
"/metrics"
,
wrap
(
GetInternalMetrics
))
r
.
Get
(
"/metrics"
,
wrap
(
GetInternalMetrics
))
...
...
pkg/api/metrics.go
View file @
bd4f0734
...
@@ -126,3 +126,12 @@ func GenerateError(c *middleware.Context) Response {
...
@@ -126,3 +126,12 @@ func GenerateError(c *middleware.Context) Response {
var
array
[]
string
var
array
[]
string
return
Json
(
200
,
array
[
20
])
return
Json
(
200
,
array
[
20
])
}
}
// GET /api/tsdb/testdata/gensql
func
GenerateSqlTestData
(
c
*
middleware
.
Context
)
Response
{
if
err
:=
bus
.
Dispatch
(
&
models
.
InsertSqlTestDataCommand
{});
err
!=
nil
{
return
ApiError
(
500
,
"Failed to insert test data"
,
err
)
}
return
Json
(
200
,
&
util
.
DynMap
{
"message"
:
"OK"
})
}
pkg/models/test_data.go
View file @
bd4f0734
...
@@ -11,6 +11,7 @@ type SqlTestData struct {
...
@@ -11,6 +11,7 @@ type SqlTestData struct {
Metric2
string
Metric2
string
ValueBigInt
int64
ValueBigInt
int64
ValueDouble
float64
ValueDouble
float64
ValueFloat
float32
ValueInt
int
ValueInt
int
TimeEpoch
int64
TimeEpoch
int64
TimeDateTime
time
.
Time
TimeDateTime
time
.
Time
...
...
pkg/services/sqlstore/migrations/stats_mig.go
View file @
bd4f0734
...
@@ -41,7 +41,7 @@ func addTestDataMigrations(mg *Migrator) {
...
@@ -41,7 +41,7 @@ func addTestDataMigrations(mg *Migrator) {
{
Name
:
"id"
,
Type
:
DB_Int
,
IsPrimaryKey
:
true
,
IsAutoIncrement
:
true
},
{
Name
:
"id"
,
Type
:
DB_Int
,
IsPrimaryKey
:
true
,
IsAutoIncrement
:
true
},
{
Name
:
"metric1"
,
Type
:
DB_Varchar
,
Length
:
20
,
Nullable
:
true
},
{
Name
:
"metric1"
,
Type
:
DB_Varchar
,
Length
:
20
,
Nullable
:
true
},
{
Name
:
"metric2"
,
Type
:
DB_NVarchar
,
Length
:
150
,
Nullable
:
true
},
{
Name
:
"metric2"
,
Type
:
DB_NVarchar
,
Length
:
150
,
Nullable
:
true
},
{
Name
:
"value_big_in
g
"
,
Type
:
DB_BigInt
,
Nullable
:
true
},
{
Name
:
"value_big_in
t
"
,
Type
:
DB_BigInt
,
Nullable
:
true
},
{
Name
:
"value_double"
,
Type
:
DB_Double
,
Nullable
:
true
},
{
Name
:
"value_double"
,
Type
:
DB_Double
,
Nullable
:
true
},
{
Name
:
"value_float"
,
Type
:
DB_Float
,
Nullable
:
true
},
{
Name
:
"value_float"
,
Type
:
DB_Float
,
Nullable
:
true
},
{
Name
:
"value_int"
,
Type
:
DB_Int
,
Nullable
:
true
},
{
Name
:
"value_int"
,
Type
:
DB_Int
,
Nullable
:
true
},
...
...
pkg/services/sqlstore/sql_test_data.go
View file @
bd4f0734
package
sqlstore
package
sqlstore
import
(
import
(
"time"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
m
"github.com/grafana/grafana/pkg/models"
)
)
...
@@ -12,10 +14,17 @@ func init() {
...
@@ -12,10 +14,17 @@ func init() {
func
InsertSqlTestData
(
cmd
*
m
.
InsertSqlTestDataCommand
)
error
{
func
InsertSqlTestData
(
cmd
*
m
.
InsertSqlTestDataCommand
)
error
{
return
inTransaction2
(
func
(
sess
*
session
)
error
{
return
inTransaction2
(
func
(
sess
*
session
)
error
{
// create user
row
:=
&
m
.
SqlTestData
{
user
:=
&
m
.
SqlTestData
{}
Metric1
:
"server1"
,
Metric2
:
"frontend"
,
ValueBigInt
:
123123
,
ValueDouble
:
3.14159265359
,
ValueFloat
:
3.14159265359
,
TimeEpoch
:
time
.
Now
()
.
Unix
(),
TimeDateTime
:
time
.
Now
(),
}
if
_
,
err
:=
sess
.
Insert
(
user
);
err
!=
nil
{
if
_
,
err
:=
sess
.
Table
(
"test_data"
)
.
Insert
(
row
);
err
!=
nil
{
return
err
return
err
}
}
...
...
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