iperf-watcher/src/loki.zig
2023-10-14 21:19:20 -05:00

49 lines
901 B
Zig

const std = @import("std");
pub const LogLevel = enum {
critical,
@"error",
warning,
info,
debug,
trace,
unknown,
};
pub const LokiLabels = struct {
job: []const u8,
server: []const u8,
level: LogLevel = .info,
};
pub const LokiValue = struct {
ts: i128,
line: []const u8,
const Self = @This();
pub fn jsonStringify(self: Self, jws: anytype) !void {
var tsb: [32]u8 = undefined;
const tsb_size = std.fmt.formatIntBuf(
&tsb,
self.ts,
10,
.lower,
.{},
);
try jws.beginArray();
try jws.write(tsb[0..tsb_size]);
try jws.write(self.line);
try jws.endArray();
}
};
pub const LokiStream = struct {
stream: LokiLabels,
values: []const LokiValue,
};
pub const LokiStreams = struct {
streams: []const LokiStream,
};