@@ -434,10 +434,176 @@ export const runsSchema: TableSchema = {
434434 } ,
435435} ;
436436
437+ /**
438+ * Schema definition for the metrics table (trigger_dev.metrics_v1)
439+ */
440+ export const metricsSchema : TableSchema = {
441+ name : "metrics" ,
442+ clickhouseName : "trigger_dev.metrics_v1" ,
443+ description : "Host and runtime metrics collected during task execution" ,
444+ timeConstraint : "bucket_start" ,
445+ tenantColumns : {
446+ organizationId : "organization_id" ,
447+ projectId : "project_id" ,
448+ environmentId : "environment_id" ,
449+ } ,
450+ columns : {
451+ environment : {
452+ name : "environment" ,
453+ clickhouseName : "environment_id" ,
454+ ...column ( "String" , { description : "The environment slug" , example : "prod" } ) ,
455+ fieldMapping : "environment" ,
456+ customRenderType : "environment" ,
457+ } ,
458+ project : {
459+ name : "project" ,
460+ clickhouseName : "project_id" ,
461+ ...column ( "String" , {
462+ description : "The project reference, they always start with `proj_`." ,
463+ example : "proj_howcnaxbfxdmwmxazktx" ,
464+ } ) ,
465+ fieldMapping : "project" ,
466+ customRenderType : "project" ,
467+ } ,
468+ metric_name : {
469+ name : "metric_name" ,
470+ ...column ( "LowCardinality(String)" , {
471+ description : "The name of the metric (e.g. process.cpu.utilization, system.memory.usage)" ,
472+ example : "process.cpu.utilization" ,
473+ coreColumn : true ,
474+ } ) ,
475+ } ,
476+ metric_type : {
477+ name : "metric_type" ,
478+ ...column ( "LowCardinality(String)" , {
479+ description : "The type of metric" ,
480+ allowedValues : [ "gauge" , "sum" , "histogram" ] ,
481+ example : "gauge" ,
482+ } ) ,
483+ } ,
484+ machine_id : {
485+ name : "machine_id" ,
486+ clickhouseName : "metric_subject" ,
487+ ...column ( "String" , {
488+ description : "The machine ID that produced this metric" ,
489+ example : "machine-abc123" ,
490+ } ) ,
491+ } ,
492+ bucket_start : {
493+ name : "bucket_start" ,
494+ ...column ( "DateTime" , {
495+ description : "The start of the 10-second aggregation bucket" ,
496+ example : "2024-01-15 09:30:00" ,
497+ coreColumn : true ,
498+ } ) ,
499+ } ,
500+ count : {
501+ name : "count" ,
502+ ...column ( "UInt64" , {
503+ description : "Number of data points in this bucket" ,
504+ example : "6" ,
505+ } ) ,
506+ } ,
507+ sum_value : {
508+ name : "sum_value" ,
509+ ...column ( "Float64" , {
510+ description : "Sum of values in this bucket" ,
511+ example : "0.45" ,
512+ } ) ,
513+ } ,
514+ max_value : {
515+ name : "max_value" ,
516+ ...column ( "Float64" , {
517+ description : "Maximum value in this bucket" ,
518+ example : "0.85" ,
519+ coreColumn : true ,
520+ } ) ,
521+ } ,
522+ min_value : {
523+ name : "min_value" ,
524+ ...column ( "Float64" , {
525+ description : "Minimum value in this bucket" ,
526+ example : "0.12" ,
527+ } ) ,
528+ } ,
529+ last_value : {
530+ name : "last_value" ,
531+ ...column ( "Float64" , {
532+ description : "Last recorded value in this bucket" ,
533+ example : "0.42" ,
534+ coreColumn : true ,
535+ } ) ,
536+ } ,
537+
538+ // Trigger context columns (from attributes.trigger.* JSON subpaths)
539+ run_id : {
540+ name : "run_id" ,
541+ ...column ( "String" , {
542+ description : "The run ID associated with this metric" ,
543+ customRenderType : "runId" ,
544+ example : "run_cm1a2b3c4d5e6f7g8h9i" ,
545+ } ) ,
546+ expression : "attributes.trigger.run_id" ,
547+ } ,
548+ task_identifier : {
549+ name : "task_identifier" ,
550+ ...column ( "String" , {
551+ description : "Task identifier/slug" ,
552+ example : "my-background-task" ,
553+ coreColumn : true ,
554+ } ) ,
555+ expression : "attributes.trigger.task_slug" ,
556+ } ,
557+ attempt_number : {
558+ name : "attempt_number" ,
559+ ...column ( "String" , {
560+ description : "The attempt number for this metric" ,
561+ example : "1" ,
562+ } ) ,
563+ expression : "attributes.trigger.attempt_number" ,
564+ } ,
565+ machine_name : {
566+ name : "machine_name" ,
567+ ...column ( "String" , {
568+ description : "The machine preset used for execution" ,
569+ allowedValues : [ ...MACHINE_PRESETS ] ,
570+ example : "small-1x" ,
571+ } ) ,
572+ expression : "attributes.trigger.machine_name" ,
573+ } ,
574+ environment_type : {
575+ name : "environment_type" ,
576+ ...column ( "String" , {
577+ description : "Environment type" ,
578+ allowedValues : [ ...ENVIRONMENT_TYPES ] ,
579+ customRenderType : "environmentType" ,
580+ example : "PRODUCTION" ,
581+ } ) ,
582+ expression : "attributes.trigger.environment_type" ,
583+ } ,
584+ worker_id : {
585+ name : "worker_id" ,
586+ ...column ( "String" , {
587+ description : "The worker ID that produced this metric" ,
588+ example : "worker-abc123" ,
589+ } ) ,
590+ expression : "attributes.trigger.worker_id" ,
591+ } ,
592+ worker_version : {
593+ name : "worker_version" ,
594+ ...column ( "String" , {
595+ description : "The worker version that produced this metric" ,
596+ example : "20240115.1" ,
597+ } ) ,
598+ expression : "attributes.trigger.worker_version" ,
599+ } ,
600+ } ,
601+ } ;
602+
437603/**
438604 * All available schemas for the query editor
439605 */
440- export const querySchemas : TableSchema [ ] = [ runsSchema ] ;
606+ export const querySchemas : TableSchema [ ] = [ runsSchema , metricsSchema ] ;
441607
442608/**
443609 * Default query for the query editor
0 commit comments