@@ -78,6 +78,9 @@ type Config struct {
78
78
// should be created.
79
79
SocketPath string
80
80
81
+ // LogPath defines the file path where the Firecracker log is located.
82
+ LogPath string
83
+
81
84
// LogFifo defines the file path where the Firecracker log named-pipe should
82
85
// be located.
83
86
LogFifo string
@@ -86,6 +89,10 @@ type Config struct {
86
89
// "Error", "Warning", "Info", and "Debug", and are case-sensitive.
87
90
LogLevel string
88
91
92
+ // MetricsPath defines the file path where the Firecracker metrics
93
+ // is located.
94
+ MetricsPath string
95
+
89
96
// MetricsFifo defines the file path where the Firecracker metrics
90
97
// named-pipe should be located.
91
98
MetricsFifo string
@@ -585,29 +592,29 @@ func (m *Machine) stopVMM() error {
585
592
return nil
586
593
}
587
594
588
- // createFifos sets up the firecracker logging and metrics FIFOs
589
- func createFifos ( logFifo , metricsFifo string ) error {
590
- log .Debugf ("Creating FIFO %s" , logFifo )
591
- if err := syscall .Mkfifo (logFifo , 0700 ); err != nil {
595
+ // createFifo sets up a FIFOs
596
+ func createFifo ( path string ) error {
597
+ log .Debugf ("Creating FIFO %s" , path )
598
+ if err := syscall .Mkfifo (path , 0700 ); err != nil {
592
599
return fmt .Errorf ("Failed to create log fifo: %v" , err )
593
600
}
594
-
595
- log .Debugf ("Creating metric FIFO %s" , metricsFifo )
596
- if err := syscall .Mkfifo (metricsFifo , 0700 ); err != nil {
597
- return fmt .Errorf ("Failed to create metric fifo: %v" , err )
598
- }
599
601
return nil
600
602
}
601
603
602
604
func (m * Machine ) setupLogging (ctx context.Context ) error {
603
- if len (m .Cfg .LogFifo ) == 0 || len (m .Cfg .MetricsFifo ) == 0 {
605
+ path := m .Cfg .LogPath
606
+ if len (m .Cfg .LogFifo ) > 0 {
607
+ path = m .Cfg .LogFifo
608
+ }
609
+
610
+ if len (path ) == 0 {
604
611
// No logging configured
605
- m .logger .Printf ("VMM logging and metrics disabled." )
612
+ m .logger .Printf ("VMM logging disabled." )
606
613
return nil
607
614
}
608
615
609
616
l := models.Logger {
610
- LogPath : String (m . Cfg . LogFifo ),
617
+ LogPath : String (path ),
611
618
Level : String (m .Cfg .LogLevel ),
612
619
ShowLevel : Bool (true ),
613
620
ShowLogOrigin : Bool (false ),
@@ -618,10 +625,31 @@ func (m *Machine) setupLogging(ctx context.Context) error {
618
625
return err
619
626
}
620
627
621
- m .logger .Debugf ("Configured VMM logging to %s, metrics to %s" ,
622
- m .Cfg .LogFifo ,
623
- m .Cfg .MetricsFifo ,
624
- )
628
+ m .logger .Debugf ("Configured VMM logging to %s" , path )
629
+
630
+ return nil
631
+ }
632
+
633
+ func (m * Machine ) setupMetrics (ctx context.Context ) error {
634
+ path := m .Cfg .MetricsPath
635
+ if len (m .Cfg .MetricsFifo ) > 0 {
636
+ path = m .Cfg .MetricsFifo
637
+ }
638
+
639
+ if len (path ) == 0 {
640
+ // No logging configured
641
+ m .logger .Printf ("VMM metrics disabled." )
642
+ return nil
643
+ }
644
+
645
+ _ , err := m .client .PutMetrics (ctx , & models.Metrics {
646
+ MetricsPath : String (path ),
647
+ })
648
+ if err != nil {
649
+ return err
650
+ }
651
+
652
+ m .logger .Debugf ("Configured VMM metrics to %s" , path )
625
653
626
654
return nil
627
655
}
0 commit comments