config.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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
  9. ScrapeInterval string
  10. ClusterUID string
  11. ClusterName string
  12. ApplicationName string
  13. NetworkPort int
  14. }
  15. func NewOpenCostCollectorConfigFromEnv(clusterUID string) CollectorConfig {
  16. return CollectorConfig{
  17. Resolutions: []util.ResolutionConfiguration{
  18. {
  19. Interval: "10m",
  20. Retention: env.GetCollectorResolution10mRetention(),
  21. },
  22. {
  23. Interval: "1h",
  24. Retention: env.GetCollectorResolution1hRetention(),
  25. },
  26. {
  27. Interval: "1d",
  28. Retention: env.GetCollectionResolution1dRetention(),
  29. },
  30. },
  31. ScrapeInterval: env.GetCollectorScrapeIntervalSeconds(),
  32. ClusterUID: clusterUID,
  33. ClusterName: coreenv.GetClusterID(),
  34. ApplicationName: coreenv.GetAppName(),
  35. NetworkPort: env.GetNetworkPort(),
  36. }
  37. }