add global datasource proxy timeout setting

closes grafana#5699
This commit is contained in:
Benjamin Reed 2019-01-24 14:04:21 -05:00
parent c7b556c0e4
commit 9108fd1b9d
4 changed files with 9 additions and 1 deletions

View File

@ -143,6 +143,9 @@ conn_max_lifetime = 14400
# This enables data proxy logging, default is false # This enables data proxy logging, default is false
logging = false logging = false
# How long the data proxy should wait before timing out default is 30 (seconds)
timeout = 30
#################################### Analytics ########################### #################################### Analytics ###########################
[analytics] [analytics]
# Server reporting, sends usage counters to stats.grafana.org every 24 hours. # Server reporting, sends usage counters to stats.grafana.org every 24 hours.

View File

@ -130,6 +130,9 @@ log_queries =
# This enables data proxy logging, default is false # This enables data proxy logging, default is false
;logging = false ;logging = false
# How long the data proxy should wait before timing out default is 30 (seconds)
;timeout = 30
#################################### Analytics #################################### #################################### Analytics ####################################
[analytics] [analytics]
# Server reporting, sends usage counters to stats.grafana.org every 24 hours. # Server reporting, sends usage counters to stats.grafana.org every 24 hours.

View File

@ -54,7 +54,7 @@ func NewDataSourceProxy(ds *m.DataSource, plugin *plugins.DataSourcePlugin, ctx
func newHTTPClient() httpClient { func newHTTPClient() httpClient {
return &http.Client{ return &http.Client{
Timeout: time.Second * 30, Timeout: time.Duration(setting.DataProxyTimeout) * time.Second,
Transport: &http.Transport{Proxy: http.ProxyFromEnvironment}, Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
} }
} }

View File

@ -77,6 +77,7 @@ var (
SocketPath string SocketPath string
RouterLogging bool RouterLogging bool
DataProxyLogging bool DataProxyLogging bool
DataProxyTimeout int
StaticRootPath string StaticRootPath string
EnableGzip bool EnableGzip bool
EnforceDomain bool EnforceDomain bool
@ -583,6 +584,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
// read data proxy settings // read data proxy settings
dataproxy := iniFile.Section("dataproxy") dataproxy := iniFile.Section("dataproxy")
DataProxyLogging = dataproxy.Key("logging").MustBool(false) DataProxyLogging = dataproxy.Key("logging").MustBool(false)
DataProxyTimeout = dataproxy.Key("timeout").MustInt(30)
// read security settings // read security settings
security := iniFile.Section("security") security := iniFile.Section("security")