config.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package collector
  2. import (
  3. coreenv "github.com/opencost/opencost/core/pkg/env"
  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. }
  13. func NewOpenCostCollectorConfigFromEnv() CollectorConfig {
  14. return CollectorConfig{
  15. Resolutions: []util.ResolutionConfiguration{
  16. {
  17. Interval: "10m",
  18. Retention: env.GetCollector10mResolutionRetention(),
  19. },
  20. {
  21. Interval: "1h",
  22. Retention: env.GetCollector1hResolutionRetention(),
  23. },
  24. {
  25. Interval: "1d",
  26. Retention: env.GetCollection1dResolutionRetention(),
  27. },
  28. },
  29. ScrapeInterval: env.GetCollectorScrapeIntervalSeconds(),
  30. ClusterID: coreenv.GetClusterID(),
  31. NetworkPort: env.GetNetworkPort(),
  32. }
  33. }