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

CloudWatch: Add account support to variable queries #63822

Merged
merged 8 commits into from Mar 3, 2023
Merged

Conversation

iwysiu
Copy link
Contributor

@iwysiu iwysiu commented Feb 27, 2023

What is this feature?
Supports cross-account variable queries by adding the AccountId field to variable queries for log groups, metrics, dimension keys, and dimension values.

Why do we need this feature?
Cross account querying should also be supported by variable queries.

Which issue(s) does this PR fix?:

Fixes #61450

Special notes for your reviewer:
I went through all the variable query types and I believe that these are the only ones that support accountId

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2023

Backend code coverage report for PR #63822
No changes

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2023

Frontend code coverage report for PR #63822

Plugin Main PR Difference
cloudwatch 82.23% 82.22% -.01%

@iwysiu iwysiu marked this pull request as ready for review February 28, 2023 14:01
@iwysiu iwysiu requested a review from a team as a code owner February 28, 2023 14:01
@iwysiu iwysiu requested review from fridgepoet and sarahzinger and removed request for a team February 28, 2023 14:01
Copy link
Member

@fridgepoet fridgepoet left a comment

Choose a reason for hiding this comment

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

Nice!

What behavior do you expect when I choose a Region in which I have no accounts? I'm just wondering because when I test it out I see the Account field just disappear and am not sure if it should be active but with an empty dropdown, for example.

@fridgepoet
Copy link
Member

For any other readers, here's a screenshot of the field this PR adds in the variable query editor:
Screenshot 2023-03-01 at 10 42 08

Copy link
Contributor Author

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

Good catch on the region thing! Updated the resource api. Also thanks for the screenshot

Copy link
Contributor

@idastambuk idastambuk left a comment

Choose a reason for hiding this comment

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

Looks good, but I was testing the variable editor and when I select 'All' in the dropdown, nothing happens when I click the Run query button, so I dont see the change in query results as I expected. Is this intended behaviour?

label="Account"
value={query.accountId ?? null}
onChange={(accountId?: string) => onQueryChange({ ...parsedQuery, accountId })}
options={accountState?.value.length ? [ALL_ACCOUNTS_OPTION, ...accountState?.value] : []}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
options={accountState?.value.length ? [ALL_ACCOUNTS_OPTION, ...accountState?.value] : []}
options={[ALL_ACCOUNTS_OPTION, ...accountState?.value]}

There's a condition above that checks for accountState.value.length, I dont think we need it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

Looks good, but I was testing the variable editor and when I select 'All' in the dropdown, nothing happens when I click the Run query button, so I dont see the change in query results as I expected. Is this intended behaviour?

The form auto-reruns the query, so if you select a log group query, look at the results, then select all for the account it should change

label="Account"
value={query.accountId ?? null}
onChange={(accountId?: string) => onQueryChange({ ...parsedQuery, accountId })}
options={accountState?.value.length ? [ALL_ACCOUNTS_OPTION, ...accountState?.value] : []}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@iwysiu iwysiu requested a review from idastambuk March 2, 2023 18:40
@iwysiu iwysiu merged commit 59ac0a0 into main Mar 3, 2023
@iwysiu iwysiu deleted the iwysiu/61450 branch March 3, 2023 14:26
baldm0mma pushed a commit that referenced this pull request Mar 6, 2023
Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CloudWatch: Make variable queries cross-account compatible
5 participants