-
Notifications
You must be signed in to change notification settings - Fork 3.2k
add more samples #15007
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
Merged
Merged
add more samples #15007
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
425a91d
add more samples
xiangyan99 69759d6
Update sdk/metricsadvisor/azure-ai-metricsadvisor/samples/README.md
xiangyan99 b01db2f
Update sdk/metricsadvisor/azure-ai-metricsadvisor/samples/async_sampl…
xiangyan99 ed787f4
Update sdk/metricsadvisor/azure-ai-metricsadvisor/samples/async_sampl…
xiangyan99 b949588
update
xiangyan99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,18 +19,17 @@ | |
| 1) METRICS_ADVISOR_ENDPOINT - the endpoint of your Azure Metrics Advisor service | ||
| 2) METRICS_ADVISOR_SUBSCRIPTION_KEY - Metrics Advisor service subscription key | ||
| 3) METRICS_ADVISOR_API_KEY - Metrics Advisor service API key | ||
| 4) METRICS_ADVISOR_METRIC_ID - the ID of an metric from an existing data feed | ||
| 5) METRICS_ADVISOR_ANOMALY_DETECTION_CONFIGURATION_ID - the ID of an anomaly detection configuration | ||
| 6) METRICS_ADVISOR_ALERT_CONFIGURATION_ID - the ID of an alert configuration | ||
| 7) METRICS_ADVISOR_INCIDENT_ID - the ID of an incident | ||
| 8) METRICS_ADVISOR_ALERT_ID - the ID of an alert | ||
| 4) METRICS_ADVISOR_ANOMALY_DETECTION_CONFIGURATION_ID - the ID of an anomaly detection configuration | ||
|
||
| 5) METRICS_ADVISOR_ALERT_CONFIGURATION_ID - the ID of an alert configuration | ||
| 6) METRICS_ADVISOR_INCIDENT_ID - the ID of an incident | ||
| 7) METRICS_ADVISOR_ALERT_ID - the ID of an alert | ||
| """ | ||
|
|
||
| import os | ||
| import asyncio | ||
|
|
||
|
|
||
| def sample_list_incidents_for_detection_configuration(): | ||
| async def sample_list_incidents_for_detection_configuration_async(): | ||
| # [START list_incidents_for_detection_configuration_async] | ||
| import datetime | ||
| from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential | ||
|
|
@@ -44,20 +43,20 @@ def sample_list_incidents_for_detection_configuration(): | |
| client = MetricsAdvisorClient(service_endpoint, | ||
| MetricsAdvisorKeyCredential(subscription_key, api_key)) | ||
| async with client: | ||
| results = client.list_incidents_for_detection_configuration( | ||
| results = client.list_incidents( | ||
| detection_configuration_id=anomaly_detection_configuration_id, | ||
| start_time=datetime.datetime(2020, 1, 1), | ||
| end_time=datetime.datetime(2020, 9, 9), | ||
| ) | ||
| for result in results: | ||
| async for result in results: | ||
| print("Metric id: {}".format(result.metric_id)) | ||
| print("Incident ID: {}".format(result.id)) | ||
| print("Severity: {}".format(result.severity)) | ||
| print("Status: {}".format(result.status)) | ||
|
|
||
| # [END list_incidents_for_detection_configuration_async] | ||
|
|
||
| def sample_list_incident_root_cause(): | ||
| async def sample_list_incident_root_cause_async(): | ||
| # [START list_incident_root_cause_async] | ||
| from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential | ||
| from azure.ai.metricsadvisor.aio import MetricsAdvisorClient | ||
|
|
@@ -75,13 +74,13 @@ def sample_list_incident_root_cause(): | |
| detection_configuration_id=anomaly_detection_configuration_id, | ||
| incident_id=incident_id, | ||
| ) | ||
| for result in results: | ||
| async for result in results: | ||
| print("Score: {}".format(result.score)) | ||
| print("Description: {}".format(result.description)) | ||
|
|
||
| # [END list_incident_root_cause_async] | ||
|
|
||
| def sample_list_incidents_for_alert(): | ||
| async def sample_list_incidents_for_alert_async(): | ||
| # [START list_incidents_for_alert_async] | ||
| from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential | ||
| from azure.ai.metricsadvisor.aio import MetricsAdvisorClient | ||
|
|
@@ -95,11 +94,11 @@ def sample_list_incidents_for_alert(): | |
| client = MetricsAdvisorClient(service_endpoint, | ||
| MetricsAdvisorKeyCredential(subscription_key, api_key)) | ||
| async with client: | ||
| results = client.list_incidents_for_alert( | ||
| results = client.list_incidents( | ||
| alert_configuration_id=alert_configuration_id, | ||
| alert_id=alert_id, | ||
| ) | ||
| for result in results: | ||
| async for result in results: | ||
| print("Metric id: {}".format(result.metric_id)) | ||
| print("Incident ID: {}".format(result.id)) | ||
| print("Severity: {}".format(result.severity)) | ||
|
|
@@ -110,11 +109,11 @@ def sample_list_incidents_for_alert(): | |
|
|
||
| async def main(): | ||
| print("---List incidents for detection configuration...") | ||
| sample_list_incidents_for_detection_configuration() | ||
| await sample_list_incidents_for_detection_configuration_async() | ||
| print("---List root causes...") | ||
| sample_list_incident_root_cause() | ||
| await sample_list_incident_root_cause_async() | ||
| print("---List incidents for alert configuration...") | ||
| sample_list_incidents_for_alert() | ||
| await sample_list_incidents_for_alert_async() | ||
|
|
||
| if __name__ == '__main__': | ||
| loop = asyncio.get_event_loop() | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.