Commit 5af81b97 by Torkel Ödegaard

mysql: graph showing

parent a7babfb7
...@@ -7,3 +7,6 @@ mysql: ...@@ -7,3 +7,6 @@ mysql:
MYSQL_PASSWORD: password MYSQL_PASSWORD: password
ports: ports:
- "3306:3306" - "3306:3306"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
...@@ -58,6 +58,13 @@ func InsertSqlTestData(cmd *m.InsertSqlTestDataCommand) error { ...@@ -58,6 +58,13 @@ func InsertSqlTestData(cmd *m.InsertSqlTestDataCommand) error {
sqlog.Info("SQL TestData: Truncate done", "rows", rows) sqlog.Info("SQL TestData: Truncate done", "rows", rows)
sqlRandomWalk("server1", "frontend", 100, 1.123, sess) sqlRandomWalk("server1", "frontend", 100, 1.123, sess)
sqlRandomWalk("server2", "frontend", 100, 1.123, sess)
sqlRandomWalk("server3", "frontend", 100, 1.123, sess)
sqlRandomWalk("server1", "backend", 100, 1.123, sess)
sqlRandomWalk("server2", "backend", 100, 1.123, sess)
sqlRandomWalk("server3", "backend", 100, 1.123, sess)
sqlRandomWalk("db-server1", "backend", 100, 1.123, sess)
return err return err
}) })
......
...@@ -93,20 +93,15 @@ func (e *MysqlExecutor) Execute(ctx context.Context, queries tsdb.QuerySlice, co ...@@ -93,20 +93,15 @@ func (e *MysqlExecutor) Execute(ctx context.Context, queries tsdb.QuerySlice, co
rows, err := db.Query(rawSql) rows, err := db.Query(rawSql)
if err != nil { if err != nil {
result.Error = err result.QueryResults[query.RefId] = &tsdb.QueryResult{Error: err}
return result continue
} }
defer rows.Close() defer rows.Close()
result.QueryResults[query.RefId] = e.TransformToTimeSeries(query, rows) result.QueryResults[query.RefId] = e.TransformToTimeSeries(query, rows)
} }
for _, value := range result.QueryResults {
if value.Error != nil {
e.log.Error("error", "error", value.Error)
}
}
return result return result
} }
...@@ -190,7 +185,6 @@ func (s *stringStringScan) Update(rows *sql.Rows) error { ...@@ -190,7 +185,6 @@ func (s *stringStringScan) Update(rows *sql.Rows) error {
for i := 0; i < s.columnCount; i++ { for i := 0; i < s.columnCount; i++ {
if rb, ok := s.rowPtrs[i].(*sql.RawBytes); ok { if rb, ok := s.rowPtrs[i].(*sql.RawBytes); ok {
s.rowValues[i] = string(*rb) s.rowValues[i] = string(*rb)
fmt.Printf("column %s = %s", s.columnNames[i], s.rowValues[i])
switch s.columnNames[i] { switch s.columnNames[i] {
case "time_sec": case "time_sec":
...@@ -202,9 +196,7 @@ func (s *stringStringScan) Update(rows *sql.Rows) error { ...@@ -202,9 +196,7 @@ func (s *stringStringScan) Update(rows *sql.Rows) error {
s.value = null.FloatFrom(value) s.value = null.FloatFrom(value)
} }
case "metric": case "metric":
if value, err := strconv.ParseFloat(s.rowValues[i], 64); err == nil { s.metric = s.rowValues[i]
s.value = null.FloatFrom(value)
}
} }
*rb = nil // reset pointer to discard current value to avoid a bug *rb = nil // reset pointer to discard current value to avoid a bug
......
<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 gf-form--grow"> <div class="gf-form gf-form--grow">
<textarea rows="6" class="gf-form-input" ng-model="ctrl.target.rawSql" spellcheck="false" placeholder="query expression" data-min-length=0 data-items=100 ng-model-onblur ng-change="ctrl.refreshMetricData()"></textarea> <textarea rows="6" class="gf-form-input" ng-model="ctrl.target.rawSql" spellcheck="false" placeholder="query expression" data-min-length=0 data-items=100 ng-model-onblur ng-change="ctrl.panelCtrl.refresh()"></textarea>
</div> </div>
</div> </div>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
} }
}, },
"alerting": true,
"annotations": true, "annotations": true,
"metrics": true "metrics": true
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment