-
Notifications
You must be signed in to change notification settings - Fork 490
/
config.go
59 lines (48 loc) · 1.81 KB
/
config.go
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
// Package process_exporter embeds https://github.com/ncabatoff/process-exporter
package process_exporter //nolint:golint
import (
"github.com/go-kit/log"
"github.com/grafana/agent/pkg/integrations"
integrations_v2 "github.com/grafana/agent/pkg/integrations/v2"
"github.com/grafana/agent/pkg/integrations/v2/metricsutils"
exporter_config "github.com/ncabatoff/process-exporter/config"
)
// DefaultConfig holds the default settings for the process_exporter integration.
var DefaultConfig = Config{
ProcFSPath: "/proc",
Children: true,
Threads: true,
SMaps: true,
Recheck: false,
}
// Config controls the process_exporter integration.
type Config struct {
ProcessExporter exporter_config.MatcherRules `yaml:"process_names,omitempty"`
ProcFSPath string `yaml:"procfs_path,omitempty"`
Children bool `yaml:"track_children,omitempty"`
Threads bool `yaml:"track_threads,omitempty"`
SMaps bool `yaml:"gather_smaps,omitempty"`
Recheck bool `yaml:"recheck_on_scrape,omitempty"`
}
// UnmarshalYAML implements yaml.Unmarshaler.
func (c *Config) UnmarshalYAML(unmarshal func(v interface{}) error) error {
*c = DefaultConfig
type plain Config
return unmarshal((*plain)(c))
}
// Name returns the name of the integration that this config represents.
func (c *Config) Name() string {
return "process_exporter"
}
// InstanceKey returns the hostname of the machine.
func (c *Config) InstanceKey(agentKey string) (string, error) {
return agentKey, nil
}
// NewIntegration converts this config into an instance of an integration.
func (c *Config) NewIntegration(l log.Logger) (integrations.Integration, error) {
return New(l, c)
}
func init() {
integrations.RegisterIntegration(&Config{})
integrations_v2.RegisterLegacy(&Config{}, integrations_v2.TypeSingleton, metricsutils.NewNamedShim("process"))
}