Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon CloudWatch query runners #4372

Merged
merged 6 commits into from
Nov 27, 2019
Merged

Amazon CloudWatch query runners #4372

merged 6 commits into from
Nov 27, 2019

Conversation

arikfr
Copy link
Member

@arikfr arikfr commented Nov 19, 2019

What type of PR is this? (check all applicable)

  • New Query Runner (Data Source)

Description

Query runner for Amazon CloudWatch and CloudWatch Insights.

  • Implement Insights query runner.
  • Update names & types.
  • Add logos.
  • Implement Test Connection.

@arikfr arikfr added the Backend label Nov 19, 2019
@arikfr arikfr changed the title Amazon CloudWatch query runners WIP: Amazon CloudWatch query runners Nov 19, 2019
@arikfr arikfr changed the title WIP: Amazon CloudWatch query runners Amazon CloudWatch query runners Nov 19, 2019
@arikfr arikfr requested a review from rauchy November 19, 2019 12:25
Copy link
Contributor

@rauchy rauchy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I just have a couple of questions:

  1. How do you decide if a helper function is inside or outside a class scope? For example, I'm not sure why CloudWatch._get_client is inside the CloudWatch scope, but parse_response is outside. I know it's not a big deal, but if it's just arbitrary, then a unified approach would make the code slightly easier to step into.

  2. How do you pick between list comprehensions and building with for loops? For example, the for block in parse_response under cloudwatch.py could easily be represented with a list comprehension. Again, not a big deal, but having a rule to follow (for example - 'prefer list comprehensions unless they look like a pile of manure') might make things easier.

@arikfr
Copy link
Member Author

arikfr commented Nov 25, 2019

  1. How do you decide if a helper function is inside or outside a class scope? For example, I'm not sure why CloudWatch._get_client is inside the CloudWatch scope, but parse_response is outside.

_get_client uses values from the instance, hence it's a class method. parse_response doesn't so it's outside.

2. How do you pick between list comprehensions and building with for loops?

Mostly habit thing. When the for loop is simple I use list comprehensions, but when it's multi line I usually do a for loop.

@rauchy
Copy link
Contributor

rauchy commented Nov 25, 2019

_get_client uses values from the instance, hence it's a class method. parse_response doesn't so it's outside.

Yeah, but encapsulating is about knowledge, not access to memory. parse_response is tightly coupled to CloudWatch's knowledge and not at all portable. It's as related to CloudWatch as _get_client...

@arikfr
Copy link
Member Author

arikfr commented Nov 25, 2019

I'm looking at it not at the class level, but the module level. redash.query_runner.cloudwatch is a module about accessing CloudWatch metrics. It has the CloudWatch class which is the Redash driver/interface and parse_response which is used to parse responses coming from the API.

There is also a benefit in testing: it makes it trivial to test parse_response without having to go through the whole CloudWatch class. Of course it could be a staticmethod on the CloudWatch class, but I don't see much benefit in doing so.

@kangzj
Copy link

kangzj commented Jul 13, 2020

@arikfr Hi mate, good job & great effort
I'm a newbie to redash. May I ask how to query from CloudWatch? It doesn't seem to work the normal way. Thanks
image

@susodapop
Copy link
Contributor

Hey @kangzj, the CloudWatch query runner documentation is underway. The associated issue is getredash/website#453. This data source is part of V9 which is still in beta. The doc should be ready before the full release.

The short answer is that you don't use SQL to query CloudWatch. It uses a YAML query (similar to the JSON query source or MongoDB).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants