aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
authorKonstantin Lebedev <lebedev_k@tochka.com>2020-09-24 17:45:39 +0500
committerKonstantin Lebedev <lebedev_k@tochka.com>2020-09-24 17:45:39 +0500
commit324e44d4b3dffc1197bf8f6c6ec49297ace44c2b (patch)
treeedf0b2b4d990e4085d58ab084270912fd9fb5e77 /weed/command
parent3e52329cee39f3a83f58d3896514547093ff0cf8 (diff)
downloadseaweedfs-324e44d4b3dffc1197bf8f6c6ec49297ace44c2b.tar.xz
seaweedfs-324e44d4b3dffc1197bf8f6c6ec49297ace44c2b.zip
add start metrics server
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/filer.go4
-rw-r--r--weed/command/s3.go16
-rw-r--r--weed/command/server.go3
-rw-r--r--weed/command/volume.go3
4 files changed, 18 insertions, 8 deletions
diff --git a/weed/command/filer.go b/weed/command/filer.go
index a6670b063..dcc85d8bd 100644
--- a/weed/command/filer.go
+++ b/weed/command/filer.go
@@ -36,7 +36,7 @@ type FilerOptions struct {
disableHttp *bool
cipher *bool
peers *string
-
+ metricsHttpPort *int
// default leveldb directory, used in "weed server" mode
defaultLevelDbDirectory *string
}
@@ -57,6 +57,7 @@ func init() {
f.disableHttp = cmdFiler.Flag.Bool("disableHttp", false, "disable http request, only gRpc operations are allowed")
f.cipher = cmdFiler.Flag.Bool("encryptVolumeData", false, "encrypt data on volume servers")
f.peers = cmdFiler.Flag.String("peers", "", "all filers sharing the same filer store in comma separated ip:port list")
+ f.metricsHttpPort = cmdFiler.Flag.Int("metricsPort", 0, "Prometheus metrics listen port")
}
var cmdFiler = &Command{
@@ -122,6 +123,7 @@ func (fo *FilerOptions) startFiler() {
Port: uint32(*fo.port),
Cipher: *fo.cipher,
Filers: peers,
+ MetricsHttpPort: *fo.metricsHttpPort,
})
if nfs_err != nil {
glog.Fatalf("Filer startup error: %v", nfs_err)
diff --git a/weed/command/s3.go b/weed/command/s3.go
index a9b317138..3562dc765 100644
--- a/weed/command/s3.go
+++ b/weed/command/s3.go
@@ -23,12 +23,13 @@ var (
)
type S3Options struct {
- filer *string
- port *int
- config *string
- domainName *string
- tlsPrivateKey *string
- tlsCertificate *string
+ filer *string
+ port *int
+ config *string
+ domainName *string
+ tlsPrivateKey *string
+ tlsCertificate *string
+ metricsHttpPort *int
}
func init() {
@@ -39,6 +40,7 @@ func init() {
s3StandaloneOptions.config = cmdS3.Flag.String("config", "", "path to the config file")
s3StandaloneOptions.tlsPrivateKey = cmdS3.Flag.String("key.file", "", "path to the TLS private key file")
s3StandaloneOptions.tlsCertificate = cmdS3.Flag.String("cert.file", "", "path to the TLS certificate file")
+ s3StandaloneOptions.metricsHttpPort = cmdS3.Flag.Int("metricsPort", 0, "Prometheus metrics listen port")
}
var cmdS3 = &Command{
@@ -153,6 +155,7 @@ func (s3opt *S3Options) startS3Server() bool {
}
}
+ go stats_collect.StartMetricsServer(stats_collect.S3Gather, *s3opt.metricsHttpPort)
go stats_collect.LoopPushingMetric("s3", stats_collect.SourceName(uint32(*s3opt.port)), stats_collect.S3Gather, metricsAddress, metricsIntervalSec)
router := mux.NewRouter().SkipClean(true)
@@ -169,7 +172,6 @@ func (s3opt *S3Options) startS3Server() bool {
if s3ApiServer_err != nil {
glog.Fatalf("S3 API Server startup error: %v", s3ApiServer_err)
}
-
httpS := &http.Server{Handler: router}
listenAddress := fmt.Sprintf(":%d", *s3opt.port)
diff --git a/weed/command/server.go b/weed/command/server.go
index aee62290a..b0c99aacf 100644
--- a/weed/command/server.go
+++ b/weed/command/server.go
@@ -89,6 +89,7 @@ func init() {
filerOptions.dirListingLimit = cmdServer.Flag.Int("filer.dirListLimit", 1000, "limit sub dir listing size")
filerOptions.cipher = cmdServer.Flag.Bool("filer.encryptVolumeData", false, "encrypt data on volume servers")
filerOptions.peers = cmdServer.Flag.String("filer.peers", "", "all filers sharing the same filer store in comma separated ip:port list")
+ filerOptions.metricsHttpPort = cmdServer.Flag.Int("filer.metricsPort", 0, "Prometheus metrics listen port")
serverOptions.v.port = cmdServer.Flag.Int("volume.port", 8080, "volume server http listen port")
serverOptions.v.publicPort = cmdServer.Flag.Int("volume.port.public", 0, "volume server public port")
@@ -100,12 +101,14 @@ func init() {
serverOptions.v.publicUrl = cmdServer.Flag.String("volume.publicUrl", "", "publicly accessible address")
serverOptions.v.preStopSeconds = cmdServer.Flag.Int("volume.preStopSeconds", 10, "number of seconds between stop send heartbeats and stop volume server")
serverOptions.v.pprof = cmdServer.Flag.Bool("volume.pprof", false, "enable pprof http handlers. precludes --memprofile and --cpuprofile")
+ serverOptions.v.metricsHttpPort = cmdServer.Flag.Int("volume.metricsPort", 0, "Prometheus metrics listen port")
s3Options.port = cmdServer.Flag.Int("s3.port", 8333, "s3 server http listen port")
s3Options.domainName = cmdServer.Flag.String("s3.domainName", "", "suffix of the host name, {bucket}.{domainName}")
s3Options.tlsPrivateKey = cmdServer.Flag.String("s3.key.file", "", "path to the TLS private key file")
s3Options.tlsCertificate = cmdServer.Flag.String("s3.cert.file", "", "path to the TLS certificate file")
s3Options.config = cmdServer.Flag.String("s3.config", "", "path to the config file")
+ s3Options.metricsHttpPort = cmdServer.Flag.Int("s3.metricsPort", 0, "Prometheus metrics listen port")
msgBrokerOptions.port = cmdServer.Flag.Int("msgBroker.port", 17777, "broker gRPC listen port")
diff --git a/weed/command/volume.go b/weed/command/volume.go
index 92f83f945..82f2658c3 100644
--- a/weed/command/volume.go
+++ b/weed/command/volume.go
@@ -56,6 +56,7 @@ type VolumeServerOptions struct {
minFreeSpacePercents []float32
pprof *bool
preStopSeconds *int
+ metricsHttpPort *int
// pulseSeconds *int
}
@@ -80,6 +81,7 @@ func init() {
v.compactionMBPerSecond = cmdVolume.Flag.Int("compactionMBps", 0, "limit background compaction or copying speed in mega bytes per second")
v.fileSizeLimitMB = cmdVolume.Flag.Int("fileSizeLimitMB", 1024, "limit file size to avoid out of memory")
v.pprof = cmdVolume.Flag.Bool("pprof", false, "enable pprof http handlers. precludes --memprofile and --cpuprofile")
+ v.metricsHttpPort = cmdVolume.Flag.Int("metricsPort", 0, "Prometheus metrics listen port")
}
var cmdVolume = &Command{
@@ -207,6 +209,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
*v.fixJpgOrientation, *v.readRedirect,
*v.compactionMBPerSecond,
*v.fileSizeLimitMB,
+ *v.metricsHttpPort,
)
// starting grpc server
grpcS := v.startGrpcService(volumeServer)