Skip to content

Commit

Permalink
feat: add boostd-data metrics (#1784)
Browse files Browse the repository at this point in the history
* add boostd-data metrics

* go mod tidy

* separate metrics

* cleanup incorrect metrics

* reduce metrics name size

* add new dashboards

* add some traces to boostd-daata

* add API metrics to boostd

* improve dashboard, remove older

* remove info view name

* use unique info view name

* add storage to docker, fix tests

* fix context

* remove extra else and metric
  • Loading branch information
LexLuthr authored Nov 1, 2023
1 parent b70bf8c commit 059e592
Show file tree
Hide file tree
Showing 31 changed files with 8,582 additions and 5,223 deletions.
32 changes: 29 additions & 3 deletions cmd/boostd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ package main

import (
"fmt"
"net/http"
_ "net/http/pprof"
"time"

"github.com/filecoin-project/boost/api"
"github.com/filecoin-project/boost/build"
"github.com/filecoin-project/boost/metrics"
"github.com/filecoin-project/boost/node"
"github.com/filecoin-project/boost/node/modules/dtypes"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"

lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/v0api"
Expand All @@ -16,9 +24,6 @@ import (
lcliutil "github.com/filecoin-project/lotus/cli/util"
lotus_repo "github.com/filecoin-project/lotus/node/repo"

"net/http"
_ "net/http/pprof"

"github.com/urfave/cli/v2"
)

Expand All @@ -35,6 +40,10 @@ var runCmd = &cli.Command{
Name: "nosync",
Usage: "dont wait for the full node to sync with the chain",
},
&cli.BoolFlag{
Name: "no-metrics",
Usage: "stops emitting information about the node as metrics (param is used by tests)",
},
},
Action: func(cctx *cli.Context) error {
if cctx.Bool("pprof") {
Expand All @@ -55,6 +64,23 @@ var runCmd = &cli.Command{

ctx := lcli.ReqContext(cctx)

if !cctx.Bool("no-metrics") {
ctx, _ = tag.New(ctx,
tag.Insert(metrics.Version, build.BuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "boostd"),
tag.Insert(metrics.StartedAt, time.Now().String()),
)
// Register all metric views
if err = view.Register(
metrics.DefaultViews...,
); err != nil {
log.Fatalf("Cannot register the view: %v", err)
}
// Set the metric to one so, it is published to the exporter
stats.Record(ctx, metrics.BoostInfo.M(1))
}

log.Debug("Checking full node version")

v, err := fullnodeApi.Version(ctx)
Expand Down
1 change: 1 addition & 0 deletions cmd/booster-bitswap/multiminer_retrieval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func runBoosterBitswap(ctx context.Context, repo string, minerApiInfo []string,
"--api-fullnode=" + fullNodeApiInfo,
"--api-lid=" + lidApiInfo,
"--api-version-check=false",
"--no-metrics",
}
for _, apiInfo := range minerApiInfo {
args = append(args, "--api-storage="+apiInfo)
Expand Down
25 changes: 25 additions & 0 deletions cmd/booster-bitswap/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"fmt"
"net/http"
_ "net/http/pprof"
"time"

"github.com/filecoin-project/boost/build"
"github.com/filecoin-project/boost/cmd/lib"
"github.com/filecoin-project/boost/cmd/lib/filters"
"github.com/filecoin-project/boost/cmd/lib/remoteblockstore"
Expand All @@ -16,6 +18,9 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
)

var runCmd = &cli.Command{
Expand Down Expand Up @@ -120,6 +125,10 @@ var runCmd = &cli.Command{
Hidden: true,
Value: true,
},
&cli.BoolFlag{
Name: "no-metrics",
Usage: "stops emitting information about the node as metrics (param is used by tests)",
},
},
Action: func(cctx *cli.Context) error {
if cctx.Bool("pprof") {
Expand All @@ -133,6 +142,22 @@ var runCmd = &cli.Command{
}

ctx := lcli.ReqContext(cctx)
if !cctx.Bool("no-metrics") {
ctx, _ = tag.New(ctx,
tag.Insert(metrics.Version, build.BuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "booster-bitswap"),
tag.Insert(metrics.StartedAt, time.Now().String()),
)
// Register all metric views
if err := view.Register(
metrics.DefaultViews...,
); err != nil {
log.Fatalf("Cannot register the view: %v", err)
}
// Set the metric to one so, it is published to the exporter
stats.Record(ctx, metrics.BoostInfo.M(1))
}

// Instantiate the tracer and exporter
if cctx.Bool("tracing") {
Expand Down
1 change: 1 addition & 0 deletions cmd/booster-http/multiminer_retrieval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func runBoosterHttp(ctx context.Context, t *testing.T, minerApiInfo []string, fu
"--api-fullnode=" + fullNodeApiInfo,
"--api-lid=" + lidApiInfo,
"--api-version-check=false",
"--no-metrics",
}, args...)
for _, apiInfo := range minerApiInfo {
args = append(args, "--api-storage="+apiInfo)
Expand Down
29 changes: 28 additions & 1 deletion cmd/booster-http/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"time"

"github.com/filecoin-project/boost/build"
"github.com/filecoin-project/boost/cmd/lib"
"github.com/filecoin-project/boost/cmd/lib/filters"
"github.com/filecoin-project/boost/cmd/lib/remoteblockstore"
Expand All @@ -24,6 +26,9 @@ import (
"github.com/ipfs/go-cid"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
)

const (
Expand Down Expand Up @@ -153,6 +158,10 @@ var runCmd = &cli.Command{
Hidden: true,
Value: true,
},
&cli.BoolFlag{
Name: "no-metrics",
Usage: "stops emitting information about the node as metrics (param is used by tests)",
},
},
Action: func(cctx *cli.Context) error {
servePieces := cctx.Bool("serve-pieces")
Expand All @@ -171,8 +180,26 @@ var runCmd = &cli.Command{
}()
}

// Connect to the local index directory service
ctx := lcli.ReqContext(cctx)

if !cctx.Bool("no-metrics") {
ctx, _ = tag.New(ctx,
tag.Insert(metrics.Version, build.BuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "booster-http"),
tag.Insert(metrics.StartedAt, time.Now().String()),
)
// Register all metric views
if err := view.Register(
metrics.DefaultViews...,
); err != nil {
log.Fatalf("Cannot register the view: %v", err)
}
// Set the metric to one so, it is published to the exporter
stats.Record(ctx, metrics.BoostInfo.M(1))
}

// Connect to the local index directory service
cl := bdclient.NewStore()
defer cl.Close(ctx)
err := cl.Dial(ctx, cctx.String("api-lid"))
Expand Down
1 change: 1 addition & 0 deletions docker/monitoring/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONITORING_DATA=${HOME}/.boost-monitoring
6 changes: 4 additions & 2 deletions docker/monitoring/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
volumes:
- ./tempo-local.yaml:/etc/tempo.yaml
- ./overrides.yaml:/etc/overrides.yaml
- ./tempo-data:/tmp/tempo
- ${MONITORING_DATA}/tempo-data:/tmp/tempo
ports:
- "14268:14268" # jaeger ingest
restart: unless-stopped
Expand Down Expand Up @@ -44,6 +44,7 @@ services:
command: [ "--config.file=/etc/prometheus.yaml" ]
volumes:
- ./${PROMETHEUS_CONFIG_FILE:-prometheus.yaml}:/etc/prometheus.yaml
- ${MONITORING_DATA}/prometheus-data:/prometheus
restart: unless-stopped
ports:
- "9190:9090"
Expand All @@ -56,6 +57,7 @@ services:
#- "booster-http:host-gateway"
#- "booster-bitswap:host-gateway"
#- "lotus-miner:host-gateway"
#- "boostd-data:host-gateway"

logging:
driver: loki
Expand All @@ -76,7 +78,7 @@ services:
#- GF_AUTH_DISABLE_LOGIN_FORM=true
GF_AUTH_SIGV4_AUTH_ENABLED: true
AWS_SDK_LOAD_CONFIG: true
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/exported_dashboard.json"
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/boostd.json"
ports:
- "3333:3000"
restart: unless-stopped
Expand Down
Loading

0 comments on commit 059e592

Please sign in to comment.