如何将应用程序见解添加到Azure批处理帐户

问题描述 投票:0回答:1

我正在按照本文档将见解添加到批处理帐户中。 文档

以下是添加见解的步骤。 步骤1:安装batch_insights.exe并添加到应用程序包中,因为我不想按照步骤中的描述随时添加。 步骤 2:添加环境变量,例如 ApplicationInsights_instrumentation key 和 application Id。 第 3 步:更新启动任务 -

%AZ_BATCH_APP_PACKAGE_batch_insights\batch-insights.exe /install /norestart && start /wait 

第4步:在document中指定添加一些python脚本,我们是否需要添加该步骤,如果是,我需要下载脚本以及之后如何运行,有人可以详细解释这个步骤.

azure azure-application-insights azure-batch
1个回答
0
投票

您引用的存储库是旧的,Batch 服务资源管理器 api 现已更新为新功能。

请参阅此 MS 文档 通过 Application Insights 监控您的 Azure Batch 服务,它提供了通过 .Net 框架将日志写入 Application Insights 的示例。

安装此软件包:-

PM> Install-Package Microsoft.ApplicationInsights.WindowsServer

请参阅此 Github 示例以获得相同的信息。

ApplicationInsights.config
文件中更新 Application Insights Instrumentation 密钥:-

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
    <InstrumentationKey>InstrumentationKey=xxxxxxxxb8220f;IngestionEndpoint=https://australiacentral-0.in.applicationinsights.azure.com/;LiveEndpoint=https://australiacentral.livediagnostics.monitor.azure.com/</InstrumentationKey>
  <TelemetryInitializers>
    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
  </TelemetryInitializers>
  <TelemetryModules>
    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
      <ExcludeComponentCorrelationHttpHeadersOnDomains>
        <!-- 
        Requests to the following hostnames will not be modified by adding correlation headers. 
        This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
        Add entries here to exclude additional hostnames.
        NOTE: this configuration will be lost upon NuGet upgrade.
        -->
        <Add>core.windows.net</Add>
        <Add>core.chinacloudapi.cn</Add>
        <Add>core.cloudapi.de</Add>
        <Add>core.usgovcloudapi.net</Add>
      </ExcludeComponentCorrelationHttpHeadersOnDomains>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
      <!--
      Use the following syntax here to collect additional performance counters:
      
      <Counters>
        <Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
        ...
      </Counters>
      
      PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
      
      NOTE: performance counters configuration will be lost upon NuGet upgrade.
      
      The following placeholders are supported as InstanceName:
        ??APP_WIN32_PROC?? - instance name of the application process  for Win32 counters.
        ??APP_W3SVC_PROC?? - instance name of the application IIS worker process for IIS/ASP.NET counters.
        ??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
      -->
    </Add>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
  </TelemetryModules>
  <TelemetryProcessors>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
      <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
    </Add>
  </TelemetryProcessors>
  <TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
</ApplicationInsights>

尝试从示例中初始化 Application Insight 代码并运行您的应用程序。

您还可以使用 OpenTelemetry 在 python 文件中实现自定义代码,然后将自定义日志发送到 Application Insights。通过将该 python 文件作为启动任务运行。

请参阅我的 SO 答案 1 以使用 Opencensus 库将日志发送到应用程序洞察,并参考此 SO 答案 2 在 Azure Batch 服务中运行 python 脚本。

© www.soinside.com 2019 - 2024. All rights reserved.