-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Closed
Copy link
Labels
MgmtThis issue is related to a management-plane library.This issue is related to a management-plane library.MonitorMonitor, Monitor Ingestion, Monitor QueryMonitor, Monitor Ingestion, Monitor QueryService AttentionWorkflow: This issue is responsible by Azure service team.Workflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.Workflow: More information is needed from author to address the issue.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Description
- Package Name: azure-mgmt-monitor
- Package Version: 0.9.0
- Operating System: CentOS Linux 7
- Python Version: 2.7.5
Describe the bug
Monitoring outputs different results depending on what times I enter to the query.
To Reproduce
Steps to reproduce the behavior:
- Run example code:
#!/usr/bin/python
# Python imports
import datetime
import json
# Azure imports
import adal
from azure.mgmt.monitor import MonitorManagementClient
from azure.mgmt.resource import ResourceManagementClient
from msrestazure.azure_active_directory import AADTokenCredentials
from msrestazure.azure_cloud import AZURE_PUBLIC_CLOUD
# Customer data
client_id = "<snip>"
pem_file = "<snip>"
pem_thumbprint = "<snip>"
resource_group = "<snip>"
resource_name = "<snip>"
subscription_id = "<snip>"
tenant_id = "<snip>"
# Read PEM-file
with open(pem_file, 'r') as file:
pem_key = file.read()
# Create authentication context
login_endpoint = AZURE_PUBLIC_CLOUD.endpoints.active_directory
api = AZURE_PUBLIC_CLOUD.endpoints.active_directory_resource_id
context = adal.AuthenticationContext("{}/{}".format(
login_endpoint,
tenant_id
))
# Acquire token with client certificate
management_token = context.acquire_token_with_client_certificate(
api,
client_id,
pem_key,
pem_thumbprint
)
# Create credentials object
credentials = AADTokenCredentials(
management_token,
client_id
)
# Instantiate new monitoring client
client = MonitorManagementClient(
credentials,
subscription_id
)
# Create resource ID
resource_id = ('subscriptions/{}/resourceGroups/{}/providers/Microsoft.DBforMySQL/servers/{}').format(
subscription_id,
resource_group,
resource_name
)
# Set explicit datetimes to retrieve data from
datetimes = [
{
"start_time": datetime.datetime.strptime('2020-05-27T10:19:25', '%Y-%m-%dT%H:%M:%S'), # Zabbix epoch
"end_time": datetime.datetime.strptime('2020-05-27T10:20:25', '%Y-%m-%dT%H:%M:%S')
},
{
"start_time": datetime.datetime.strptime('2020-05-27T10:20:25', '%Y-%m-%dT%H:%M:%S'), # Zabbix epoch
"end_time": datetime.datetime.strptime('2020-05-27T10:21:25', '%Y-%m-%dT%H:%M:%S')
},
{
"start_time": datetime.datetime.strptime('2020-05-27T10:21:25', '%Y-%m-%dT%H:%M:%S'), # Zabbix epoch
"end_time": datetime.datetime.strptime('2020-05-27T10:22:26', '%Y-%m-%dT%H:%M:%S')
},
{
"start_time": datetime.datetime.strptime('2020-05-27T10:19:00', '%Y-%m-%dT%H:%M:%S'), # Even minute
"end_time": datetime.datetime.strptime('2020-05-27T10:20:00', '%Y-%m-%dT%H:%M:%S')
},
{
"start_time": datetime.datetime.strptime('2020-05-27T10:20:00', '%Y-%m-%dT%H:%M:%S'), # Even minute
"end_time": datetime.datetime.strptime('2020-05-27T10:21:00', '%Y-%m-%dT%H:%M:%S')
},
{
"start_time": datetime.datetime.strptime('2020-05-27T10:21:00', '%Y-%m-%dT%H:%M:%S'), # Even minute
"end_time": datetime.datetime.strptime('2020-05-27T10:22:00', '%Y-%m-%dT%H:%M:%S')
},
{
"start_time": datetime.datetime.strptime('2020-05-27T10:20:00', '%Y-%m-%dT%H:%M:%S'), # Two minutes
"end_time": datetime.datetime.strptime('2020-05-27T10:22:00', '%Y-%m-%dT%H:%M:%S')
}
]
# Loop datetimes, retrieve and output data
for item in datetimes:
print("start_time: {}".format(item["start_time"].strftime('%Y-%m-%dT%H:%M:%SZ')))
print("end_time: {}".format(item["end_time"].strftime('%Y-%m-%dT%H:%M:%SZ')))
metrics_data = client.metrics.list(
resource_id,
timespan="{}/{}".format(
item["start_time"].strftime('%Y-%m-%dT%H:%M:%SZ'),
item["end_time"].strftime('%Y-%m-%dT%H:%M:%SZ')
),
interval="PT1M",
metricnames="connections_failed",
aggregation="Total",
result_type="Data",
timeout=15
)
# Loop metric/timeserie/data and output results
for item in metrics_data.value:
for timeserie in item.timeseries:
for data in timeserie.data:
print(data)
print("")
- Check output:
start_time: 2020-05-27T10:19:25Z
end_time: 2020-05-27T10:20:25Z
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 19, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 0.0}
start_time: 2020-05-27T10:20:25Z
end_time: 2020-05-27T10:21:25Z
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 20, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 0.0}
start_time: 2020-05-27T10:21:25Z
end_time: 2020-05-27T10:22:26Z
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 21, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 0.0}
start_time: 2020-05-27T10:19:00Z
end_time: 2020-05-27T10:20:00Z
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 19, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 0.0}
start_time: 2020-05-27T10:20:00Z
end_time: 2020-05-27T10:21:00Z
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 20, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 0.0}
start_time: 2020-05-27T10:21:00Z
end_time: 2020-05-27T10:22:00Z
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 21, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 0.0}
start_time: 2020-05-27T10:20:00Z
end_time: 2020-05-27T10:22:00Z
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 20, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 2.0}
{'count': None, 'average': None, 'maximum': None, 'minimum': None, 'additional_properties': {}, 'time_stamp': datetime.datetime(2020, 5, 27, 10, 21, tzinfo=<isodate.tzinfo.Utc object at 0x7fc3615f0550>), 'total': 3.0}
Expected behavior
I expected to receive a total of 2.0 at time 10:20 and a total of 3.0 at time 10:21.
Additional context
I cannot enter customer data here so I believe this might not be as easy to reproduce. If you need further information, please contact me. I can also reproduce this using the Azure CLI. I'll be happy to provide additional information about this.
Metadata
Metadata
Assignees
Labels
MgmtThis issue is related to a management-plane library.This issue is related to a management-plane library.MonitorMonitor, Monitor Ingestion, Monitor QueryMonitor, Monitor Ingestion, Monitor QueryService AttentionWorkflow: This issue is responsible by Azure service team.Workflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.Workflow: More information is needed from author to address the issue.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that