summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/k8s_kubelet/metrics.go
blob: 15867b975b6b83965274188c1f87246311119028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// SPDX-License-Identifier: GPL-3.0-or-later

package k8s_kubelet

import (
	mtx "github.com/netdata/netdata/go/go.d.plugin/pkg/metrics"
)

func newMetrics() *metrics {
	var mx metrics
	mx.RESTClient.Requests.ByStatusCode = make(map[string]mtx.Gauge)
	mx.RESTClient.Requests.ByMethod = make(map[string]mtx.Gauge)
	mx.Kubelet.Runtime.Operations = make(map[string]mtx.Gauge)
	mx.Kubelet.Runtime.OperationsErrors = make(map[string]mtx.Gauge)
	mx.Kubelet.Docker.Operations = make(map[string]mtx.Gauge)
	mx.Kubelet.Docker.OperationsErrors = make(map[string]mtx.Gauge)
	mx.Kubelet.PodLogFileSystemUsage = make(map[string]mtx.Gauge)

	return &mx
}

type metrics struct {
	Token         tokenMetrics         `stm:"token"`
	RESTClient    restClientMetrics    `stm:"rest_client"`
	APIServer     apiServerMetrics     `stm:"apiserver"`
	Kubelet       kubeletMetrics       `stm:"kubelet"`
	VolumeManager volumeManagerMetrics `stm:"volume_manager"`
}

type tokenMetrics struct {
	Count     mtx.Gauge `stm:"count"`
	FailCount mtx.Gauge `stm:"fail_count"`
}

type restClientMetrics struct {
	Requests struct {
		ByStatusCode map[string]mtx.Gauge `stm:""`
		ByMethod     map[string]mtx.Gauge `stm:""`
	} `stm:"requests"`
}

type apiServerMetrics struct {
	Audit struct {
		Requests struct {
			Rejected mtx.Gauge `stm:"rejected_total"`
		} `stm:"requests"`
	} `stm:"audit"`
	Storage struct {
		EnvelopeTransformation struct {
			CacheMisses mtx.Gauge `stm:"cache_misses_total"`
		} `stm:"envelope_transformation"`
		DataKeyGeneration struct {
			Failures  mtx.Gauge `stm:"failures_total"`
			Latencies struct {
				LE5     mtx.Gauge `stm:"5"`
				LE10    mtx.Gauge `stm:"10"`
				LE20    mtx.Gauge `stm:"20"`
				LE40    mtx.Gauge `stm:"40"`
				LE80    mtx.Gauge `stm:"80"`
				LE160   mtx.Gauge `stm:"160"`
				LE320   mtx.Gauge `stm:"320"`
				LE640   mtx.Gauge `stm:"640"`
				LE1280  mtx.Gauge `stm:"1280"`
				LE2560  mtx.Gauge `stm:"2560"`
				LE5120  mtx.Gauge `stm:"5120"`
				LE10240 mtx.Gauge `stm:"10240"`
				LE20480 mtx.Gauge `stm:"20480"`
				LE40960 mtx.Gauge `stm:"40960"`
				LEInf   mtx.Gauge `stm:"+Inf"`
			} `stm:"bucket"`
		} `stm:"data_key_generation"`
	} `stm:"storage"`
}

type kubeletMetrics struct {
	NodeConfigError       mtx.Gauge `stm:"node_config_error"`
	RunningContainerCount mtx.Gauge `stm:"running_container"`
	RunningPodCount       mtx.Gauge `stm:"running_pod"`
	PLEG                  struct {
		Relist struct {
			Interval struct {
				Quantile05  mtx.Gauge `stm:"05"`
				Quantile09  mtx.Gauge `stm:"09"`
				Quantile099 mtx.Gauge `stm:"099"`
			} `stm:"interval"`
			Latency struct {
				Quantile05  mtx.Gauge `stm:"05"`
				Quantile09  mtx.Gauge `stm:"09"`
				Quantile099 mtx.Gauge `stm:"099"`
			} `stm:"latency"`
		} `stm:"relist"`
	} `stm:"pleg"`
	Runtime struct {
		Operations       map[string]mtx.Gauge `stm:"operations"`
		OperationsErrors map[string]mtx.Gauge `stm:"operations_errors"`
	} `stm:"runtime"`
	Docker struct {
		Operations       map[string]mtx.Gauge `stm:"operations"`
		OperationsErrors map[string]mtx.Gauge `stm:"operations_errors"`
	} `stm:"docker"`
	PodLogFileSystemUsage map[string]mtx.Gauge `stm:"log_file_system_usage"`
}

type volumeManagerMetrics struct {
	Plugins map[string]*volumeManagerPlugin `stm:"plugin"`
}

type volumeManagerPlugin struct {
	State struct {
		Actual  mtx.Gauge `stm:"actual"`
		Desired mtx.Gauge `stm:"desired"`
	} `stm:"state"`
}