tty-prometheus-exporter-merger/cmd/config.go
Dmitry Vasiliev 9827e1865a
update readme
2020-05-17 16:58:41 +03:00

32 lines
596 B
Go

package cmd
import (
"io/ioutil"
"time"
"gopkg.in/yaml.v2"
)
type source struct {
Url string `yaml:"url"`
Labels map[string]string `yaml:"labels"`
}
type config struct {
Listen string `yaml:"listen"`
ScrapTimeout time.Duration `yaml:"scrap_timeout"`
Sources []*source `yaml:"sources"`
}
func parseConfig(filename string) (*config, error) {
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
result := &config{
Listen: ":8080",
ScrapTimeout: 15 * time.Second,
}
return result, yaml.Unmarshal(data, result)
}