Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prom: Add option to specify metrics prefix #782

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ OPTIONS:
endpoint. (default: false, ie disable metrics)
[$BAZEL_REMOTE_ENABLE_ENDPOINT_METRICS]

--http_metrics_prefix Prefix HTTP metrics names with `bazel_remote`
(default: false, ie no prefix)
[$BAZEL_HTTP_METRICS_PREFIX]

--experimental_remote_asset_api Whether to enable the experimental remote
asset API implementation. (default: false, ie disable remote asset API)
[$BAZEL_REMOTE_EXPERIMENTAL_REMOTE_ASSET_API]
Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type Config struct {
EnableACKeyInstanceMangling bool `yaml:"enable_ac_key_instance_mangling"`
EnableEndpointMetrics bool `yaml:"enable_endpoint_metrics"`
MetricsDurationBuckets []float64 `yaml:"endpoint_metrics_duration_buckets"`
HttpMetricsPrefix bool `yaml:"http_metrics_prefix"`
ExperimentalRemoteAssetAPI bool `yaml:"experimental_remote_asset_api"`
HTTPReadTimeout time.Duration `yaml:"http_read_timeout"`
HTTPWriteTimeout time.Duration `yaml:"http_write_timeout"`
Expand Down Expand Up @@ -175,6 +176,7 @@ func newFromArgs(dir string, maxSize int, storageMode string, zstdImplementation
disableGRPCACDepsCheck bool,
enableACKeyInstanceMangling bool,
enableEndpointMetrics bool,
httpMetricsPrefix bool,
experimentalRemoteAssetAPI bool,
httpReadTimeout time.Duration,
httpWriteTimeout time.Duration,
Expand Down Expand Up @@ -211,6 +213,7 @@ func newFromArgs(dir string, maxSize int, storageMode string, zstdImplementation
EnableACKeyInstanceMangling: enableACKeyInstanceMangling,
EnableEndpointMetrics: enableEndpointMetrics,
MetricsDurationBuckets: defaultDurationBuckets,
HttpMetricsPrefix: httpMetricsPrefix,
ExperimentalRemoteAssetAPI: experimentalRemoteAssetAPI,
HTTPReadTimeout: httpReadTimeout,
HTTPWriteTimeout: httpWriteTimeout,
Expand Down Expand Up @@ -662,6 +665,7 @@ func get(ctx *cli.Context) (*Config, error) {
ctx.Bool("disable_grpc_ac_deps_check"),
ctx.Bool("enable_ac_key_instance_mangling"),
ctx.Bool("enable_endpoint_metrics"),
ctx.Bool("http_metrics_prefix"),
ctx.Bool("experimental_remote_asset_api"),
ctx.Duration("http_read_timeout"),
ctx.Duration("http_write_timeout"),
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,14 @@ func startHttpServer(c *config.Config, httpServer **http.Server,
if c.EnableEndpointMetrics {
log.Println("Endpoint metrics: enabled")

prefix := ""
if c.HttpMetricsPrefix {
prefix = "bazel_remote"
}

metricsMdlw := middleware.New(middleware.Config{
Recorder: httpmetrics.NewRecorder(httpmetrics.Config{
Prefix: prefix,
DurationBuckets: c.MetricsDurationBuckets,
}),
})
Expand Down
6 changes: 6 additions & 0 deletions utils/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,12 @@ func GetCliFlags() []cli.Flag {
DefaultText: "false, ie disable metrics",
EnvVars: []string{"BAZEL_REMOTE_ENABLE_ENDPOINT_METRICS"},
},
&cli.BoolFlag{
Name: "http_metrics_prefix",
Usage: "Prefix to apply to exported http metrics",
kellyma2 marked this conversation as resolved.
Show resolved Hide resolved
DefaultText: "false, ie no prefix",
EnvVars: []string{"BAZEL_HTTP_METRICS_PREFIX"},
kellyma2 marked this conversation as resolved.
Show resolved Hide resolved
},
&cli.BoolFlag{
Name: "experimental_remote_asset_api",
Usage: "Whether to enable the experimental remote asset API implementation.",
Expand Down