private IEnumerable <MetricDataPoint> ProvideMetrics() { var metrics = counter.Collect(); foreach (var property in typeof(LogEventsMetrics).GetProperties()) { yield return(new MetricDataPoint( Convert.ToDouble(property.GetValue(metrics)), ("LogLevel", property.Name.Replace("LogEvents", string.Empty)))); } }
public void OnNext(HealthReport value) { foreach (var check in value.Checks) { context.Send( new MetricDataPoint( Convert.ToDouble(check.Value.Status), (WellKnownTagKeys.Name, "HealthCheckStatus"), ("HealthCheckName", check.Key)) { Timestamp = value.Timestamp }
private static IEnumerable <MetricDataPoint> ProvideMetrics(HostMetricsCollector collector) { var metrics = collector.Collect(); foreach (var property in typeof(HostMetrics).GetProperties()) { if (property.PropertyType.GetInterface(nameof(IDictionary)) == null) { yield return(new MetricDataPoint( Convert.ToDouble(property.GetValue(metrics)), (WellKnownTagKeys.Name, property.Name))); } } foreach (var tcpState in metrics.TcpStates.OrEmptyIfNull()) { yield return(new MetricDataPoint( Convert.ToDouble(tcpState.Value), (WellKnownTagKeys.Name, "TcpConnectionCountPerState"), (nameof(TcpState), tcpState.Key.ToString()) )); } foreach (var diskSpaceInfo in metrics.DisksSpaceInfo.OrEmptyIfNull()) { foreach (var property in typeof(DiskSpaceInfo).GetProperties()) { if (!property.Name.Equals(nameof(DiskSpaceInfo.DiskName)) && !property.Name.Equals(nameof(DiskSpaceInfo.RootDirectory))) { yield return(new MetricDataPoint( Convert.ToDouble(property.GetValue(diskSpaceInfo.Value)), (WellKnownTagKeys.Name, $"Disk{property.Name}"), (nameof(DiskSpaceInfo.DiskName), diskSpaceInfo.Value.DiskName) )); } } } foreach (var diskUsageInfo in metrics.DisksUsageInfo.OrEmptyIfNull()) { foreach (var property in typeof(DiskUsageInfo).GetProperties()) { if (!property.Name.Equals(nameof(DiskUsageInfo.DiskName))) { yield return(new MetricDataPoint( Convert.ToDouble(property.GetValue(diskUsageInfo.Value)), (WellKnownTagKeys.Name, $"Disk{property.Name}"), (nameof(DiskSpaceInfo.DiskName), diskUsageInfo.Value.DiskName) )); } } } }
public void OnNext(HealthReport value) { foreach (var keyValuePair in value.Checks) { context.Send( new MetricDataPoint( Convert.ToDouble(keyValuePair.Value.Status), (WellKnownTagKeys.Name, "HealthCheckStatus"), ("HealthCheckName", keyValuePair.Key) ) ); } }
private static IEnumerable <MetricDataPoint> ProvideMetrics(CurrentProcessMetricsCollector collector) { var metrics = collector.Collect(); foreach (var property in typeof(CurrentProcessMetrics).GetProperties()) { var value = property.GetValue(metrics); if (value != null) { yield return(new MetricDataPoint(Convert.ToDouble(value), (WellKnownTagKeys.Name, property.Name))); } } }
public MetricValueControl(WriteToLogDelegate writeToLog, Action closeAction, IEnumerable <MetricValue> metricValues, MetricDataPoint metricDataPoint, MetricInfo metricInfo) { this.writeToLog = writeToLog; this.closeAction = closeAction; this.metricDataPoint = metricDataPoint; this.metricInfo = metricInfo; InitializeComponent(); metricList = metricValues as IList <MetricValue> ?? metricValues.ToList(); bindingList = metricValues != null ? new BindingList <MetricValue>(metricList) { AllowNew = true, AllowEdit = true, AllowRemove = true } : new BindingList <MetricValue> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeControls(); }
private void GetData() { try { Credential cred = new Credential { SecretId = APIKey.SecretID, SecretKey = APIKey.SecretKey }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("monitor.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; MonitorClient client = new MonitorClient(cred, IRegion, clientProfile); GetMonitorDataRequest req = new GetMonitorDataRequest(); req.Namespace = "QCE/CVM"; req.MetricName = Metric; Instance instance1 = new Instance(); Dimension dimension1 = new Dimension(); dimension1.Name = "InstanceId"; dimension1.Value = InstanceID; instance1.Dimensions = new Dimension[] { dimension1 }; req.Instances = new Instance[] { instance1 }; GetMonitorDataResponse resp = client.GetMonitorDataSync(req); dataPoints.Clear(); for (int i1 = 0; i1 < resp.DataPoints[0].Timestamps.Length; i1++) { MetricDataPoint i = new MetricDataPoint() { time = resp.DataPoints[0].Timestamps[i1], value = resp.DataPoints[0].Values[i1] }; dataPoints.Enqueue(i); if (dataPoints.Count > 10) { dataPoints.Dequeue(); } } } catch (Exception e) { SOLMain.WriteLogline("获取数据失败:" + e.Message, SOLMain.LogLevel.Error); } }