public async Task <QueryResultPage> GetSeries(string EnvironmentFqdn, string TimeSeriesId) { TimeSeriesInsightsClient tsi = GetTimeSeriesInsightsClientAsync(EnvironmentFqdn).Result; string continuationToken; do { DateTimeRange SearchSpan = new DateTimeRange(new DateTime(2019, 12, 26).ToUniversalTime(), new DateTime(2019, 12, 27).ToUniversalTime()); //object[] TimeSeriesIdValue = new object[] { "AND-ARU-XI82121_F" }; QueryResultPage queryResponse = await tsi.ExecuteQueryPagedAsync( new QueryRequest( getSeries : new GetSeries( timeSeriesId : new object[] { TimeSeriesId }, searchSpan : SearchSpan, filter : null, projectedVariables : new[] { "Float" }, inlineVariables : new Dictionary <string, NumericVariable>() { ["Float"] = new NumericVariable( value : new Tsx("$event.series_value"), aggregation : new Tsx("avg($value)")) }))); return(queryResponse); //continuationToken = queryResponse.ContinuationToken; }while (continuationToken != null); }
private static async Task RunAggregateSeriesAsync() { string continuationToken; do { QueryResultPage queryResponse = await _client.ExecuteQueryPagedAsync( new QueryRequest( aggregateSeries : new AggregateSeries( timeSeriesId : TimeSeriesId, searchSpan : SearchSpan, filter : null, interval : TimeSpan.FromMinutes(5), projectedVariables : new[] { "Min_Numeric", "Max_Numeric", "Sum_Numeric", "Avg_Numeric", "First_Numeric", "Last_Numeric", "Count_Aggregate" }, inlineVariables : new Dictionary <string, Variable>() { ["Min_Numeric"] = new NumericVariable( value : new Tsx("$event.data"), aggregation : new Tsx("min($value)")), ["Max_Numeric"] = new NumericVariable( value : new Tsx("$event.data"), aggregation : new Tsx("max($value)")), ["Sum_Numeric"] = new NumericVariable( value : new Tsx("$event.data"), aggregation : new Tsx("sum($value)")), ["Avg_Numeric"] = new NumericVariable( value : new Tsx("$event.data"), aggregation : new Tsx("avg($value)")), ["First_Numeric"] = new NumericVariable( value : new Tsx("$event.data"), aggregation : new Tsx("first($value)")), ["Last_Numeric"] = new NumericVariable( value : new Tsx("$event.data"), aggregation : new Tsx("last($value)")), ["Count_Aggregate"] = new AggregateVariable( aggregation : new Tsx("count()")) }))); PrintResponse(queryResponse); continuationToken = queryResponse.ContinuationToken; }while (continuationToken != null); }
public async Task <QueryResultPage> GetAggregateSeries(string EnvironmentFqdn, string TimeSeriesId) { TimeSeriesInsightsClient tsi = GetTimeSeriesInsightsClientAsync(EnvironmentFqdn).Result; string continuationToken; do { DateTimeRange SearchSpan = new DateTimeRange(new DateTime(2019, 12, 26).ToUniversalTime(), new DateTime(2019, 12, 27).ToUniversalTime()); //object[] TimeSeriesIdValue = new object[] { "AND-ARU-XI82121_F" }; QueryResultPage queryResponse = await tsi.ExecuteQueryPagedAsync( new QueryRequest( aggregateSeries : new AggregateSeries( timeSeriesId : new object[] { TimeSeriesId }, searchSpan : SearchSpan, filter : null, interval : TimeSpan.FromHours(5), projectedVariables : new[] { "Min_Numeric", "Max_Numeric", "Sum_Numeric", "Avg_Numeric", "First_Numeric", "Last_Numeric" }, inlineVariables : new Dictionary <string, Variable>() { ["Min_Numeric"] = new NumericVariable( value : new Tsx("$event.series_value"), aggregation : new Tsx("min($value)")), ["Max_Numeric"] = new NumericVariable( value : new Tsx("$event.series_value"), aggregation : new Tsx("max($value)")), ["Sum_Numeric"] = new NumericVariable( value : new Tsx("$event.series_value"), aggregation : new Tsx("sum($value)")), ["Avg_Numeric"] = new NumericVariable( value : new Tsx("$event.series_value"), aggregation : new Tsx("avg($value)")), ["First_Numeric"] = new NumericVariable( value : new Tsx("$event.series_value"), aggregation : new Tsx("first($value)")), ["Last_Numeric"] = new NumericVariable( value : new Tsx("$event.series_value"), aggregation : new Tsx("last($value)")) }))); return(queryResponse); //continuationToken = queryResponse.ContinuationToken; }while (continuationToken != null); }
private List <Reading> GetReadingsBetween(DateTime from, DateTime to) { var readings = new List <Reading>(); DateTimeRange SearchToday = new DateTimeRange(from.ToUniversalTime(), to.ToUniversalTime()); string continuationToken; do { QueryResultPage queryResponse = client.ExecuteQueryPagedAsync( new QueryRequest( getEvents: new GetEvents(timeSeriesId: timeSeriesId, searchSpan: SearchToday, filter: null))).Result; readings.AddRange(ParseReadings(queryResponse)); continuationToken = queryResponse.ContinuationToken; }while (continuationToken != null); return(readings); }
public async Task <QueryResultPage> GetEvents(string EnvironmentFqdn, string TimeSeriesId) { TimeSeriesInsightsClient tsi = GetTimeSeriesInsightsClientAsync(EnvironmentFqdn).Result; string continuationToken; do { DateTimeRange SearchSpan = new DateTimeRange(new DateTime(2019, 12, 26).ToUniversalTime(), new DateTime(2019, 12, 27).ToUniversalTime()); //object[] TimeSeriesIdValue = new object[] { "AND-ARU-XI82121_F" }; QueryResultPage queryResponse = await tsi.ExecuteQueryPagedAsync( new QueryRequest( getSeries : new GetSeries( timeSeriesId : new object[] { TimeSeriesId }, searchSpan : SearchSpan, filter : null ))); return(queryResponse); //continuationToken = queryResponse.ContinuationToken; }while (continuationToken != null); }