Add the ability to log to loki
This commit is contained in:
@@ -26,6 +26,14 @@ export type MetricsSettings = {
|
||||
port?: number; // Port to expose metrics on (default: 9090, separate from admin API)
|
||||
};
|
||||
|
||||
export type LoggingSettings = {
|
||||
enabled: boolean;
|
||||
lokiUrl?: string; // URL of Loki instance (e.g., http://loki:3100)
|
||||
lokiUsername?: string; // Optional username for Loki authentication
|
||||
lokiPassword?: string; // Optional password for Loki authentication
|
||||
labels?: Record<string, string>; // Optional custom labels for logs
|
||||
};
|
||||
|
||||
export async function getSetting<T>(key: string): Promise<SettingValue<T>> {
|
||||
const setting = await db.query.settings.findFirst({
|
||||
where: (table, { eq }) => eq(table.key, key)
|
||||
@@ -94,3 +102,11 @@ export async function getMetricsSettings(): Promise<MetricsSettings | null> {
|
||||
export async function saveMetricsSettings(settings: MetricsSettings): Promise<void> {
|
||||
await setSetting("metrics", settings);
|
||||
}
|
||||
|
||||
export async function getLoggingSettings(): Promise<LoggingSettings | null> {
|
||||
return await getSetting<LoggingSettings>("logging");
|
||||
}
|
||||
|
||||
export async function saveLoggingSettings(settings: LoggingSettings): Promise<void> {
|
||||
await setSetting("logging", settings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user