diff --git a/src/Vantage.Core/History/IMetricsStore.cs b/src/Vantage.Core/History/IMetricsStore.cs new file mode 100644 index 0000000..20e0892 --- /dev/null +++ b/src/Vantage.Core/History/IMetricsStore.cs @@ -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 samples, CancellationToken cancellationToken = default); + + Task RecordHostMetricsAsync(string hostId, HostMetrics metrics, CancellationToken cancellationToken = default); + + Task> QueryAsync( + string hostId, + string metric, + DateTimeOffset from, + DateTimeOffset to, + CancellationToken cancellationToken = default); + + Task PruneOlderThanAsync(DateTimeOffset cutoff, CancellationToken cancellationToken = default); + + Task CountAsync(CancellationToken cancellationToken = default); +} diff --git a/src/Vantage.Core/History/MetricNames.cs b/src/Vantage.Core/History/MetricNames.cs new file mode 100644 index 0000000..7b143bc --- /dev/null +++ b/src/Vantage.Core/History/MetricNames.cs @@ -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 All = new[] + { + Cpu, Memory, Disk, Load1, Load5, Load15, NetworkRx, NetworkTx + }; +} diff --git a/src/Vantage.Core/History/MetricPoint.cs b/src/Vantage.Core/History/MetricPoint.cs new file mode 100644 index 0000000..ad10bcf --- /dev/null +++ b/src/Vantage.Core/History/MetricPoint.cs @@ -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);