add prometheus monitoring to config

This commit is contained in:
Anton Schirg 2018-08-26 20:25:06 +02:00
parent add1b69809
commit fbb8a25320
2 changed files with 21 additions and 1 deletions

View File

@ -53,7 +53,8 @@ type Pruning struct {
} }
type Global struct { type Global struct {
Logging []LoggingOutletEnum `yaml:"logging"` Logging []LoggingOutletEnum `yaml:"logging"`
Monitoring []MonitoringEnum `yaml:"monitoring"`
} }
type ConnectEnum struct { type ConnectEnum struct {
@ -138,6 +139,15 @@ type TCPLoggingOutletTLS struct {
Key string `yaml:"key"` 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) { func enumUnmarshal(u func(interface{}, bool) error, types map[string]interface{}) (interface{}, error) {
var in struct { var in struct {
Type string Type string
@ -201,6 +211,13 @@ func (t *LoggingOutletEnum) UnmarshalYAML(u func(interface{}, bool) error) (err
return 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{ var ConfigFileDefaultLocations = []string{
"/etc/zrepl/zrepl.yml", "/etc/zrepl/zrepl.yml",
"/usr/local/etc/zrepl/zrepl.yml", "/usr/local/etc/zrepl/zrepl.yml",

View File

@ -28,3 +28,6 @@ global:
time: true time: true
level: "warn" level: "warn"
format: "human" format: "human"
monitoring:
- type: "prometheus"
listen: ":9091"