feat(monitor): add k8s metric describetion

This commit is contained in:
zhaoxiangchun
2021-12-07 17:02:19 +08:00
parent 5c9cf5b725
commit fc69fe9a22
4 changed files with 35 additions and 4 deletions
+2 -2
View File
@@ -75,7 +75,7 @@ func TestCron() {
err = parser.ParseArgs2(os.Args[1:], false, false)
opts := parser.Options().(*options.CloudMonOptions)
opts := parser.Options().(*options.SubCloudMonOptions)
if opts.Help {
fmt.Println(parser.HelpString())
@@ -141,7 +141,7 @@ func TestCron() {
}()
var session *mcclient.ClientSession
session, err = newClientSession(opts)
session, err = newClientSession(&opts.CloudMonOptions)
if err != nil {
showErrorAndExit(err)
}
+2
View File
@@ -30,6 +30,8 @@ const (
METRIC_RES_TYPE_DOMAIN = "domain"
METRIC_RES_TYPE_STORAGE = "storage"
METRIC_RES_TYPE_ELB = "elb"
METRIC_RES_TYPE_K8S = "k8s"
//ext is prefix
METRIC_RES_TYPE_JENKINS = "ext_jenkins"
METRIC_RES_TYPE_EXT_MYSQL = "ext_mysql"
+6 -2
View File
@@ -37,7 +37,10 @@ type CloudMonOptions struct {
KeyFile string `help:"private key file"`
InfluxDatabase string `help:"influxdb database name, default telegraf" default:"telegraf"`
}
type SubCloudMonOptions struct {
CloudMonOptions
Subcommand string `help:"climc subcommand" subcommand:"true"`
}
@@ -63,7 +66,7 @@ type PingProbeOptions struct {
}
func GetArgumentParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParser(&Options,
parse, e := structarg.NewArgumentParser(&SubOptions,
"cloudmon",
`Command-line interface to collect cloud monitoring data.`,
`See "cloudmon help COMMAND" for help on a specific command.`)
@@ -97,5 +100,6 @@ func GetArgumentParser() (*structarg.ArgumentParser, error) {
}
var (
Options CloudMonOptions
Options CloudMonOptions
SubOptions SubCloudMonOptions
)
+25
View File
@@ -455,4 +455,29 @@ func init() {
newMetricFieldCreateInput("messages", "messages", monitor.METRIC_UNIT_COUNT, 4),
})
// k8s
// pod
RegistryMetricCreateInput("k8s_pod", "k8s pod",
monitor.METRIC_RES_TYPE_K8S, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{
newMetricFieldCreateInput("cpu_used_percent", "CPU active state utilization rate", monitor.METRIC_UNIT_PERCENT, 1),
newMetricFieldCreateInput("mem_used_percent", "Used memory rate", monitor.METRIC_UNIT_PERCENT, 2),
newMetricFieldCreateInput("restart_total", "pod restart count", monitor.METRIC_UNIT_COUNT, 3),
})
// deploy/daemonset
RegistryMetricCreateInput("k8s_deploy", "k8s deploy",
monitor.METRIC_RES_TYPE_K8S, monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{
newMetricFieldCreateInput("pod_oom_total", "oom pod count", monitor.METRIC_UNIT_COUNT, 1),
newMetricFieldCreateInput("pod_restarting_total", "restarting pod count", monitor.METRIC_UNIT_COUNT, 2),
})
// node
RegistryMetricCreateInput("k8s_node", "k8s node",
monitor.METRIC_RES_TYPE_K8S, monitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{
newMetricFieldCreateInput("cpu_used_percent", "CPU active state utilization rate", monitor.METRIC_UNIT_PERCENT, 1),
newMetricFieldCreateInput("mem_used_percent", "Used memory rate", monitor.METRIC_UNIT_PERCENT, 2),
newMetricFieldCreateInput("disk_used_percent", "Percentage of used disks", monitor.METRIC_UNIT_PERCENT, 3),
newMetricFieldCreateInput("bps_sent", "Send traffic per second", monitor.METRIC_UNIT_BPS, 3),
newMetricFieldCreateInput("bps_recv", "Received traffic per second", monitor.METRIC_UNIT_BPS, 4),
newMetricFieldCreateInput("pod_restart_total", "pod restart count in node", monitor.METRIC_UNIT_COUNT, 4),
})
}