Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/prometheus/exporter/memcached/memcached.go
4096 views
1
package memcached
2
3
import (
4
"time"
5
6
"github.com/grafana/agent/component"
7
"github.com/grafana/agent/component/prometheus/exporter"
8
"github.com/grafana/agent/pkg/integrations"
9
"github.com/grafana/agent/pkg/integrations/memcached_exporter"
10
)
11
12
func init() {
13
component.Register(component.Registration{
14
Name: "prometheus.exporter.memcached",
15
Args: Arguments{},
16
Exports: exporter.Exports{},
17
Build: exporter.New(createExporter, "memcached"),
18
})
19
}
20
21
func createExporter(opts component.Options, args component.Arguments) (integrations.Integration, error) {
22
a := args.(Arguments)
23
return a.Convert().NewIntegration(opts.Logger)
24
}
25
26
// DefaultArguments holds the default arguments for the prometheus.exporter.memcached component.
27
var DefaultArguments = Arguments{
28
Address: "localhost:11211",
29
Timeout: time.Second,
30
}
31
32
// Arguments configures the prometheus.exporter.memcached component.
33
type Arguments struct {
34
// Address is the address of the memcached server to connect to (host:port).
35
Address string `river:"address,attr,optional"`
36
37
// Timeout is the timeout for the memcached exporter to use when connecting to the
38
// memcached server.
39
Timeout time.Duration `river:"timeout,attr,optional"`
40
}
41
42
// UnmarshalRiver implements River unmarshalling for Arguments.
43
func (a *Arguments) UnmarshalRiver(f func(interface{}) error) error {
44
*a = DefaultArguments
45
46
type args Arguments
47
return f((*args)(a))
48
}
49
50
func (a Arguments) Convert() *memcached_exporter.Config {
51
return &memcached_exporter.Config{
52
MemcachedAddress: a.Address,
53
Timeout: a.Timeout,
54
}
55
}
56
57