This commit is contained in:
2020-05-27 19:51:18 +00:00
parent f9f29eedad
commit 811b7c88a2
3 changed files with 24 additions and 33 deletions

View File

@@ -41,6 +41,12 @@ going to try
that's what I want if I'm only dealing in UTC
rerun again and see if it's casting still
OK, after some research I am doing the correct thing, it should be:
Schema: "timestamp" Model: DateTime
The only issue may be in the interpretation of the date time, it's sent to postgres as is so if the server converts it as local from the parameter in the route then that's waht's sent
which is what I'm seeing in metric route so it's a translation of the datetime incoming to route parameter issue only and only when it hits the db for storage or query
Storage?? I best check that shit use eventlog...
todo: leave running check it does overnight backup properly

View File

@@ -57,7 +57,7 @@ namespace AyaNova.Api.Controllers
/// <param name="maxRecords">Optional maximum records to return. If there are more records for the time period selected than this value the result will be downsampled. There is a 400 record maximum fixed default</param>
/// <returns>Snapshot of metrics</returns>
[HttpGet]
public async Task<IActionResult> GetMetrics([FromQuery] DateTimeOffset tsStart, [FromQuery] DateTimeOffset tsEnd, [FromQuery] int? maxRecords)
public async Task<IActionResult> GetMetrics([FromQuery] DateTime tsStart, [FromQuery] DateTime tsEnd, [FromQuery] int? maxRecords)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -66,11 +66,16 @@ namespace AyaNova.Api.Controllers
{
return StatusCode(403, new ApiNotAuthorizedResponse());
}
//use specified values or just return all
maxRecords ??= MAX_RECORDS_BEFORE_DOWNSAMPLING;
List<MetricMM> MinuteMetrics = new List<MetricMM>();
MinuteMetrics = await ct.MetricMM.AsNoTracking().Where(z => z.t >= tsStart && z.t <= tsEnd).OrderBy(z => z.t).ToListAsync();
//touniversal is because the parameters are converted to local time here, but then sent to the query as local time as well and not universal time which is what it should be
MinuteMetrics = await ct.MetricMM.AsNoTracking().Where(z => z.t >= tsStart.ToUniversalTime() && z.t <= tsEnd.ToUniversalTime()).OrderBy(z => z.t).ToListAsync();
//var v=await ct.MetricMM.AsNoTracking().Where(z => z.t >= tsStart.ToUniversalTime() && z.t <= tsEnd.ToUniversalTime()).OrderByDescending(z => z.t).ToListAsync();
//Log
@@ -83,51 +88,31 @@ namespace AyaNova.Api.Controllers
{
//yes, so need to return individual labels and downsampled data as they wont' sync anymore
// var dsCPU = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.CPU)).ToList();
// dsCPU = Util.DataUtil.LargestTriangleThreeBuckets(dsCPU, (int)maxRecords) as List<Tuple<double, double>>;
// var dsAllocated = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Allocated)).ToList();
// dsAllocated = Util.DataUtil.LargestTriangleThreeBuckets(dsAllocated, (int)maxRecords) as List<Tuple<double, double>>;
// var dsWorkingSet = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.WorkingSet)).ToList();
// dsWorkingSet = Util.DataUtil.LargestTriangleThreeBuckets(dsWorkingSet, (int)maxRecords) as List<Tuple<double, double>>;
// var dsPrivateBytes = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.PrivateBytes)).ToList();
// dsPrivateBytes = Util.DataUtil.LargestTriangleThreeBuckets(dsPrivateBytes, (int)maxRecords) as List<Tuple<double, double>>;
// var dsGen0 = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Gen0)).ToList();
// dsGen0 = Util.DataUtil.LargestTriangleThreeBuckets(dsGen0, (int)maxRecords) as List<Tuple<double, double>>;
// var dsGen1 = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Gen1)).ToList();
// dsGen1 = Util.DataUtil.LargestTriangleThreeBuckets(dsGen1, (int)maxRecords) as List<Tuple<double, double>>;
// var dsGen2 = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Gen2)).ToList();
// dsGen2 = Util.DataUtil.LargestTriangleThreeBuckets(dsGen2, (int)maxRecords) as List<Tuple<double, double>>;
var dsCPU = MinuteMetrics.Select(z => new Tuple<double, double>(z.t.ToUnixTimeSeconds(), z.CPU)).ToList();
var dsCPU = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.CPU)).ToList();
dsCPU = Util.DataUtil.LargestTriangleThreeBuckets(dsCPU, (int)maxRecords) as List<Tuple<double, double>>;
var dsAllocated = MinuteMetrics.Select(z => new Tuple<double, double>(z.t.ToUnixTimeSeconds(), z.Allocated)).ToList();
var dsAllocated = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Allocated)).ToList();
dsAllocated = Util.DataUtil.LargestTriangleThreeBuckets(dsAllocated, (int)maxRecords) as List<Tuple<double, double>>;
var dsWorkingSet = MinuteMetrics.Select(z => new Tuple<double, double>(z.t.ToUnixTimeSeconds(), z.WorkingSet)).ToList();
var dsWorkingSet = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.WorkingSet)).ToList();
dsWorkingSet = Util.DataUtil.LargestTriangleThreeBuckets(dsWorkingSet, (int)maxRecords) as List<Tuple<double, double>>;
var dsPrivateBytes = MinuteMetrics.Select(z => new Tuple<double, double>(z.t.ToUnixTimeSeconds(), z.PrivateBytes)).ToList();
var dsPrivateBytes = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.PrivateBytes)).ToList();
dsPrivateBytes = Util.DataUtil.LargestTriangleThreeBuckets(dsPrivateBytes, (int)maxRecords) as List<Tuple<double, double>>;
var dsGen0 = MinuteMetrics.Select(z => new Tuple<double, double>(z.t.ToUnixTimeSeconds(), z.Gen0)).ToList();
var dsGen0 = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Gen0)).ToList();
dsGen0 = Util.DataUtil.LargestTriangleThreeBuckets(dsGen0, (int)maxRecords) as List<Tuple<double, double>>;
var dsGen1 = MinuteMetrics.Select(z => new Tuple<double, double>(z.t.ToUnixTimeSeconds(), z.Gen1)).ToList();
var dsGen1 = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Gen1)).ToList();
dsGen1 = Util.DataUtil.LargestTriangleThreeBuckets(dsGen1, (int)maxRecords) as List<Tuple<double, double>>;
var dsGen2 = MinuteMetrics.Select(z => new Tuple<double, double>(z.t.ToUnixTimeSeconds(), z.Gen2)).ToList();
var dsGen2 = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.Gen2)).ToList();
dsGen2 = Util.DataUtil.LargestTriangleThreeBuckets(dsGen2, (int)maxRecords) as List<Tuple<double, double>>;
var ret = new
{
DownSampled = true,

View File

@@ -11,7 +11,7 @@ namespace AyaNova.Models
{
[Required]
[Key]
public DateTimeOffset t { get; set; }
public DateTime t { get; set; }
public long Allocated { get; set; }
public long WorkingSet { get; set; }
public long PrivateBytes { get; set; }
@@ -25,7 +25,7 @@ namespace AyaNova.Models
public MetricMM(long allocated, long workingSet, long privateBytes, int gen0, int gen1, int gen2, double cpu)
{
t = System.DateTimeOffset.UtcNow;
t = System.DateTime.UtcNow;
Allocated = allocated;
WorkingSet = workingSet;
PrivateBytes = privateBytes;