mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 07:02:22 +08:00
Add the datasource of RDBMS (PostgreSQL and MySQL)
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user