Merge "Add timeout option for Grafana request"
This commit is contained in:
commit
1e11c490a7
|
@ -134,7 +134,13 @@ GRAFANA_CLIENT_OPTS = [
|
||||||
"InfluxDB this will be the retention period. "
|
"InfluxDB this will be the retention period. "
|
||||||
"These queries will need to be constructed using tools "
|
"These queries will need to be constructed using tools "
|
||||||
"such as Postman. Example: SELECT cpu FROM {4}."
|
"such as Postman. Example: SELECT cpu FROM {4}."
|
||||||
"cpu_percent WHERE host == '{1}' AND time > now()-{2}s")]
|
"cpu_percent WHERE host == '{1}' AND time > now()-{2}s"),
|
||||||
|
cfg.IntOpt('http_timeout',
|
||||||
|
min=0,
|
||||||
|
default=60,
|
||||||
|
mutable=True,
|
||||||
|
help='Timeout for Grafana request')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def register_opts(conf):
|
def register_opts(conf):
|
||||||
|
|
|
@ -138,7 +138,8 @@ class GrafanaHelper(base.DataSourceBase):
|
||||||
raise exception.DataSourceNotAvailable(self.NAME)
|
raise exception.DataSourceNotAvailable(self.NAME)
|
||||||
|
|
||||||
resp = requests.get(self._base_url + str(project_id) + '/query',
|
resp = requests.get(self._base_url + str(project_id) + '/query',
|
||||||
params=params, headers=self._headers)
|
params=params, headers=self._headers,
|
||||||
|
timeout=CONF.grafana_client.http_timeout)
|
||||||
if resp.status_code == HTTPStatus.OK:
|
if resp.status_code == HTTPStatus.OK:
|
||||||
return resp
|
return resp
|
||||||
elif resp.status_code == HTTPStatus.BAD_REQUEST:
|
elif resp.status_code == HTTPStatus.BAD_REQUEST:
|
||||||
|
|
Loading…
Reference in New Issue