private void GetPerformanceStats(ContainerStatsResponse stats) { if (stats == null) { return; } var perfData = new PerfData { TotalCpuUsage = stats.CPUStats?.CPUUsage?.TotalUsage, TotalMemoryUsage = stats.MemoryStats?.Usage, MemoryLimit = stats.MemoryStats?.Limit, ReadBytes = stats.StorageStats?.ReadSizeBytes, WriteBytes = stats.StorageStats?.WriteSizeBytes, Timestamp = stats.Read, ContainerName = stats.Name.Trim('/'), ContainerId = stats.ID }; // Console.WriteLine("Writing data to PerfDictByName, and Container ID is:" + perfData.ContainerId.ToString()); //_elasticClient.WriteToEs(perfData); if (PerfDictByName.ContainsKey(perfData.ContainerName)) { PerfDictByName[perfData.ContainerName] = perfData; } else { PerfDictByName.Add(perfData.ContainerName, perfData); } if (PerfDictByID.ContainsKey(perfData.ContainerId)) { PerfDictByID[perfData.ContainerId] = perfData; } else { PerfDictByID.Add(perfData.ContainerId, perfData); } }
/// <summary> /// Writes the document to elasticsearch with the default index /// </summary> /// <param name="data">Document data to insert</param> public void WriteToEs(PerfData data) { _client.IndexDocument(data); }