Path: blob/main/component/prometheus/exporter/consul/consul.go
4096 views
package consul12import (3"time"45"github.com/grafana/agent/component"6"github.com/grafana/agent/component/prometheus/exporter"7"github.com/grafana/agent/pkg/integrations"8"github.com/grafana/agent/pkg/integrations/consul_exporter"9)1011func init() {12component.Register(component.Registration{13Name: "prometheus.exporter.consul",14Args: Arguments{},15Exports: exporter.Exports{},16Build: exporter.New(createExporter, "consul"),17})18}1920func createExporter(opts component.Options, args component.Arguments) (integrations.Integration, error) {21a := args.(Arguments)22return a.Convert().NewIntegration(opts.Logger)23}2425// DefaultArguments holds the default settings for the consul_exporter exporter.26var DefaultArguments = Arguments{27Server: "http://localhost:8500",28Timeout: 500 * time.Millisecond,29AllowStale: true,30KVFilter: ".*",31HealthSummary: true,32}3334// Arguments controls the consul_exporter exporter.35type Arguments struct {36Server string `river:"server,attr,optional"`37CAFile string `river:"ca_file,attr,optional"`38CertFile string `river:"cert_file,attr,optional"`39KeyFile string `river:"key_file,attr,optional"`40ServerName string `river:"server_name,attr,optional"`41Timeout time.Duration `river:"timeout,attr,optional"`42InsecureSkipVerify bool `river:"insecure_skip_verify,attr,optional"`43RequestLimit int `river:"concurrent_request_limit,attr,optional"`44AllowStale bool `river:"allow_stale,attr,optional"`45RequireConsistent bool `river:"require_consistent,attr,optional"`4647KVPrefix string `river:"kv_prefix,attr,optional"`48KVFilter string `river:"kv_filter,attr,optional"`49HealthSummary bool `river:"generate_health_summary,attr,optional"`50}5152// UnmarshalRiver implements River unmarshalling for Arguments.53func (a *Arguments) UnmarshalRiver(f func(interface{}) error) error {54*a = DefaultArguments5556type args Arguments57return f((*args)(a))58}5960func (a *Arguments) Convert() *consul_exporter.Config {61return &consul_exporter.Config{62Server: a.Server,63CAFile: a.CAFile,64CertFile: a.CertFile,65KeyFile: a.KeyFile,66ServerName: a.ServerName,67Timeout: a.Timeout,68InsecureSkipVerify: a.InsecureSkipVerify,69RequestLimit: a.RequestLimit,70AllowStale: a.AllowStale,71RequireConsistent: a.RequireConsistent,72KVPrefix: a.KVPrefix,73KVFilter: a.KVFilter,74HealthSummary: a.HealthSummary,75}76}777879