Skip to content

Commit 2ddb7f7

Browse files
authored
Azure Monitor API rejecting timespan format (#1003)
* Azure Monitor API rejecting timespan format * Azure Monitor API rejecting timespan format
1 parent 45d7eae commit 2ddb7f7

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

cloud_governance/common/clouds/azure/monitor/monitor_management_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_resource_metrics(self, resource_id: str, metricnames: str, aggregation:
8181
if not timespan:
8282
end_date = datetime.now(tz=timezone.utc)
8383
start_date = end_date - timedelta(days=UNUSED_DAYS)
84-
timespan = f'{start_date}/{end_date}'
84+
timespan = f'{start_date.isoformat()}/{end_date.isoformat()}'
8585
response = self.__monitor_client.metrics.list(resource_uri=resource_id, timespan=timespan,
8686
metricnames=metricnames, aggregation=aggregation,
8787
result_type='Data', interval=interval,

cloud_governance/policy/helpers/azure/azure_policy_operations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def get_cpu_utilization_percentage_metric(self, resource_id: str, days: int = IN
199199
:rtype:
200200
"""
201201
start_date, end_date = Utils.get_start_and_end_datetime(days=days)
202-
timespan = f'{start_date}/{end_date}'
202+
timespan = f'{start_date.isoformat()}/{end_date.isoformat()}'
203203
cpu_metrics = self.monitor_operations.get_resource_metrics(resource_id=resource_id,
204204
metricnames='Percentage CPU',
205205
aggregation='Average',
@@ -218,7 +218,7 @@ def get_network_in_kib_metric(self, resource_id: str, days: int = INSTANCE_IDLE_
218218
:rtype:
219219
"""
220220
start_date, end_date = Utils.get_start_and_end_datetime(days=days)
221-
timespan = f'{start_date}/{end_date}'
221+
timespan = f'{start_date.isoformat()}/{end_date.isoformat()}'
222222
network_in_metrics = self.monitor_operations.get_resource_metrics(resource_id=resource_id,
223223
metricnames='Network In Total',
224224
aggregation='Average',
@@ -238,7 +238,7 @@ def get_network_out_kib_metric(self, resource_id: str, days: int = INSTANCE_IDLE
238238
:rtype:
239239
"""
240240
start_date, end_date = Utils.get_start_and_end_datetime(days=days)
241-
timespan = f'{start_date}/{end_date}'
241+
timespan = f'{start_date.isoformat()}/{end_date.isoformat()}'
242242
network_out_metrics = self.monitor_operations.get_resource_metrics(resource_id=resource_id,
243243
metricnames='Network Out Total',
244244
aggregation='Average',

0 commit comments

Comments
 (0)