-
Notifications
You must be signed in to change notification settings - Fork 485
/
snowflake.go
54 lines (46 loc) · 1.62 KB
/
snowflake.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
package snowflake
import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/prometheus/exporter"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/snowflake_exporter"
"github.com/grafana/river/rivertypes"
config_util "github.com/prometheus/common/config"
)
func init() {
component.Register(component.Registration{
Name: "prometheus.exporter.snowflake",
Args: Arguments{},
Exports: exporter.Exports{},
Build: exporter.New(createExporter, "snowflake"),
})
}
func createExporter(opts component.Options, args component.Arguments, defaultInstanceKey string) (integrations.Integration, string, error) {
a := args.(Arguments)
return integrations.NewIntegrationWithInstanceKey(opts.Logger, a.Convert(), defaultInstanceKey)
}
// DefaultArguments holds the default settings for the snowflake exporter
var DefaultArguments = Arguments{
Role: "ACCOUNTADMIN",
}
// Arguments controls the snowflake exporter.
type Arguments struct {
AccountName string `river:"account_name,attr"`
Username string `river:"username,attr"`
Password rivertypes.Secret `river:"password,attr"`
Role string `river:"role,attr,optional"`
Warehouse string `river:"warehouse,attr"`
}
// SetToDefault implements river.Defaulter.
func (a *Arguments) SetToDefault() {
*a = DefaultArguments
}
func (a *Arguments) Convert() *snowflake_exporter.Config {
return &snowflake_exporter.Config{
AccountName: a.AccountName,
Username: a.Username,
Password: config_util.Secret(a.Password),
Role: a.Role,
Warehouse: a.Warehouse,
}
}