diff --git a/cmd/config/config.go b/cmd/config/config.go index 3c3a6ce..e2ab447 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -53,7 +53,8 @@ type Pruning struct { } type Global struct { - Logging []LoggingOutletEnum `yaml:"logging"` + Logging []LoggingOutletEnum `yaml:"logging"` + Monitoring []MonitoringEnum `yaml:"monitoring"` } type ConnectEnum struct { @@ -138,6 +139,15 @@ type TCPLoggingOutletTLS struct { Key string `yaml:"key"` } +type MonitoringEnum struct { + Ret interface{} +} + +type PrometheusMonitoring struct { + Type string `yaml:"type"` + Listen string `yaml:"listen"` +} + func enumUnmarshal(u func(interface{}, bool) error, types map[string]interface{}) (interface{}, error) { var in struct { Type string @@ -201,6 +211,13 @@ func (t *LoggingOutletEnum) UnmarshalYAML(u func(interface{}, bool) error) (err return } +func (t *MonitoringEnum) UnmarshalYAML(u func(interface{}, bool) error) (err error) { + t.Ret, err = enumUnmarshal(u, map[string]interface{}{ + "prometheus": &PrometheusMonitoring{}, + }) + return +} + var ConfigFileDefaultLocations = []string{ "/etc/zrepl/zrepl.yml", "/usr/local/etc/zrepl/zrepl.yml", diff --git a/cmd/config/samples/push.yml b/cmd/config/samples/push.yml index 5966465..4d762af 100644 --- a/cmd/config/samples/push.yml +++ b/cmd/config/samples/push.yml @@ -28,3 +28,6 @@ global: time: true level: "warn" format: "human" + monitoring: + - type: "prometheus" + listen: ":9091" \ No newline at end of file