feat(core): add metrics history storage interface and point model
This commit is contained in:
1 parent
3a913c4375
commit
7dd006c479
3 files changed
+46
No files matched your search
@@ -0,0 +1,23 @@
|
||||
using Vantage.Core.Models;
|
||||
|
||||
namespace Vantage.Core.History;
|
||||
|
||||
public interface IMetricsStore
|
||||
{
|
||||
Task RecordAsync(MetricSample sample, CancellationToken cancellationToken = default);
|
||||
|
||||
Task RecordManyAsync(IEnumerable<MetricSample> samples, CancellationToken cancellationToken = default);
|
||||
|
||||
Task RecordHostMetricsAsync(string hostId, HostMetrics metrics, CancellationToken cancellationToken = default);
|
||||
|
||||
Task<IReadOnlyList<MetricPoint>> QueryAsync(
|
||||
string hostId,
|
||||
string metric,
|
||||
DateTimeOffset from,
|
||||
DateTimeOffset to,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<int> PruneOlderThanAsync(DateTimeOffset cutoff, CancellationToken cancellationToken = default);
|
||||
|
||||
Task<long> CountAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Vantage.Core.History;
|
||||
|
||||
public static class MetricNames
|
||||
{
|
||||
public const string Cpu = "cpu";
|
||||
public const string Memory = "memory";
|
||||
public const string Disk = "disk";
|
||||
public const string Load1 = "load1";
|
||||
public const string Load5 = "load5";
|
||||
public const string Load15 = "load15";
|
||||
public const string NetworkRx = "networkRx";
|
||||
public const string NetworkTx = "networkTx";
|
||||
|
||||
public static readonly IReadOnlyList<string> All = new[]
|
||||
{
|
||||
Cpu, Memory, Disk, Load1, Load5, Load15, NetworkRx, NetworkTx
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Vantage.Core.History;
|
||||
|
||||
public readonly record struct MetricPoint(DateTimeOffset Timestamp, double Value);
|
||||
|
||||
public readonly record struct MetricSample(string HostId, string Metric, DateTimeOffset Timestamp, double Value);
|
||||
Reference in new issue
Block a user