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;
私の 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>
編集:また、このコードを Azure のテスト環境にデプロイしましたが、問題なく動作します。
EDIT 2 : Service Definitions 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>
ユーザー @Igorek の回答を読んだ後、 ServiceDefinition.csdef 構成 XML を含めました。構成の LocalResources > LocalStorage 部分をどのように構成する必要があるかはまだわかりません。「MyApp.Website」の構成を設定する必要があります。
編集 3: テスト用の Azure アカウントにこれらの変更を加えました。
これを ServiceDefinitions.csdef に設定しました
<LocalResources>
<LocalStorage name="DiagnosticStore" sizeInMB="4096" cleanOnRoleRecycle="false"/>
</LocalResources>
そして、diagnostics.wadcfg でOverallQuotaと BufferQuota を下げました。
結果を見るには、これをライブアカウントに入れる必要があります。
最終編集:保証はできませんが、明らかに全体的なクォータが問題でした。
最後に、新しいパブリッシュの後、私はこれに気付きました:
- ロール インスタンスには、1024MB の構成 XML
wad-control-container
と1024MB の BufferQuotaInMB がありoverall quota
ました-- > これは正しかったです。 - 別の 2 つのロール インスタンスの全体的なクォータは4080MBで、BufferQuotaInMB は500MBでした --> これは誤りで、WADPerformanceCounters テーブルに書き込まれませんでした。
wad-control-container
各ロール インスタンスに属するXML 構成ファイル (にあった) の両方が、新しい発行の前に削除されました。- 構成ファイル
diagnostics.wadcfg
は正しく構成されました: 1024MBごとに
ですから、出版社に問題があると思います。
2 つの解決策が試されました。
「wad-control-container」から間違った XML を 1 つ削除し、マシンを再起動しました。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); } }
また、時々このエラーが発生しますThe configuration file is missing a diagnostic connection string for one or more roles
。
問題が見つかったので、最後に現在の回答を回答として選択します。残念ながら、問題の原因は見つかりませんでした。パブリッシュするたびに、変更された構成 XML を取得するリスクがあります。