SHARE
TWEET

Untitled

a guest Apr 25th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography.X509Certificates;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7.  
  8. using Microsoft.Cloud.Metrics.Client;
  9. using Microsoft.Cloud.Metrics.Client.Configuration;
  10. using Microsoft.Cloud.Metrics.Client.Metrics;
  11. using Microsoft.Cloud.Metrics.Client.Monitors;
  12. using Microsoft.Cloud.Metrics.Client.Query;
  13. using Microsoft.Cloud.Metrics.Client.MetricsExtension;
  14. using Microsoft.Online.Metrics.Serialization.Configuration;
  15. using Microsoft.Online.Metrics.Serialization.Monitor;
  16. using Newtonsoft.Json;
  17.  
  18. namespace MDMetricsClientSampleCode
  19. {
  20. public class Methods
  21.     {
  22.         public static int Main()//string[] args)
  23.         {
  24.             var connectionInfo = new ConnectionInfo();
  25.             String FarmLabel = "US_20_Content";
  26.             var reader = new MetricReader(connectionInfo);
  27.  
  28.             // Metric name where Account=MetricTeamInternalMetrics, Namespace=QueryServiceCoordinator, Name=AttemptsCount
  29.             var id = new MetricIdentifier("SPOProd", "PerfCounters", "\\ASP.NET\\Requests Current");
  30.             var dimensionFilters = new List<DimensionFilter>();
  31.  
  32.             // Filter represents the condition
  33.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("Instance"));
  34.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("__DataCenter"));
  35.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("__FarmLabel", FarmLabel));
  36.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("__Machine"));
  37.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("__Network"));
  38.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("__Role", "USR"));
  39.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("__FarmType", "Primary"));
  40.             dimensionFilters.Add(DimensionFilter.CreateIncludeFilter("__Environment"));
  41.  
  42.             IQueryResultListV3 results = reader.GetTimeSeriesAsync(
  43.                 id,
  44.                 dimensionFilters,
  45.                 DateTime.UtcNow.AddMinutes(-5),
  46.                 DateTime.UtcNow,
  47.                 new[] { SamplingType.Sum },
  48.                 new SelectionClauseV3(new PropertyDefinition(PropertyAggregationType.Average, SamplingType.Sum), 10, OrderBy.Descending),
  49.                 outputDimensionNames: new[] { "__Machine" }).Result;
  50.  
  51.             var temp0 = results.Results.SelectMany(x => x.DimensionList).Select(y => y.Value.ToString()).ToArray();
  52.             Console.WriteLine(temp0[1]);
  53.             return 0;
  54.         }
  55.     }
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top