Enabled option to show node and bucket metrics (#4632)
Earlier the command `mc admin prometheus metrics ALIAS` used to display only the cluster-level metrics. This change enables optionally to list node/bucket-specific metrics. Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
@@ -39,24 +39,34 @@ var adminPrometheusMetricsCmd = cli.Command{
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
{{.HelpName}} TARGET [METRIC-TYPE]
|
||||
|
||||
METRIC-TYPE:
|
||||
valid values are ['cluster', 'node', 'bucket']. Defaults to 'cluster' if not specified.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. List of metrics reported cluster wide.
|
||||
{{.Prompt}} {{.HelpName}} play
|
||||
|
||||
2. List of metrics reported at node level.
|
||||
{{.Prompt}} {{.HelpName}} play node
|
||||
|
||||
3. List of metrics reported at bucket level.
|
||||
{{.Prompt}} {{.HelpName}} play bucket
|
||||
`,
|
||||
}
|
||||
|
||||
const (
|
||||
metricsRespBodyLimit = 10 << 20 // 10 MiB
|
||||
metricsEndPoint = "/minio/v2/metrics/cluster"
|
||||
metricsEndPointRoot = "/minio/v2/metrics/"
|
||||
)
|
||||
|
||||
// checkSupportMetricsSyntax - validate arguments passed by a user
|
||||
func checkSupportMetricsSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 {
|
||||
showCommandHelpAndExit(ctx, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
@@ -79,8 +89,16 @@ func printPrometheusMetrics(ctx *cli.Context) error {
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
metricsSubSystem := args.Get(1)
|
||||
switch metricsSubSystem {
|
||||
case "node", "bucket", "cluster":
|
||||
case "":
|
||||
metricsSubSystem = "cluster"
|
||||
default:
|
||||
fatalIf(errInvalidArgument().Trace(), "invalid metric type '%v'", metricsSubSystem)
|
||||
}
|
||||
|
||||
req, e := http.NewRequest(http.MethodGet, hostConfig.URL+metricsEndPoint, nil)
|
||||
req, e := http.NewRequest(http.MethodGet, hostConfig.URL+metricsEndPointRoot+metricsSubSystem, nil)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user