config.go 1.2 KB

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