config.go 1016 B

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