Dra*_*lut 6 c# azure azure-diagnostics
我正在尝试从Azure WadPerformanceCountersTable查询数据.
我想要获取最后5分钟的数据.
问题是我只从实例nr获取数据.4,5和6,但不是0,1,2和3.
我用来拉取数据的脚本是这样的:
Microsoft.WindowsAzure.CloudStorageAccount storageAccount = Microsoft.WindowsAzure.CloudStorageAccount.Parse(AppDefs.CloudStorageAccountConnectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
TableServiceContext serviceContext = cloudTableClient.GetDataServiceContext();
IQueryable<PerformanceCountersEntity> traceLogsTable = serviceContext.CreateQuery<PerformanceCountersEntity>("WADPerformanceCountersTable");
var selection = from row in traceLogsTable
where row.PartitionKey.CompareTo("0" + DateTime.UtcNow.AddMinutes(-timespanInMinutes).Ticks) >= 0
&& row.DeploymentId == deploymentId
&& row.CounterName == @"\Processor(_Total)\% Processor Time"
select row;
CloudTableQuery<PerformanceCountersEntity> query = selection.AsTableServiceQuery<PerformanceCountersEntity>();
IEnumerable<PerformanceCountersEntity> result = query.Execute();
return result;
Run Code Online (Sandbox Code Playgroud)
我的diagnostics.wadcfg文件是这样的:
<?xml version="1.0" encoding="utf-8" ?>
<DiagnosticMonitorConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration" configurationChangePollInterval="PT1M" overallQuotaInMB="4096">
<PerformanceCounters bufferQuotaInMB="0" scheduledTransferPeriod="PT5M">
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available Bytes" sampleRate="PT60S" />
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT60S" />
</PerformanceCounters>
</DiagnosticMonitorConfiguration>
Run Code Online (Sandbox Code Playgroud)
编辑:此外,我有这个代码部署在天蓝色的测试环境中,它的工作正常.
编辑2:更新以包含服务定义XML:
<ServiceDefinition name="MyApp.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
<WebRole name="MyApp.Website" vmsize="ExtraSmall">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
</WebRole>
<WorkerRole name="MyApp.Cache" vmsize="ExtraSmall">
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="Caching" />
</Imports>
<LocalResources>
<LocalStorage name="Microsoft.WindowsAzure.Plugins.Caching.FileStore" sizeInMB="1000" cleanOnRoleRecycle="false" />
</LocalResources>
</WorkerRole>
</ServiceDefinition>
Run Code Online (Sandbox Code Playgroud)
在我阅读了用户@Igorek的回答之后,我已经包含了我的ServiceDefinition.csdef配置XML.我仍然不知道如何配置LocalResources> LocalStorage配置部分.必须为"MyApp.Website"设置配置.
编辑3:我已经对测试azure帐户进行了这些更改.
我在ServiceDefinitions.csdef中设置了它
<LocalResources>
<LocalStorage name="DiagnosticStore" sizeInMB="4096" cleanOnRoleRecycle="false"/>
</LocalResources>
Run Code Online (Sandbox Code Playgroud)
我已经降低了diagnostics.wadcfg中的OverallQuota和BufferQuota最后,在WAD-control-container中,每个实例都有这个配置:http: //pastebin.com/aUywLUfE
我必须将其放在真实账户上以查看结果.
最终编辑:显然整体配额是问题,即使我无法保证.
最后,在新发布后我注意到了这一点:
wad-control-container具有overall quota的1024MB和BufferQuotaInMB 1024MB - >这是正确的,wad-control-container在新发布之前,删除了属于每个角色实例的两个XML配置文件(属于).diagnostics.wadcfg配置正确:每个1024MB所以我认为他们的出版商存在问题.
尝试了两种解决方案:
我从'wad-control-container'中删除了 1个不正确的XML并重启了该机器.XML被重写,角色实例开始在WADPerfCountTable中写入.
我在另一个不正确的实例上使用了下面的脚本,并且错误的角色实例开始在WADPerfCountTable中写入.
var storageAccount = CloudStorageAccount.Parse(AppDefs.CloudStorageAccountConnectionString);
DeploymentDiagnosticManager diagManager = new DeploymentDiagnosticManager(storageAccount, deploymentId);
IEnumerable<RoleInstanceDiagnosticManager> instanceManagers = diagManager.GetRoleInstanceDiagnosticManagersForRole(roleName);
foreach (var roleInstance in instanceManagers)
{
DiagnosticMonitorConfiguration currentConfiguration = roleInstance.GetCurrentConfiguration();
TimeSpan configurationChangePollInterval = TimeSpan.FromSeconds(60);
if (!IsCurrentConfigurationCorrect(currentConfiguration, overallQuotaInMb, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1)))
{
// Add a performance counter for processor time.
PerformanceCounterConfiguration pccCPU = new PerformanceCounterConfiguration();
pccCPU.CounterSpecifier = @"\Processor(_Total)\% Processor Time";
pccCPU.SampleRate = TimeSpan.FromSeconds(60);
// Add a performance counter for available memory.
PerformanceCounterConfiguration pccMemory = new PerformanceCounterConfiguration();
pccMemory.CounterSpecifier = @"\Memory\Available Bytes";
pccMemory.SampleRate = TimeSpan.FromSeconds(60);
currentConfiguration.ConfigurationChangePollInterval = TimeSpan.FromSeconds(60);
currentConfiguration.OverallQuotaInMB = overallQuotaInMb;
currentConfiguration.PerformanceCounters.BufferQuotaInMB = overallQuotaInMb;
currentConfiguration.PerformanceCounters.DataSources.Add(pccCPU);
currentConfiguration.PerformanceCounters.DataSources.Add(pccMemory);
roleInstance.SetCurrentConfiguration(currentConfiguration);
}
}
Run Code Online (Sandbox Code Playgroud)此外,我不时收到此错误The configuration file is missing a diagnostic connection string for one or more roles.
最后,我将选择当前的响应作为答案,因为我发现了问题.不幸的是,我还没有找到问题的原因.在每次发布时,我都有可能获得更改的配置XML.
查看您的第一个实例如何不将数据传输到诊断,而后面的实例则这样做,一个可能的原因如下:
服务器上的本地诊断存储已填满诊断数据,Azure 无法再将数据从本地存储传输到存储。确保在角色配置(本地存储下)中分配给 DiagnosticStore 的空间大于在diagnostics.wadcfg 中分配的缓冲区配额量
详细说明:我与许多客户有过亲身经历,因此以下是我根据 Microsoft 支持人员的评论得出的自己的解释。Azure 诊断 API 不会根据 BufferQuota 清理本地存储,直到超出该配额。云项目中的 DiagnosticStore 默认大小与所有示例中使用的 BufferQuota 大小相同 (4096)。发生的情况是,您的 BufferQuota 非常接近 4096megs,但不等于限制,并且您的诊断 API 不会启动清除过程。同时,您对诊断数据的捕获无法再正常运行,因为本地存储几乎已满,并且 Azure 主机停止了应用程序写入 DiagnosticStore 的能力。
一旦本地存储填满,您的其他服务器也应该停止写入诊断数据。
希望这是有道理的。
编辑我的回复,以便为稍后阅读的人准确指出更改:
最简单的方法是将在diagnostics.wadcfg 中指定的OverallQuotaInMb 的需求降低到4000 左右(请确保所有其他缓冲区组合不超过此数字)
或者或另外,可以使用 .CSDEF 文件中的 LocalStorage 设置手动指定分配给 VM 上诊断存储的空间。此链接显示了如何操作:http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.diagnostics.diagnosticmonitorconfiguration.overallquotainmb.aspx
| 归档时间: |
|
| 查看次数: |
586 次 |
| 最近记录: |