aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-06-13 02:01:51 -0700
committerChris Lu <chris.lu@gmail.com>2019-06-13 02:01:54 -0700
commita11525fe4eb501f4c98db6aaf40800edabf30d08 (patch)
tree402552f42955055eff7c09d06fbeb0a2a9d3389f /weed/command
parentc542714448cff02e72ddc75f30712c24c3b3024f (diff)
downloadseaweedfs-a11525fe4eb501f4c98db6aaf40800edabf30d08.tar.xz
seaweedfs-a11525fe4eb501f4c98db6aaf40800edabf30d08.zip
filer: adds basic metrics pushing to Prometheus gateway
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/filer.go6
-rw-r--r--weed/command/server.go11
2 files changed, 15 insertions, 2 deletions
diff --git a/weed/command/filer.go b/weed/command/filer.go
index 2aa022cd0..83e9df20f 100644
--- a/weed/command/filer.go
+++ b/weed/command/filer.go
@@ -34,6 +34,8 @@ type FilerOptions struct {
dataCenter *string
enableNotification *bool
disableHttp *bool
+ metricsAddress *string
+ metricsIntervalSec *int
// default leveldb directory, used in "weed server" mode
defaultLevelDbDirectory *string
@@ -53,6 +55,8 @@ func init() {
f.dirListingLimit = cmdFiler.Flag.Int("dirListLimit", 100000, "limit sub dir listing size")
f.dataCenter = cmdFiler.Flag.String("dataCenter", "", "prefer to write to volumes in this data center")
f.disableHttp = cmdFiler.Flag.Bool("disableHttp", false, "disable http request, only gRpc operations are allowed")
+ f.metricsAddress = cmdFiler.Flag.String("metrics.address", "", "Prometheus gateway address")
+ f.metricsIntervalSec = cmdFiler.Flag.Int("metrics.intervalSeconds", 15, "Prometheus push interval in seconds")
}
var cmdFiler = &Command{
@@ -110,6 +114,8 @@ func (fo *FilerOptions) startFiler() {
DataCenter: *fo.dataCenter,
DefaultLevelDbDir: defaultLevelDbDirectory,
DisableHttp: *fo.disableHttp,
+ MetricsAddress: *fo.metricsAddress,
+ MetricsIntervalSec: *fo.metricsIntervalSec,
})
if nfs_err != nil {
glog.Fatalf("Filer startup error: %v", nfs_err)
diff --git a/weed/command/server.go b/weed/command/server.go
index 437b0ad83..30618c452 100644
--- a/weed/command/server.go
+++ b/weed/command/server.go
@@ -24,8 +24,10 @@ import (
)
type ServerOptions struct {
- cpuprofile *string
- v VolumeServerOptions
+ cpuprofile *string
+ metricsAddress *string
+ metricsIntervalSec *int
+ v VolumeServerOptions
}
var (
@@ -81,6 +83,8 @@ var (
func init() {
serverOptions.cpuprofile = cmdServer.Flag.String("cpuprofile", "", "cpu profile output file")
+ serverOptions.metricsAddress = cmdServer.Flag.String("metrics.address", "", "Prometheus gateway address")
+ serverOptions.metricsIntervalSec = cmdServer.Flag.Int("metrics.intervalSeconds", 15, "Prometheus push interval in seconds")
filerOptions.collection = cmdServer.Flag.String("filer.collection", "", "all data will be stored in this collection")
filerOptions.port = cmdServer.Flag.Int("filer.port", 8888, "filer server http listen port")
filerOptions.publicPort = cmdServer.Flag.Int("filer.port.public", 0, "filer server public http listen port")
@@ -143,6 +147,9 @@ func runServer(cmd *Command, args []string) bool {
filerOptions.dataCenter = serverDataCenter
filerOptions.disableHttp = serverDisableHttp
+ filerOptions.metricsAddress = serverOptions.metricsAddress
+ filerOptions.metricsIntervalSec = serverOptions.metricsIntervalSec
+
filerAddress := fmt.Sprintf("%s:%d", *serverIp, *filerOptions.port)
s3Options.filer = &filerAddress