Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export default function DashboardPage() {
height={200}
/>
<MetricChart
title="Component Latency"
title="Pipeline Latency"
icon={<Timer className="h-4 w-4" />}
data={chartData.data?.pipeline.latency ?? {}}
variant="area"
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/pipelines/[id]/metrics/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function PipelineMetricsPage() {

<Card>
<CardHeader>
<CardTitle>Component Latency</CardTitle>
<CardTitle>Pipeline Latency</CardTitle>
</CardHeader>
<CardContent>
<MetricsChart rows={rows} dataKey="latency" height={220} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/pipeline/metrics-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export function PipelineMetricsChart({ pipelineId, hours = 24 }: PipelineMetrics

{/* Latency chart */}
<div>
<p className="text-xs text-muted-foreground mb-1 font-medium">Component Latency</p>
<p className="text-xs text-muted-foreground mb-1 font-medium">Pipeline Latency</p>
<ChartContainer config={latencyChartConfig} className="w-full" style={{ height: 180 }}>
<AreaChart data={data}>
<CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
Expand Down
36 changes: 31 additions & 5 deletions src/server/services/alert-evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,15 @@ export async function evaluateAlerts(

if (!node) return [];

// Load all enabled rules for this environment
// Load all enabled rules for this environment (include pipeline name for messages)
const rules = await prisma.alertRule.findMany({
where: {
environmentId,
enabled: true,
},
include: {
pipeline: { select: { name: true } },
},
});

const results: FiredAlertEvent[] = [];
Expand Down Expand Up @@ -281,7 +284,7 @@ export async function evaluateAlerts(

if (!existingEvent) {
// Create a new firing event
const message = buildMessage(rule, value);
const message = buildMessage(rule, value, rule.pipeline?.name);
const event = await prisma.alertEvent.create({
data: {
alertRuleId: rule.id,
Expand Down Expand Up @@ -354,11 +357,34 @@ const CONDITION_LABELS: Record<AlertCondition, string> = {
eq: "=",
};

function buildMessage(rule: AlertRule, value: number): string {
/** Metrics where the value is binary (0/1) and the numeric details are noise. */
const BINARY_METRICS = new Set<AlertMetric>([
"pipeline_crashed",
"node_unreachable",
]);

function buildMessage(
rule: AlertRule,
value: number,
pipelineName?: string | null,
): string {
const metricLabel = METRIC_LABELS[rule.metric] ?? rule.metric;

if (!rule.condition || rule.threshold == null) {
return `${metricLabel} event fired`;
return pipelineName
? `${metricLabel}: ${pipelineName}`
: `${metricLabel}`;
}

// Binary metrics: just state what happened, with the pipeline name if available
if (BINARY_METRICS.has(rule.metric)) {
return pipelineName
? `${metricLabel}: ${pipelineName}`
: `${metricLabel}`;
}

// Numeric metrics: include value and threshold for context
const condLabel = CONDITION_LABELS[rule.condition] ?? rule.condition;
return `${metricLabel} is ${value.toFixed(2)} (threshold: ${condLabel} ${rule.threshold})`;
const prefix = pipelineName ? `${pipelineName} — ` : "";
return `${prefix}${metricLabel} at ${value.toFixed(2)} (threshold: ${condLabel} ${rule.threshold})`;
}
2 changes: 1 addition & 1 deletion src/server/services/metric-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface MetricSample {
errorCount: number;
errorsRate: number;
discardedRate: number;
latencyMeanMs: number | null; // mean component latency in ms
latencyMeanMs: number | null; // mean pipeline latency in ms
}

interface PrevTotals {
Expand Down
Loading