def __init__(self, arguments):
        super().__init__(arguments)

        # auth configuration
        self.metrics_uri = self.get_from_env('METRICS_RESOURCE_URI')
        self.names = ["MatchedEventCount"]
        self.aggregations = [MetricAggregationType.COUNT]

        # Create clients
        self.metrics_client = SyncMetricsQueryClient(
            credential=SyncDefaultAzureCredential())
        self.async_metrics_client = AsyncMetricsQueryClient(
            credential=AsyncDefaultAzureCredential())
Example #2
0
    def __init__(self, arguments):
        super().__init__(arguments)

        # auth configuration
        self.workspace_id = self.get_from_env('LOG_WORKSPACE_ID')

        self.query = "AppRequests | summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId"

        # Create clients
        self.logs_client = SyncLogsQueryClient(
            credential=SyncDefaultAzureCredential())
        self.async_logs_client = AsyncLogsQueryClient(
            credential=AsyncDefaultAzureCredential())
    def __init__(self, arguments):
        super().__init__(arguments)

        # auth configuration
        self.workspace_id = self.get_from_env('LOG_WORKSPACE_ID')

        # Create clients
        self.logs_client = SyncLogsQueryClient(
            credential=SyncDefaultAzureCredential())
        self.async_logs_client = AsyncLogsQueryClient(
            credential=AsyncDefaultAzureCredential())

        self.requests = [
            LogsQueryRequest(query="AzureActivity | summarize count()",
                             start_time=datetime(2021,
                                                 7,
                                                 25,
                                                 0,
                                                 0,
                                                 0,
                                                 tzinfo=timezone.utc),
                             end_time=datetime(2021,
                                               7,
                                               26,
                                               0,
                                               0,
                                               0,
                                               tzinfo=timezone.utc),
                             workspace_id=self.workspace_id),
            LogsQueryRequest(query="""AppRequests | take 10  |
                    summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId""",
                             start_time=datetime(2021,
                                                 7,
                                                 25,
                                                 0,
                                                 0,
                                                 0,
                                                 tzinfo=timezone.utc),
                             end_time=datetime(2021,
                                               7,
                                               26,
                                               0,
                                               0,
                                               0,
                                               tzinfo=timezone.utc),
                             workspace_id=self.workspace_id),
            LogsQueryRequest(query="AppRequests | take 20",
                             workspace_id=self.workspace_id,
                             include_statistics=True),
        ]
Example #4
0
def create_resource_processor_status() -> (StatusEnum, str):
    status = StatusEnum.ok
    message = ""
    try:
        vmss_name = f"vmss-rp-porter-{config.TRE_ID}"
        credential = SyncDefaultAzureCredential(
            managed_identity_client_id=config.MANAGED_IDENTITY_CLIENT_ID)
        compute_client = ComputeManagementClient(
            credential=credential, subscription_id=config.SUBSCRIPTION_ID)
        vmss_list = compute_client.virtual_machine_scale_set_vms.list(
            config.RESOURCE_GROUP_NAME, vmss_name)
        for vm in vmss_list:
            instance_view = compute_client.virtual_machine_scale_set_vms.get_instance_view(
                config.RESOURCE_GROUP_NAME, vmss_name, vm.instance_id)
            health_status = instance_view.vm_health.status.code
            if health_status != strings.RESOURCE_PROCESSOR_HEALTHY_MESSAGE:
                status = StatusEnum.not_ok
                message = strings.RESOURCE_PROCESSOR_GENERAL_ERROR_MESSAGE
    except:  # noqa: E722 flake8 - no bare excepts
        status = StatusEnum.not_ok
        message = strings.UNSPECIFIED_ERROR
    return status, message