Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/prometheus/exporter/unix/config.go
4095 views
1
package unix
2
3
import (
4
"time"
5
6
node_integration "github.com/grafana/agent/pkg/integrations/node_exporter"
7
"github.com/grafana/dskit/flagext"
8
)
9
10
// DefaultArguments holds non-zero default options for Arguments when it is
11
// unmarshaled from YAML.
12
//
13
// Some defaults are populated from init functions in the github.com/grafana/agent/pkg/integrations/node_exporter package.
14
var DefaultArguments = Arguments{
15
ProcFSPath: node_integration.DefaultConfig.ProcFSPath,
16
RootFSPath: node_integration.DefaultConfig.RootFSPath,
17
SysFSPath: node_integration.DefaultConfig.SysFSPath,
18
Disk: DiskStatsConfig{
19
DeviceExclude: node_integration.DefaultConfig.DiskStatsDeviceExclude,
20
},
21
EthTool: EthToolConfig{
22
MetricsInclude: ".*",
23
},
24
Filesystem: FilesystemConfig{
25
MountTimeout: 5 * time.Second,
26
MountPointsExclude: node_integration.DefaultConfig.FilesystemMountPointsExclude,
27
FSTypesExclude: node_integration.DefaultConfig.FilesystemFSTypesExclude,
28
},
29
NTP: NTPConfig{
30
IPTTL: 1,
31
LocalOffsetTolerance: time.Millisecond,
32
MaxDistance: time.Microsecond * 3466080,
33
ProtocolVersion: 4,
34
Server: "127.0.0.1",
35
},
36
Netclass: NetclassConfig{
37
IgnoredDevices: "^$",
38
},
39
Netstat: NetstatConfig{
40
Fields: node_integration.DefaultConfig.NetstatFields,
41
},
42
Powersupply: PowersupplyConfig{
43
IgnoredSupplies: "^$",
44
},
45
Runit: RunitConfig{
46
ServiceDir: "/etc/service",
47
},
48
Supervisord: SupervisordConfig{
49
URL: node_integration.DefaultConfig.SupervisordURL,
50
},
51
Systemd: SystemdConfig{
52
UnitExclude: node_integration.DefaultConfig.SystemdUnitExclude,
53
UnitInclude: ".+",
54
},
55
Tapestats: TapestatsConfig{
56
IgnoredDevices: "^$",
57
},
58
VMStat: VMStatConfig{
59
Fields: node_integration.DefaultConfig.VMStatFields,
60
},
61
}
62
63
// Arguments is used for controlling for this exporter.
64
type Arguments struct {
65
IncludeExporterMetrics bool `river:"include_exporter_metrics,attr,optional"`
66
ProcFSPath string `river:"procfs_path,attr,optional"`
67
SysFSPath string `river:"sysfs_path,attr,optional"`
68
RootFSPath string `river:"rootfs_path,attr,optional"`
69
70
// Collectors to mark as enabled
71
EnableCollectors flagext.StringSlice `river:"enable_collectors,attr,optional"`
72
73
// Collectors to mark as disabled
74
DisableCollectors flagext.StringSlice `river:"disable_collectors,attr,optional"`
75
76
// Overrides the default set of enabled collectors with the collectors
77
// listed.
78
SetCollectors flagext.StringSlice `river:"set_collectors,attr,optional"`
79
80
// Collector-specific config options
81
BCache BCacheConfig `river:"bcache,block,optional"`
82
CPU CPUConfig `river:"cpu,block,optional"`
83
Disk DiskStatsConfig `river:"disk,block,optional"`
84
EthTool EthToolConfig `river:"ethtool,block,optional"`
85
Filesystem FilesystemConfig `river:"filesystem,block,optional"`
86
IPVS IPVSConfig `river:"ipvs,block,optional"`
87
NTP NTPConfig `river:"ntp,block,optional"`
88
Netclass NetclassConfig `river:"netclass,block,optional"`
89
Netdev NetdevConfig `river:"netdev,block,optional"`
90
Netstat NetstatConfig `river:"netstat,block,optional"`
91
Perf PerfConfig `river:"perf,block,optional"`
92
Powersupply PowersupplyConfig `river:"powersupply,block,optional"`
93
Runit RunitConfig `river:"runit,block,optional"`
94
Supervisord SupervisordConfig `river:"supervisord,block,optional"`
95
Sysctl SysctlConfig `river:"sysctl,block,optional"`
96
Systemd SystemdConfig `river:"systemd,block,optional"`
97
Tapestats TapestatsConfig `river:"tapestats,block,optional"`
98
Textfile TextfileConfig `river:"textfile,block,optional"`
99
VMStat VMStatConfig `river:"vmstat,block,optional"`
100
}
101
102
// Convert gives a config suitable for use with github.com/grafana/agent/pkg/integrations/node_exporter.
103
func (a *Arguments) Convert() *node_integration.Config {
104
return &node_integration.Config{
105
IncludeExporterMetrics: a.IncludeExporterMetrics,
106
ProcFSPath: a.ProcFSPath,
107
SysFSPath: a.SysFSPath,
108
RootFSPath: a.RootFSPath,
109
EnableCollectors: a.EnableCollectors,
110
DisableCollectors: a.DisableCollectors,
111
SetCollectors: a.SetCollectors,
112
BcachePriorityStats: a.BCache.PriorityStats,
113
CPUBugsInclude: a.CPU.BugsInclude,
114
CPUEnableCPUGuest: a.CPU.EnableCPUGuest,
115
CPUEnableCPUInfo: a.CPU.EnableCPUInfo,
116
CPUFlagsInclude: a.CPU.FlagsInclude,
117
DiskStatsDeviceExclude: a.Disk.DeviceExclude,
118
DiskStatsDeviceInclude: a.Disk.DeviceInclude,
119
EthtoolDeviceExclude: a.EthTool.DeviceExclude,
120
EthtoolDeviceInclude: a.EthTool.DeviceInclude,
121
EthtoolMetricsInclude: a.EthTool.MetricsInclude,
122
FilesystemFSTypesExclude: a.Filesystem.FSTypesExclude,
123
FilesystemMountPointsExclude: a.Filesystem.MountPointsExclude,
124
FilesystemMountTimeout: a.Filesystem.MountTimeout,
125
IPVSBackendLabels: a.IPVS.BackendLabels,
126
NTPIPTTL: a.NTP.IPTTL,
127
NTPLocalOffsetTolerance: a.NTP.LocalOffsetTolerance,
128
NTPMaxDistance: a.NTP.MaxDistance,
129
NTPProtocolVersion: a.NTP.ProtocolVersion,
130
NTPServer: a.NTP.Server,
131
NTPServerIsLocal: a.NTP.ServerIsLocal,
132
NetclassIgnoreInvalidSpeedDevice: a.Netclass.IgnoreInvalidSpeedDevice,
133
NetclassIgnoredDevices: a.Netclass.IgnoredDevices,
134
NetdevAddressInfo: a.Netdev.AddressInfo,
135
NetdevDeviceExclude: a.Netdev.DeviceExclude,
136
NetdevDeviceInclude: a.Netdev.DeviceInclude,
137
NetstatFields: a.Netstat.Fields,
138
PerfCPUS: a.Perf.CPUS,
139
PerfTracepoint: a.Perf.Tracepoint,
140
PowersupplyIgnoredSupplies: a.Powersupply.IgnoredSupplies,
141
RunitServiceDir: a.Runit.ServiceDir,
142
SupervisordURL: a.Supervisord.URL,
143
SysctlInclude: a.Sysctl.Include,
144
SysctlIncludeInfo: a.Sysctl.IncludeInfo,
145
SystemdEnableRestartsMetrics: a.Systemd.EnableRestartsMetrics,
146
SystemdEnableStartTimeMetrics: a.Systemd.EnableStartTimeMetrics,
147
SystemdEnableTaskMetrics: a.Systemd.EnableTaskMetrics,
148
SystemdUnitExclude: a.Systemd.UnitExclude,
149
SystemdUnitInclude: a.Systemd.UnitInclude,
150
TapestatsIgnoredDevices: a.Tapestats.IgnoredDevices,
151
TextfileDirectory: a.Textfile.Directory,
152
VMStatFields: a.VMStat.Fields,
153
}
154
}
155
156
// UnmarshalRiver implements River unmarshalling for Config.
157
func (a *Arguments) UnmarshalRiver(f func(interface{}) error) error {
158
*a = DefaultArguments
159
160
type args Arguments
161
return f((*args)(a))
162
}
163
164
// PowersupplyConfig contains config specific to the powersupply collector.
165
type PowersupplyConfig struct {
166
IgnoredSupplies string `river:"ignored_supplies,attr,optional"`
167
}
168
169
// RunitConfig contains config specific to the runit collector.
170
type RunitConfig struct {
171
ServiceDir string `river:"service_dir,attr,optional"`
172
}
173
174
// SupervisordConfig contains config specific to the supervisord collector.
175
type SupervisordConfig struct {
176
URL string `river:"url,attr,optional"`
177
}
178
179
// TapestatsConfig contains config specific to the tapestats collector.
180
type TapestatsConfig struct {
181
IgnoredDevices string `river:"ignored_devices,attr,optional"`
182
}
183
184
// TextfileConfig contains config specific to the textfile collector.
185
type TextfileConfig struct {
186
Directory string `river:"directory,attr,optional"`
187
}
188
189
// VMStatConfig contains config specific to the vmstat collector.
190
type VMStatConfig struct {
191
Fields string `river:"fields,attr,optional"`
192
}
193
194
// NetclassConfig contains config specific to the netclass collector.
195
type NetclassConfig struct {
196
IgnoreInvalidSpeedDevice bool `river:"ignore_invalid_speed_device,attr,optional"`
197
IgnoredDevices string `river:"ignored_devices,attr,optional"`
198
}
199
200
// NetdevConfig contains config specific to the netdev collector.
201
type NetdevConfig struct {
202
AddressInfo bool `river:"address_info,attr,optional"`
203
DeviceExclude string `river:"device_exclude,attr,optional"`
204
DeviceInclude string `river:"device_include,attr,optional"`
205
}
206
207
// NetstatConfig contains config specific to the netstat collector.
208
type NetstatConfig struct {
209
Fields string `river:"fields,attr,optional"`
210
}
211
212
// PerfConfig contains config specific to the perf collector.
213
type PerfConfig struct {
214
CPUS string `river:"cpus,attr,optional"`
215
Tracepoint flagext.StringSlice `river:"tracepoint,attr,optional"`
216
}
217
218
// EthToolConfig contains config specific to the ethtool collector.
219
type EthToolConfig struct {
220
DeviceExclude string `river:"device_exclude,attr,optional"`
221
DeviceInclude string `river:"device_include,attr,optional"`
222
MetricsInclude string `river:"metrics_include,attr,optional"`
223
}
224
225
// FilesystemConfig contains config specific to the filesystem collector.
226
type FilesystemConfig struct {
227
FSTypesExclude string `river:"fs_types_exclude,attr,optional"`
228
MountPointsExclude string `river:"mount_points_exclude,attr,optional"`
229
MountTimeout time.Duration `river:"mount_timeout,attr,optional"`
230
}
231
232
// IPVSConfig contains config specific to the ipvs collector.
233
type IPVSConfig struct {
234
BackendLabels []string `river:"backend_labels,attr,optional"`
235
}
236
237
// BCacheConfig contains config specific to the bcache collector.
238
type BCacheConfig struct {
239
PriorityStats bool `river:"priority_stats,attr,optional"`
240
}
241
242
// CPUConfig contains config specific to the cpu collector.
243
type CPUConfig struct {
244
BugsInclude string `river:"bugs_include,attr,optional"`
245
EnableCPUGuest bool `river:"guest,attr,optional"`
246
EnableCPUInfo bool `river:"info,attr,optional"`
247
FlagsInclude string `river:"flags_include,attr,optional"`
248
}
249
250
// DiskStatsConfig contains config specific to the diskstats collector.
251
type DiskStatsConfig struct {
252
DeviceExclude string `river:"device_exclude,attr,optional"`
253
DeviceInclude string `river:"device_include,attr,optional"`
254
}
255
256
// NTPConfig contains config specific to the ntp collector.
257
type NTPConfig struct {
258
IPTTL int `river:"ip_ttl,attr,optional"`
259
LocalOffsetTolerance time.Duration `river:"local_offset_tolerance,attr,optional"`
260
MaxDistance time.Duration `river:"max_distance,attr,optional"`
261
ProtocolVersion int `river:"protocol_version,attr,optional"`
262
Server string `river:"server,attr,optional"`
263
ServerIsLocal bool `river:"server_is_local,attr,optional"`
264
}
265
266
// SystemdConfig contains config specific to the systemd collector.
267
type SystemdConfig struct {
268
EnableRestartsMetrics bool `river:"enable_restarts,attr,optional"`
269
EnableStartTimeMetrics bool `river:"start_time,attr,optional"`
270
EnableTaskMetrics bool `river:"task_metrics,attr,optional"`
271
UnitExclude string `river:"unit_exclude,attr,optional"`
272
UnitInclude string `river:"unit_include,attr,optional"`
273
}
274
275
// SysctlConfig contains config specific to the sysctl collector.
276
type SysctlConfig struct {
277
Include []string `river:"include,attr,optional"`
278
IncludeInfo []string `river:"include_info,attr,optional"`
279
}
280
281