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

[amg] Azure managed grafana options for notification channels #5033

Merged

Conversation

michelletaal-shell
Copy link
Contributor


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

General Guidelines

  • [ x] Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • [ x] Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
The precondition is to put your code inside this repository and upgrade the version in the pull request but do not modify src/index.json.

@ghost ghost added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Jun 22, 2022
@ghost
Copy link

ghost commented Jun 22, 2022

Thank you for your contribution michelletaal-shell! We will review the pull request and get back to you soon.

@ghost
Copy link

ghost commented Jun 22, 2022

CLA assistant check
All CLA requirements met.

@ghost ghost requested a review from yonzhan June 22, 2022 14:37
@ghost ghost added the Auto-Assign Auto assign by bot label Jun 22, 2022
@ghost ghost requested a review from wangzelin007 June 22, 2022 14:37
@ghost ghost assigned kairu-ms Jun 22, 2022
@ghost ghost added this to the Jun 2022 (2022-07-05) milestone Jun 22, 2022
@ghost ghost added the extension/grafana az grafana label Jun 22, 2022
@ghost ghost requested review from kairu-ms and jsntcy June 22, 2022 14:37
@yonzhan
Copy link
Collaborator

yonzhan commented Jun 22, 2022

amg

@yugangw-msft
Copy link
Contributor

@kairu-ms, can you please review this PR and merge appropriately?

@@ -32,6 +32,15 @@ def load_command_table(self, _):
g.custom_command('query', 'query_data_source')
g.custom_command('update', 'update_data_source')

with self.command_group('grafana notification-channel') as g:
g.custom_command('list', 'list_notification_channels')
g.custom_command('list-short', 'list_notification_channels_short')
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we merge this with list command and expose an argument of --short

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Valid suggestion. Applied in commit [REV1]

@@ -43,6 +43,10 @@ def load_arguments(self, _):
c.argument("data_source", help="name, id, uid which can identify a data source. CLI will search in the order of name, id, and uid, till finds a match")
c.argument("definition", help="json string with data source definition, or a path to a file with such content")

with self.argument_context("grafana notification-channel") as c:
c.argument("notification_channel", help="id, uid which can identify a data source. CLI will search in the order of id, and uid, till finds a match")
c.argument("definition", help="json string with notification channel definition, or a path to a file with such content")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use type=validate_file_or_dict for json string or json file.

c.argument('activities', type=validate_file_or_dict, help='List of activities in pipeline. Expected value: '
'json-string/json-file/@json-file.')
c.argument('parameters', type=validate_file_or_dict, help='List of parameters for pipeline. Expected value: '
'json-string/json-file/@json-file.')
c.argument('variables', type=validate_file_or_dict, help='List of variables for pipeline. Expected value: '
'json-string/json-file/@json-file.')

Copy link
Contributor Author

@michelletaal-shell michelletaal-shell Jun 24, 2022

Choose a reason for hiding this comment

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

Currently, none of the arguments have type validation in place. Would you like me to expand my scope slightly and add type validation to all pre-existing commands as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, please. BTW, we usually don't need to specify type for most simple arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied in commits [REV2]

Type validation of the argument was added, leading to improved error messaging but also to conflict with the _try_load_file_content function currently executing type validation. This function was therefore omitted for all cli arguments except 'az grafana dashboard import' as this command takes int, str and json objects.

@kairu-ms
Copy link
Contributor

Could you add tests for your changes?

@yugangw-msft
Copy link
Contributor

@michelletaal-shell your PR looks solid we would like to merge. Do you need any help on adding the test? Assume you have followed the dev doc, you can add a test in /tests/latest/test_amg_scenario.py, then run azdev test amg which should generate a new test recording yaml file under /tests/latest/recordings/. You can then add both files to the PR.

Or I can push the test change to your branch if you prefer.

@michelletaal-shell
Copy link
Contributor Author

michelletaal-shell commented Jul 5, 2022

@michelletaal-shell your PR looks solid we would like to merge. Do you need any help on adding the test? Assume you have followed the dev doc, you can add a test in /tests/latest/test_amg_scenario.py, then run azdev test amg which should generate a new test recording yaml file under /tests/latest/recordings/. You can then add both files to the PR.

Or I can push the test change to your branch if you prefer.

Thank you for accepting my pr.

I've been working on writing some tests, but have been otherwise occupied the last few days. I've been having issues with the tests as automatically setting up the Managed Identity requires Azure permissions I don't have in my professional subscription. I'll be trying to work my way around that later this week. I suspect this is why there are also no tests for the other API-call functionalities. Once I get over that hump, the actual tests should be in place rather quickly.

@yugangw-msft
Copy link
Contributor

@michelletaal-shell, sounds good. If the permission is hard to workaround, az grafana create has skip arguments to bypass those. Hope it helps.

@yugangw-msft
Copy link
Contributor

yugangw-msft commented Jul 14, 2022

@michelletaal-shell, let you know that we are on the way to move to Grafana 9.0 with unified alerting. This will light up the contact-point which is similar with notification channel. I suggest we hold on to this PR and I will work with you in a couple of weeks to migrate this PR to support contact-point. Will that work for you?

@michelletaal-shell
Copy link
Contributor Author

@yugangw-msft, thank you for the update. I'm nearly done with setting up tests for all features and will commit those this week. I'm definitely willing to work with you to support contact point. Just let me know when you guys are ready to move forward.

@kairu-ms
Copy link
Contributor

@yugangw-msft does this PR ready for review and merge?

@yugangw-msft
Copy link
Contributor

@kairu-ms, please merge.
Note, I will have one more PR for AMG's GA feature to submit this week. Once that is in, I will bump the version to release these 2 change together.

@kairu-ms kairu-ms merged commit b0ebdda into Azure:main Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. extension/grafana az grafana
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants