mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 06:32:28 +08:00
Postgres/MySQL/MSSQL: Add setting to limit maximum amount of rows processed (#38986)
Adds a new setting dataproxy.row_limit that allows an operator to limit the amount of rows being processed/accepted in response to database queries originating from SQL data sources. Closes #38975 Ref #39095 Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
5b7dc16c06
commit
1c892a2fc4
@ -26,10 +26,9 @@ var logger = log.New("tsdb.postgres")
|
||||
|
||||
func ProvideService(cfg *setting.Cfg, manager backendplugin.Manager) (*Service, error) {
|
||||
s := &Service{
|
||||
Cfg: cfg,
|
||||
tlsManager: newTLSManager(logger, cfg.DataPath),
|
||||
}
|
||||
s.im = datasource.NewInstanceManager(s.newInstanceSettings())
|
||||
s.im = datasource.NewInstanceManager(s.newInstanceSettings(cfg))
|
||||
factory := coreplugin.New(backend.ServeOpts{
|
||||
QueryDataHandler: s,
|
||||
})
|
||||
@ -41,7 +40,6 @@ func ProvideService(cfg *setting.Cfg, manager backendplugin.Manager) (*Service,
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
Cfg *setting.Cfg
|
||||
tlsManager tlsSettingsProvider
|
||||
im instancemgmt.InstanceManager
|
||||
}
|
||||
@ -63,7 +61,7 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
||||
return dsInfo.QueryData(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Service) newInstanceSettings() datasource.InstanceFactoryFunc {
|
||||
func (s *Service) newInstanceSettings(cfg *setting.Cfg) datasource.InstanceFactoryFunc {
|
||||
return func(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||
logger.Debug("Creating Postgres query endpoint")
|
||||
jsonData := sqleng.JsonData{
|
||||
@ -94,7 +92,7 @@ func (s *Service) newInstanceSettings() datasource.InstanceFactoryFunc {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if s.Cfg.Env == setting.Dev {
|
||||
if cfg.Env == setting.Dev {
|
||||
logger.Debug("getEngine", "connection", cnnstr)
|
||||
}
|
||||
|
||||
@ -103,6 +101,7 @@ func (s *Service) newInstanceSettings() datasource.InstanceFactoryFunc {
|
||||
ConnectionString: cnnstr,
|
||||
DSInfo: dsInfo,
|
||||
MetricColumnTypes: []string{"UNKNOWN", "TEXT", "VARCHAR", "CHAR"},
|
||||
RowLimit: cfg.DataProxyRowLimit,
|
||||
}
|
||||
|
||||
queryResultTransformer := postgresQueryResultTransformer{
|
||||
|
Reference in New Issue
Block a user