metrics

package
v0.65.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:      "metrics",
	Usage:     "Fetch metric values",
	ArgsUsage: "[--host | -H <hostId>] [--service | -s <service>] [--name | -n <metricName>] [--jq <formula>] --from int --to int",
	Description: `
    Fetch metric values of 'host metric' or 'service metric'.
    Requests "/api/v0/hosts/<hostId>/metrics" or "/api/v0/services/<serviceName>/tsdb".
    See https://mackerel.io/api-docs/entry/host-metrics#get, https://mackerel.io/api-docs/entry/service-metrics#get.
`,
	Action: doMetrics,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "host",
			Aliases: []string{"H"},
			Value:   "",
			Usage:   "Fetch host metric values of <hostID>.",
		},
		&cli.StringFlag{
			Name:    "service",
			Aliases: []string{"s"},
			Value:   "",
			Usage:   "Fetch service metric values of <service>.",
		},
		&cli.StringFlag{
			Name:    "name",
			Aliases: []string{"n"},
			Value:   "",
			Usage:   "The name of the metric for which you want to obtain the metric.",
		},
		&cli.Int64Flag{
			Name:  "from",
			Usage: "The first of the period for which you want to obtain the metric. (epoch seconds)",
		},
		&cli.Int64Flag{
			Name:  "to",
			Usage: "The end of the period for which you want to obtain the metric. (epoch seconds)",
		},
		jq.CommandLineFlag,
	},
}
View Source
var CommandFetch = &cli.Command{
	Name:      "fetch",
	Usage:     "Fetch latest metric values",
	ArgsUsage: "[--name | -n <metricName>] [--jq <formula>] hostIds...",
	Description: `
    Fetch latest metric values about the hosts.
    Requests "GET /api/v0/tsdb/latest". See https://mackerel.io/api-docs/entry/host-metrics#get-latest .
`,
	Action: doFetch,
	Flags: []cli.Flag{
		&cli.StringSliceFlag{
			Name:    "name",
			Aliases: []string{"n"},
			Usage:   "Fetch metric values identified with <name>. Required. Multiple choices are allowed. ",
		},
		jq.CommandLineFlag,
	},
}
View Source
var CommandThrow = &cli.Command{
	Name:      "throw",
	Usage:     "Post metric values",
	ArgsUsage: "[--host | -H <hostId>] [--service | -s <service>] [--retry | -r N ] stdin",
	Description: `
    Post metric values to 'host metric' or 'service metric'.
    Output format of metric values are compatible with that of a Sensu plugin.
    Requests "POST /api/v0/tsdb". See https://mackerel.io/api-docs/entry/host-metrics#post .
    Automatically retries the API request when --retry is specified.
`,
	Action: doThrow,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "host",
			Aliases: []string{"H"},
			Value:   "",
			Usage:   "Post host metric values to <hostID>.",
		},
		&cli.StringFlag{
			Name:    "service",
			Aliases: []string{"s"},
			Value:   "",
			Usage:   "Post service metric values to <service>.",
		},
		&cli.IntFlag{
			Name:    "retry",
			Aliases: []string{"r"},
			Usage:   "Retries up to N times when API request fails.",
		},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL