Add the datasource of RDBMS (PostgreSQL and MySQL)

This commit is contained in:
Nozomi Anzai
2016-06-13 18:24:18 +09:00
parent 22407fc897
commit 6586cc4029
3 changed files with 172 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"time"
"github.com/grafana/grafana/pkg/api/cloudwatch"
"github.com/grafana/grafana/pkg/api/sqldb"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware"
@ -43,6 +44,7 @@ func NewReverseProxy(ds *m.DataSource, proxyPath string, targetUrl *url.URL) *ht
} else if ds.Type == m.DS_INFLUXDB {
req.URL.Path = util.JoinUrlFragments(targetUrl.Path, proxyPath)
req.URL.RawQuery = reqQueryVals.Encode()
reqQueryVals.Add("db", ds.Database)
if !ds.BasicAuth {
req.Header.Del("Authorization")
req.Header.Add("Authorization", util.GetBasicAuthHeader(ds.User, ds.Password))
@ -100,6 +102,10 @@ func ProxyDataSourceRequest(c *middleware.Context) {
if ds.Type == m.DS_CLOUDWATCH {
cloudwatch.HandleRequest(c, ds)
} else if ds.Type == m.DS_SQLDB {
sqldb.HandleRequest(c, ds)
} else {
proxyPath := c.Params("*")
proxy := NewReverseProxy(ds, proxyPath, targetUrl)