Skip to content

Commit

Permalink
allow specifying influx org in config. fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
tedpearson committed Aug 8, 2024
1 parent 60a0c50 commit 819e464
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ smarthub:
influxdb:
host: https://localhost:8428
auth_token: johndoe:influx_password
org: ""
database: db_name
insecure: false
1 change: 1 addition & 0 deletions internal/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type InfluxConfig struct {
Host string `yaml:"host"`
AuthToken string `yaml:"auth_token"`
Org string `yaml:"org"`
Database string `yaml:"database"`
Insecure bool `yaml:"insecure"`
}
Expand Down
2 changes: 1 addition & 1 deletion internal/app/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func WriteMetrics(records []ElectricUsage, config InfluxConfig) error {
opts.SetTLSConfig(&tls.Config{InsecureSkipVerify: true})
}
client := influxdb2.NewClientWithOptions(config.Host, config.AuthToken, opts)
writeApi := client.WriteAPIBlocking("", config.Database)
writeApi := client.WriteAPIBlocking(config.Org, config.Database)
for _, record := range records {
minutes := record.EndTime.Sub(record.StartTime).Minutes()
points := make([]*write.Point, 0, int(minutes))
Expand Down

0 comments on commit 819e464

Please sign in to comment.