diff --git a/redash/query_runner/cloudwatch.py b/redash/query_runner/cloudwatch.py index 16f65e5e9..c4640a537 100644 --- a/redash/query_runner/cloudwatch.py +++ b/redash/query_runner/cloudwatch.py @@ -1,10 +1,14 @@ -import boto3 import yaml import datetime from redash.query_runner import BaseQueryRunner, register from redash.utils import json_dumps, parse_human_time +try: + import boto3 + enabled = True +except ImportError: + enabled = False def parse_response(results): columns = [ @@ -63,6 +67,10 @@ class CloudWatch(BaseQueryRunner): "secret": ["aws_secret_key"], } + @classmethod + def enabled(cls): + return enabled + def __init__(self, configuration): super(CloudWatch, self).__init__(configuration) self.syntax = "yaml" diff --git a/redash/query_runner/cloudwatch_insights.py b/redash/query_runner/cloudwatch_insights.py index 9091d158c..139d5b678 100644 --- a/redash/query_runner/cloudwatch_insights.py +++ b/redash/query_runner/cloudwatch_insights.py @@ -1,13 +1,17 @@ -import boto3 import yaml import datetime import time -from botocore.exceptions import ParamValidationError - from redash.query_runner import BaseQueryRunner, register from redash.utils import json_dumps, parse_human_time +try: + import boto3 + from botocore.exceptions import ParamValidationError + enabled = True +except ImportError: + enabled = False + POLL_INTERVAL = 3 TIMEOUT = 180 @@ -81,6 +85,10 @@ class CloudWatchInsights(BaseQueryRunner): "secret": ["aws_secret_key"], } + @classmethod + def enabled(cls): + return enabled + def __init__(self, configuration): super(CloudWatchInsights, self).__init__(configuration) self.syntax = "yaml"