config.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package collector
  2. import (
  3. "fmt"
  4. "github.com/opencost/opencost/modules/collector-source/pkg/env"
  5. "github.com/opencost/opencost/modules/collector-source/pkg/util"
  6. )
  7. type CollectorConfig struct {
  8. Resolutions []util.ResolutionConfiguration `json:"resolutions"`
  9. ScrapeInterval string `json:"scrape_interval"`
  10. ClusterID string `json:"cluster_id"`
  11. NetworkPort int `json:"network_port"`
  12. BucketConfigFile string `json:"bucket_config_file"`
  13. }
  14. func NewOpenCostCollectorConfigFromEnv() CollectorConfig {
  15. return CollectorConfig{
  16. Resolutions: []util.ResolutionConfiguration{
  17. {
  18. Interval: "10m",
  19. Retention: env.GetCollector10mResolutionRetention(),
  20. },
  21. {
  22. Interval: "1h",
  23. Retention: env.GetCollector1hResolutionRetention(),
  24. },
  25. {
  26. Interval: "1d",
  27. Retention: env.GetCollection1dResolutionRetention(),
  28. },
  29. },
  30. ScrapeInterval: fmt.Sprintf("%ds", env.GetCollectorScrapeIntervalSeconds()),
  31. ClusterID: env.GetClusterID(),
  32. NetworkPort: env.GetNetworkPort(),
  33. BucketConfigFile: env.GetExportBucketConfigFile(),
  34. }
  35. }