import { Alert, AlertDescription } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { getErrorMessage, useGetCoreConfigQuery, useUpdateCoreConfigMutation } from "@/lib/store"; import { CoreConfig, DefaultCoreConfig } from "@/lib/types/config"; import { parseArrayFromText } from "@/lib/utils/array"; import { RbacOperation, RbacResource, useRbac } from "@enterprise/lib"; import { AlertTriangle } from "lucide-react"; import { useCallback, useEffect, useMemo, useState } from "react"; import { toast } from "sonner"; export default function ObservabilityView() { const hasSettingsUpdateAccess = useRbac(RbacResource.Settings, RbacOperation.Update); const { data: bifrostConfig } = useGetCoreConfigQuery({ fromDB: true }); const config = bifrostConfig?.client_config; const [updateCoreConfig, { isLoading }] = useUpdateCoreConfigMutation(); const [localConfig, setLocalConfig] = useState(DefaultCoreConfig); const [needsRestart, setNeedsRestart] = useState(false); const [localValues, setLocalValues] = useState<{ prometheus_labels: string; }>({ prometheus_labels: "", }); useEffect(() => { if (bifrostConfig && config) { setLocalConfig(config); setLocalValues({ prometheus_labels: config?.prometheus_labels?.join(", ") || "", }); } }, [config, bifrostConfig]); const hasChanges = useMemo(() => { if (!config) return false; const localLabels = localConfig.prometheus_labels.slice().sort().join(","); const serverLabels = config.prometheus_labels.slice().sort().join(","); return localLabels !== serverLabels; }, [config, localConfig]); const handlePrometheusLabelsChange = useCallback((value: string) => { setLocalValues((prev) => ({ ...prev, prometheus_labels: value })); setLocalConfig((prev) => ({ ...prev, prometheus_labels: parseArrayFromText(value) })); setNeedsRestart(true); }, []); const handleSave = useCallback(async () => { if (!bifrostConfig) { toast.error("Could not save settings: configuration not loaded."); return; } try { await updateCoreConfig({ ...bifrostConfig, client_config: localConfig }).unwrap(); toast.success("Observability settings updated successfully."); } catch (error) { toast.error(getErrorMessage(error)); } }, [bifrostConfig, localConfig, updateCoreConfig]); return (
These settings require a Bifrost service restart to take effect. Current connections will continue with existing settings until restart.
{/* Prometheus Labels */}

Comma-separated list of custom labels to add to the Prometheus metrics.