mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Add command-line arguments for config file and storage path.
This commit is contained in:
parent
a85204a0a4
commit
127c61a55f
19
main.go
19
main.go
|
@ -15,7 +15,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.google.com/p/gorest"
|
"code.google.com/p/gorest"
|
||||||
"fmt"
|
"flag"
|
||||||
"github.com/matttproud/golang_instrumentation"
|
"github.com/matttproud/golang_instrumentation"
|
||||||
"github.com/matttproud/prometheus/api"
|
"github.com/matttproud/prometheus/api"
|
||||||
"github.com/matttproud/prometheus/config"
|
"github.com/matttproud/prometheus/config"
|
||||||
|
@ -29,15 +29,20 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Commandline flags.
|
||||||
|
var (
|
||||||
|
configFile = flag.String("configFile", "prometheus.conf", "Prometheus configuration file name.")
|
||||||
|
metricsStoragePath = flag.String("metricsStoragePath", "/tmp/metrics", "Base path for metrics storage.")
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configFile := "prometheus.conf"
|
flag.Parse()
|
||||||
conf, err := config.LoadFromFile(configFile)
|
conf, err := config.LoadFromFile(*configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(fmt.Sprintf("Error loading configuration from %s: %v",
|
log.Fatalf("Error loading configuration from %s: %v", configFile, err)
|
||||||
configFile, err))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
persistence, err := leveldb.NewLevelDBMetricPersistence("/tmp/metrics")
|
persistence, err := leveldb.NewLevelDBMetricPersistence(*metricsStoragePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -64,7 +69,7 @@ func main() {
|
||||||
ruleManager := rules.NewRuleManager(ruleResults, conf.Global.EvaluationInterval)
|
ruleManager := rules.NewRuleManager(ruleResults, conf.Global.EvaluationInterval)
|
||||||
err = ruleManager.AddRulesFromConfig(conf)
|
err = ruleManager.AddRulesFromConfig(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(fmt.Sprintf("Error loading rule files: %v", err))
|
log.Fatalf("Error loading rule files: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
Loading…
Reference in a new issue