Path: blob/main/pkg/integrations/snowflake_exporter/snowflake_exporter.go
5414 views
package snowflake_exporter12import (3"github.com/go-kit/log"4"github.com/grafana/agent/pkg/integrations"5integrations_v2 "github.com/grafana/agent/pkg/integrations/v2"6"github.com/grafana/agent/pkg/integrations/v2/metricsutils"7"github.com/grafana/snowflake-prometheus-exporter/collector"8config_util "github.com/prometheus/common/config"9)1011// DefaultConfig is the default config for the snowflake integration12var DefaultConfig = Config{13Role: "ACCOUNTADMIN",14}1516// Config is the configuration for the snowflake integration17type Config struct {18AccountName string `yaml:"account_name,omitempty"`19Username string `yaml:"username,omitempty"`20Password config_util.Secret `yaml:"password,omitempty"`21Role string `yaml:"role,omitempty"`22Warehouse string `yaml:"warehouse,omitempty"`23}2425func (c *Config) exporterConfig() *collector.Config {26return &collector.Config{27AccountName: c.AccountName,28Username: c.Username,29Password: string(c.Password),30Role: c.Role,31Warehouse: c.Warehouse,32}33}3435// Identifier returns a string that identifies the integration.36func (c *Config) InstanceKey(agentKey string) (string, error) {37return c.AccountName, nil38}3940// UnmarshalYAML implements yaml.Unmarshaler for Config41func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {42*c = DefaultConfig4344type plain Config45return unmarshal((*plain)(c))46}4748// Name returns the name of the integration this config is for.49func (c *Config) Name() string {50return "snowflake"51}5253func init() {54integrations.RegisterIntegration(&Config{})55integrations_v2.RegisterLegacy(&Config{}, integrations_v2.TypeMultiplex, metricsutils.NewNamedShim("snowflake"))56}5758// NewIntegration creates a new integration from the config.59func (c *Config) NewIntegration(l log.Logger) (integrations.Integration, error) {60exporterConfig := c.exporterConfig()6162if err := exporterConfig.Validate(); err != nil {63return nil, err64}6566col := collector.NewCollector(l, exporterConfig)67return integrations.NewCollectorIntegration(68c.Name(),69integrations.WithCollectors(col),70), nil71}727374