Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/pkg/integrations/process_exporter/config.go
5333 views
1
// Package process_exporter embeds https://github.com/ncabatoff/process-exporter
2
package process_exporter //nolint:golint
3
4
import (
5
"github.com/go-kit/log"
6
"github.com/grafana/agent/pkg/integrations"
7
integrations_v2 "github.com/grafana/agent/pkg/integrations/v2"
8
"github.com/grafana/agent/pkg/integrations/v2/metricsutils"
9
10
exporter_config "github.com/ncabatoff/process-exporter/config"
11
)
12
13
// DefaultConfig holds the default settings for the process_exporter integration.
14
var DefaultConfig = Config{
15
ProcFSPath: "/proc",
16
Children: true,
17
Threads: true,
18
SMaps: true,
19
Recheck: false,
20
}
21
22
// Config controls the process_exporter integration.
23
type Config struct {
24
ProcessExporter exporter_config.MatcherRules `yaml:"process_names,omitempty"`
25
26
ProcFSPath string `yaml:"procfs_path,omitempty"`
27
Children bool `yaml:"track_children,omitempty"`
28
Threads bool `yaml:"track_threads,omitempty"`
29
SMaps bool `yaml:"gather_smaps,omitempty"`
30
Recheck bool `yaml:"recheck_on_scrape,omitempty"`
31
}
32
33
// UnmarshalYAML implements yaml.Unmarshaler.
34
func (c *Config) UnmarshalYAML(unmarshal func(v interface{}) error) error {
35
*c = DefaultConfig
36
37
type plain Config
38
return unmarshal((*plain)(c))
39
}
40
41
// Name returns the name of the integration that this config represents.
42
func (c *Config) Name() string {
43
return "process_exporter"
44
}
45
46
// InstanceKey returns the hostname of the machine.
47
func (c *Config) InstanceKey(agentKey string) (string, error) {
48
return agentKey, nil
49
}
50
51
// NewIntegration converts this config into an instance of an integration.
52
func (c *Config) NewIntegration(l log.Logger) (integrations.Integration, error) {
53
return New(l, c)
54
}
55
56
func init() {
57
integrations.RegisterIntegration(&Config{})
58
integrations_v2.RegisterLegacy(&Config{}, integrations_v2.TypeSingleton, metricsutils.NewNamedShim("process"))
59
}
60
61