costmodelenv.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. package env
  2. import (
  3. "time"
  4. "github.com/opencost/opencost/core/pkg/env"
  5. "github.com/opencost/opencost/core/pkg/log"
  6. "github.com/opencost/opencost/core/pkg/util/timeutil"
  7. )
  8. const (
  9. APIPortEnvVar = "API_PORT"
  10. AWSAccessKeyIDEnvVar = "AWS_ACCESS_KEY_ID"
  11. AWSAccessKeySecretEnvVar = "AWS_SECRET_ACCESS_KEY"
  12. AWSClusterIDEnvVar = "AWS_CLUSTER_ID"
  13. AWSPricingURL = "AWS_PRICING_URL"
  14. AlibabaAccessKeyIDEnvVar = "ALIBABA_ACCESS_KEY_ID"
  15. AlibabaAccessKeySecretEnvVar = "ALIBABA_SECRET_ACCESS_KEY"
  16. AzureOfferIDEnvVar = "AZURE_OFFER_ID"
  17. AzureBillingAccountEnvVar = "AZURE_BILLING_ACCOUNT"
  18. AzureDownloadBillingDataToDiskEnvVar = "AZURE_DOWNLOAD_BILLING_DATA_TO_DISK"
  19. KubecostNamespaceEnvVar = "KUBECOST_NAMESPACE"
  20. PodNameEnvVar = "POD_NAME"
  21. ClusterIDEnvVar = "CLUSTER_ID"
  22. ClusterProfileEnvVar = "CLUSTER_PROFILE"
  23. RemoteEnabledEnvVar = "REMOTE_WRITE_ENABLED"
  24. RemotePWEnvVar = "REMOTE_WRITE_PASSWORD"
  25. SQLAddressEnvVar = "SQL_ADDRESS"
  26. UseCSVProviderEnvVar = "USE_CSV_PROVIDER"
  27. UseCustomProviderEnvVar = "USE_CUSTOM_PROVIDER"
  28. CSVRegionEnvVar = "CSV_REGION"
  29. CSVEndpointEnvVar = "CSV_ENDPOINT"
  30. CSVPathEnvVar = "CSV_PATH"
  31. ConfigPathEnvVar = "CONFIG_PATH"
  32. CloudProviderAPIKeyEnvVar = "CLOUD_PROVIDER_API_KEY"
  33. DisableAggregateCostModelCache = "DISABLE_AGGREGATE_COST_MODEL_CACHE"
  34. EmitPodAnnotationsMetricEnvVar = "EMIT_POD_ANNOTATIONS_METRIC"
  35. EmitNamespaceAnnotationsMetricEnvVar = "EMIT_NAMESPACE_ANNOTATIONS_METRIC"
  36. EmitDeprecatedMetrics = "EMIT_DEPRECATED_METRICS"
  37. EmitKsmV1MetricsEnvVar = "EMIT_KSM_V1_METRICS"
  38. EmitKsmV1MetricsOnly = "EMIT_KSM_V1_METRICS_ONLY"
  39. PProfEnabledEnvVar = "PPROF_ENABLED"
  40. LogCollectionEnabledEnvVar = "LOG_COLLECTION_ENABLED"
  41. ProductAnalyticsEnabledEnvVar = "PRODUCT_ANALYTICS_ENABLED"
  42. ErrorReportingEnabledEnvVar = "ERROR_REPORTING_ENABLED"
  43. ValuesReportingEnabledEnvVar = "VALUES_REPORTING_ENABLED"
  44. KubeRbacProxyEnabled = "KUBE_RBAC_PROXY_ENABLED"
  45. KubeConfigPathEnvVar = "KUBECONFIG_PATH"
  46. UTCOffsetEnvVar = "UTC_OFFSET"
  47. CacheWarmingEnabledEnvVar = "CACHE_WARMING_ENABLED"
  48. ETLEnabledEnvVar = "ETL_ENABLED"
  49. ETLResolutionSeconds = "ETL_RESOLUTION_SECONDS"
  50. LegacyExternalAPIDisabledVar = "LEGACY_EXTERNAL_API_DISABLED"
  51. PricingConfigmapName = "PRICING_CONFIGMAP_NAME"
  52. MetricsConfigmapName = "METRICS_CONFIGMAP_NAME"
  53. KubecostJobNameEnvVar = "KUBECOST_JOB_NAME"
  54. KubecostConfigBucketEnvVar = "KUBECOST_CONFIG_BUCKET"
  55. ClusterInfoFileEnabledEnvVar = "CLUSTER_INFO_FILE_ENABLED"
  56. ClusterCacheFileEnabledEnvVar = "CLUSTER_CACHE_FILE_ENABLED"
  57. IngestPodUIDEnvVar = "INGEST_POD_UID"
  58. ETLReadOnlyMode = "ETL_READ_ONLY"
  59. AllocationNodeLabelsEnabled = "ALLOCATION_NODE_LABELS_ENABLED"
  60. AllocationNodeLabelsIncludeList = "ALLOCATION_NODE_LABELS_INCLUDE_LIST"
  61. AssetIncludeLocalDiskCostEnvVar = "ASSET_INCLUDE_LOCAL_DISK_COST"
  62. regionOverrideList = "REGION_OVERRIDE_LIST"
  63. ExportCSVFile = "EXPORT_CSV_FILE"
  64. ExportCSVLabelsList = "EXPORT_CSV_LABELS_LIST"
  65. ExportCSVLabelsAll = "EXPORT_CSV_LABELS_ALL"
  66. ExportCSVMaxDays = "EXPORT_CSV_MAX_DAYS"
  67. DataRetentionDailyResolutionDaysEnvVar = "DATA_RETENTION_DAILY_RESOLUTION_DAYS"
  68. DataRetentionHourlyResolutionHoursEnvVar = "DATA_RETENTION_HOURLY_RESOLUTION_HOURS"
  69. // We assume that Kubernetes is enabled if there is a KUBERNETES_PORT environment variable present
  70. KubernetesEnabledEnvVar = "KUBERNETES_PORT"
  71. CloudCostEnabledEnvVar = "CLOUD_COST_ENABLED"
  72. CloudCostConfigPath = "CLOUD_COST_CONFIG_PATH"
  73. CloudCostMonthToDateIntervalVar = "CLOUD_COST_MONTH_TO_DATE_INTERVAL"
  74. CloudCostRefreshRateHoursEnvVar = "CLOUD_COST_REFRESH_RATE_HOURS"
  75. CloudCostQueryWindowDaysEnvVar = "CLOUD_COST_QUERY_WINDOW_DAYS"
  76. CloudCostRunWindowDaysEnvVar = "CLOUD_COST_RUN_WINDOW_DAYS"
  77. CustomCostEnabledEnvVar = "CUSTOM_COST_ENABLED"
  78. CustomCostQueryWindowDaysEnvVar = "CUSTOM_COST_QUERY_WINDOW_DAYS"
  79. CustomCostRefreshRateHoursEnvVar = "CUSTOM_COST_REFRESH_RATE_HOURS"
  80. PluginConfigDirEnvVar = "PLUGIN_CONFIG_DIR"
  81. PluginExecutableDirEnvVar = "PLUGIN_EXECUTABLE_DIR"
  82. OCIPricingURL = "OCI_PRICING_URL"
  83. CarbonEstimatesEnabledEnvVar = "CARBON_ESTIMATES_ENABLED"
  84. UseCacheV1 = "USE_CACHE_V1"
  85. )
  86. const DefaultConfigMountPath = "/var/configs"
  87. func IsETLReadOnlyMode() bool {
  88. return env.GetBool(ETLReadOnlyMode, false)
  89. }
  90. func GetExportCSVFile() string {
  91. return env.Get(ExportCSVFile, "")
  92. }
  93. func GetExportCSVLabelsAll() bool {
  94. return env.GetBool(ExportCSVLabelsAll, false)
  95. }
  96. func GetExportCSVLabelsList() []string {
  97. return env.GetList(ExportCSVLabelsList, ",")
  98. }
  99. func IsPProfEnabled() bool {
  100. return env.GetBool(PProfEnabledEnvVar, false)
  101. }
  102. func GetExportCSVMaxDays() int {
  103. return env.GetInt(ExportCSVMaxDays, 90)
  104. }
  105. // GetAPIPort returns the environment variable value for APIPortEnvVar which
  106. // is the port number the API is available on.
  107. func GetAPIPort() int {
  108. return env.GetInt(APIPortEnvVar, 9003)
  109. }
  110. // GetKubecostConfigBucket returns a file location for a mounted bucket configuration which is used to store
  111. // a subset of kubecost configurations that require sharing via remote storage.
  112. func GetKubecostConfigBucket() string {
  113. return env.Get(KubecostConfigBucketEnvVar, "")
  114. }
  115. // IsClusterInfoFileEnabled returns true if the cluster info is read from a file or pulled from the local
  116. // cloud provider and kubernetes.
  117. func IsClusterInfoFileEnabled() bool {
  118. return env.GetBool(ClusterInfoFileEnabledEnvVar, false)
  119. }
  120. // IsClusterCacheFileEnabled returns true if the kubernetes cluster data is read from a file or pulled from the local
  121. // kubernetes API.
  122. func IsClusterCacheFileEnabled() bool {
  123. return env.GetBool(ClusterCacheFileEnabledEnvVar, false)
  124. }
  125. func GetPricingConfigmapName() string {
  126. return env.Get(PricingConfigmapName, "pricing-configs")
  127. }
  128. func GetMetricsConfigmapName() string {
  129. return env.Get(MetricsConfigmapName, "metrics-config")
  130. }
  131. // IsEmitNamespaceAnnotationsMetric returns true if cost-model is configured to emit the kube_namespace_annotations metric
  132. // containing the namespace annotations
  133. func IsEmitNamespaceAnnotationsMetric() bool {
  134. return env.GetBool(EmitNamespaceAnnotationsMetricEnvVar, false)
  135. }
  136. // IsEmitPodAnnotationsMetric returns true if cost-model is configured to emit the kube_pod_annotations metric containing
  137. // pod annotations.
  138. func IsEmitPodAnnotationsMetric() bool {
  139. return env.GetBool(EmitPodAnnotationsMetricEnvVar, false)
  140. }
  141. // IsEmitKsmV1Metrics returns true if cost-model is configured to emit all necessary KSM v1
  142. // metrics that were removed in KSM v2
  143. func IsEmitKsmV1Metrics() bool {
  144. return env.GetBool(EmitKsmV1MetricsEnvVar, true)
  145. }
  146. func IsEmitKsmV1MetricsOnly() bool {
  147. return env.GetBool(EmitKsmV1MetricsOnly, false)
  148. }
  149. func IsEmitDeprecatedMetrics() bool {
  150. return env.GetBool(EmitDeprecatedMetrics, false)
  151. }
  152. // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
  153. // the AWS access key for authentication
  154. func GetAWSAccessKeyID() string {
  155. awsAccessKeyID := env.Get(AWSAccessKeyIDEnvVar, "")
  156. // If the sample nil service key name is set, zero it out so that it is not
  157. // misinterpreted as a real service key.
  158. if awsAccessKeyID == "AKIXXX" {
  159. awsAccessKeyID = ""
  160. }
  161. return awsAccessKeyID
  162. }
  163. // GetAWSAccessKeySecret returns the environment variable value for AWSAccessKeySecretEnvVar which represents
  164. // the AWS access key secret for authentication
  165. func GetAWSAccessKeySecret() string {
  166. return env.Get(AWSAccessKeySecretEnvVar, "")
  167. }
  168. // GetAWSClusterID returns the environment variable value for AWSClusterIDEnvVar which represents
  169. // an AWS specific cluster identifier.
  170. func GetAWSClusterID() string {
  171. return env.Get(AWSClusterIDEnvVar, "")
  172. }
  173. // GetAWSPricingURL returns an optional alternative URL to fetch AWS pricing data from; for use in airgapped environments
  174. func GetAWSPricingURL() string {
  175. return env.Get(AWSPricingURL, "")
  176. }
  177. // GetAlibabaAccessKeyID returns the environment variable value for AlibabaAccessKeyIDEnvVar which represents
  178. // the Alibaba access key for authentication
  179. func GetAlibabaAccessKeyID() string {
  180. return env.Get(AlibabaAccessKeyIDEnvVar, "")
  181. }
  182. // GetAlibabaAccessKeySecret returns the environment variable value for AlibabaAccessKeySecretEnvVar which represents
  183. // the Alibaba access key secret for authentication
  184. func GetAlibabaAccessKeySecret() string {
  185. return env.Get(AlibabaAccessKeySecretEnvVar, "")
  186. }
  187. // GetAzureOfferID returns the environment variable value for AzureOfferIDEnvVar which represents
  188. // the Azure offer ID for determining prices.
  189. func GetAzureOfferID() string {
  190. return env.Get(AzureOfferIDEnvVar, "")
  191. }
  192. // GetAzureBillingAccount returns the environment variable value for
  193. // AzureBillingAccountEnvVar which represents the Azure billing
  194. // account for determining prices. If this is specified
  195. // customer-specific prices will be downloaded from the consumption
  196. // price sheet API.
  197. func GetAzureBillingAccount() string {
  198. return env.Get(AzureBillingAccountEnvVar, "")
  199. }
  200. // IsAzureDownloadBillingDataToDisk returns the environment variable value for
  201. // AzureDownloadBillingDataToDiskEnvVar which indicates whether the Azure
  202. // Billing Data should be held in memory or written to disk.
  203. func IsAzureDownloadBillingDataToDisk() bool {
  204. return env.GetBool(AzureDownloadBillingDataToDiskEnvVar, true)
  205. }
  206. // GetKubecostNamespace returns the environment variable value for KubecostNamespaceEnvVar which
  207. // represents the namespace the cost model exists in.
  208. func GetKubecostNamespace() string {
  209. return env.Get(KubecostNamespaceEnvVar, "kubecost")
  210. }
  211. // GetPodName returns the name of the current running pod. If this environment variable is not set,
  212. // empty string is returned.
  213. func GetPodName() string {
  214. return env.Get(PodNameEnvVar, "")
  215. }
  216. // GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
  217. // represents the cluster profile configured for
  218. func GetClusterProfile() string {
  219. return env.Get(ClusterProfileEnvVar, "development")
  220. }
  221. // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
  222. // configurable identifier used for multi-cluster metric emission.
  223. func GetClusterID() string {
  224. return env.Get(ClusterIDEnvVar, "")
  225. }
  226. func IsKubeRbacProxyEnabled() bool {
  227. return env.GetBool(KubeRbacProxyEnabled, false)
  228. }
  229. // IsAggregateCostModelCacheDisabled returns the environment variable value for DisableAggregateCostModelCache which
  230. // will inform the aggregator on whether to load cached data. Defaults to false
  231. func IsAggregateCostModelCacheDisabled() bool {
  232. return env.GetBool(DisableAggregateCostModelCache, false)
  233. }
  234. // IsRemoteEnabled returns the environment variable value for RemoteEnabledEnvVar which represents whether
  235. // or not remote write is enabled for prometheus for use with SQL backed persistent storage.
  236. func IsRemoteEnabled() bool {
  237. return env.GetBool(RemoteEnabledEnvVar, false)
  238. }
  239. // GetRemotePW returns the environment variable value for RemotePWEnvVar which represents the remote
  240. // persistent storage password.
  241. func GetRemotePW() string {
  242. return env.Get(RemotePWEnvVar, "")
  243. }
  244. // GetSQLAddress returns the environment variable value for SQLAddressEnvVar which represents the SQL
  245. // database address used with remote persistent storage.
  246. func GetSQLAddress() string {
  247. return env.Get(SQLAddressEnvVar, "")
  248. }
  249. // IsUseCSVProvider returns the environment variable value for UseCSVProviderEnvVar which represents
  250. // whether or not the use of a CSV cost provider is enabled.
  251. func IsUseCSVProvider() bool {
  252. return env.GetBool(UseCSVProviderEnvVar, false)
  253. }
  254. // IsUseCustomProvider returns the environment variable value for UseCustomProviderEnvVar which represents
  255. // whether or not the use of a custom cost provider is enabled.
  256. func IsUseCustomProvider() bool {
  257. return env.GetBool(UseCustomProviderEnvVar, false)
  258. }
  259. // GetCSVRegion returns the environment variable value for CSVRegionEnvVar which represents the
  260. // region configured for a CSV provider.
  261. func GetCSVRegion() string {
  262. return env.Get(CSVRegionEnvVar, "")
  263. }
  264. // GetCSVEndpoint returns the environment variable value for CSVEndpointEnvVar which represents the
  265. // endpoint configured for a S3 CSV provider another than AWS S3.
  266. func GetCSVEndpoint() string {
  267. return env.Get(CSVEndpointEnvVar, "")
  268. }
  269. // GetCSVPath returns the environment variable value for CSVPathEnvVar which represents the key path
  270. // configured for a CSV provider.
  271. func GetCSVPath() string {
  272. return env.Get(CSVPathEnvVar, "")
  273. }
  274. // GetCostAnalyzerVolumeMountPath is an alias of GetConfigPath, which returns the mount path for the
  275. // Cost Analyzer volume, which stores configs, persistent data, etc.
  276. func GetCostAnalyzerVolumeMountPath() string {
  277. return GetConfigPathWithDefault(DefaultConfigMountPath)
  278. }
  279. // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
  280. // model configuration path
  281. func GetConfigPathWithDefault(defaultValue string) string {
  282. return env.Get(ConfigPathEnvVar, defaultValue)
  283. }
  284. // GetCloudProviderAPI returns the environment variable value for CloudProviderAPIEnvVar which represents
  285. // the API key provided for the cloud provider.
  286. func GetCloudProviderAPIKey() string {
  287. return env.Get(CloudProviderAPIKeyEnvVar, "")
  288. }
  289. // IsLogCollectionEnabled returns the environment variable value for LogCollectionEnabledEnvVar which represents
  290. // whether or not log collection has been enabled for kubecost deployments.
  291. func IsLogCollectionEnabled() bool {
  292. return env.GetBool(LogCollectionEnabledEnvVar, true)
  293. }
  294. // IsProductAnalyticsEnabled returns the environment variable value for ProductAnalyticsEnabledEnvVar
  295. func IsProductAnalyticsEnabled() bool {
  296. return env.GetBool(ProductAnalyticsEnabledEnvVar, true)
  297. }
  298. // IsErrorReportingEnabled returns the environment variable value for ErrorReportingEnabledEnvVar
  299. func IsErrorReportingEnabled() bool {
  300. return env.GetBool(ErrorReportingEnabledEnvVar, true)
  301. }
  302. // IsValuesReportingEnabled returns the environment variable value for ValuesReportingEnabledEnvVar
  303. func IsValuesReportingEnabled() bool {
  304. return env.GetBool(ValuesReportingEnabledEnvVar, true)
  305. }
  306. // GetKubeConfigPath returns the environment variable value for KubeConfigPathEnvVar
  307. func GetKubeConfigPath() string {
  308. return env.Get(KubeConfigPathEnvVar, "")
  309. }
  310. // GetUTCOffset returns the environment variable value for UTCOffset
  311. func GetUTCOffset() string {
  312. return env.Get(UTCOffsetEnvVar, "")
  313. }
  314. // GetParsedUTCOffset returns the duration of the configured UTC offset
  315. func GetParsedUTCOffset() time.Duration {
  316. offset, err := timeutil.ParseUTCOffset(GetUTCOffset())
  317. if err != nil {
  318. log.Warnf("Failed to parse UTC offset: %s", err)
  319. return time.Duration(0)
  320. }
  321. return offset
  322. }
  323. // GetKubecostJobName returns the environment variable value for KubecostJobNameEnvVar
  324. func GetKubecostJobName() string {
  325. return env.Get(KubecostJobNameEnvVar, "kubecost")
  326. }
  327. func IsCacheWarmingEnabled() bool {
  328. return env.GetBool(CacheWarmingEnabledEnvVar, true)
  329. }
  330. func IsETLEnabled() bool {
  331. return env.GetBool(ETLEnabledEnvVar, true)
  332. }
  333. // GetETLResolution determines the resolution of ETL queries. The smaller the
  334. // duration, the higher the resolution; the higher the resolution, the more
  335. // accurate the query results, but the more computationally expensive.
  336. func GetETLResolution() time.Duration {
  337. // Use the configured ETL resolution, or default to
  338. // 5m (i.e. 300s)
  339. secs := time.Duration(env.GetInt64(ETLResolutionSeconds, 300))
  340. return secs * time.Second
  341. }
  342. func LegacyExternalCostsAPIDisabled() bool {
  343. return env.GetBool(LegacyExternalAPIDisabledVar, false)
  344. }
  345. // IsIngestingPodUID returns the env variable from ingestPodUID, which alters the
  346. // contents of podKeys in Allocation
  347. func IsIngestingPodUID() bool {
  348. return env.GetBool(IngestPodUIDEnvVar, false)
  349. }
  350. func GetAllocationNodeLabelsEnabled() bool {
  351. return env.GetBool(AllocationNodeLabelsEnabled, true)
  352. }
  353. var defaultAllocationNodeLabelsIncludeList []string = []string{
  354. "cloud.google.com/gke-nodepool",
  355. "eks.amazonaws.com/nodegroup",
  356. "kubernetes.azure.com/agentpool",
  357. "node.kubernetes.io/instance-type",
  358. "topology.kubernetes.io/region",
  359. "topology.kubernetes.io/zone",
  360. }
  361. func GetAllocationNodeLabelsIncludeList() []string {
  362. // If node labels are not enabled, return an empty list.
  363. if !GetAllocationNodeLabelsEnabled() {
  364. return []string{}
  365. }
  366. list := env.GetList(AllocationNodeLabelsIncludeList, ",")
  367. // If node labels are enabled, but the white list is empty, use defaults.
  368. if len(list) == 0 {
  369. return defaultAllocationNodeLabelsIncludeList
  370. }
  371. return list
  372. }
  373. func GetAssetIncludeLocalDiskCost() bool {
  374. return env.GetBool(AssetIncludeLocalDiskCostEnvVar, true)
  375. }
  376. func GetRegionOverrideList() []string {
  377. regionList := env.GetList(regionOverrideList, ",")
  378. if regionList == nil {
  379. return []string{}
  380. }
  381. return regionList
  382. }
  383. func GetDataRetentionDailyResolutionDays() int64 {
  384. return env.GetInt64(DataRetentionDailyResolutionDaysEnvVar, 30)
  385. }
  386. func GetDataRetentionHourlyResolutionHours() int64 {
  387. return env.GetInt64(DataRetentionHourlyResolutionHoursEnvVar, 49)
  388. }
  389. func IsKubernetesEnabled() bool {
  390. return env.Get(KubernetesEnabledEnvVar, "") != ""
  391. }
  392. func IsCloudCostEnabled() bool {
  393. return env.GetBool(CloudCostEnabledEnvVar, false)
  394. }
  395. func IsCustomCostEnabled() bool {
  396. return env.GetBool(CustomCostEnabledEnvVar, false)
  397. }
  398. func GetCloudCostConfigPath() string {
  399. return env.Get(CloudCostConfigPath, "cloud-integration.json")
  400. }
  401. func GetCloudCostMonthToDateInterval() int {
  402. return env.GetInt(CloudCostMonthToDateIntervalVar, 6)
  403. }
  404. func GetCloudCostRefreshRateHours() int64 {
  405. return env.GetInt64(CloudCostRefreshRateHoursEnvVar, 6)
  406. }
  407. func GetCloudCostQueryWindowDays() int64 {
  408. return env.GetInt64(CloudCostQueryWindowDaysEnvVar, 7)
  409. }
  410. func GetCustomCostQueryWindowHours() int64 {
  411. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 1)
  412. }
  413. func GetCustomCostQueryWindowDays() int64 {
  414. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 7)
  415. }
  416. func GetCloudCostRunWindowDays() int64 {
  417. return env.GetInt64(CloudCostRunWindowDaysEnvVar, 3)
  418. }
  419. func GetOCIPricingURL() string {
  420. return env.Get(OCIPricingURL, "https://apexapps.oracle.com/pls/apex/cetools/api/v1/products")
  421. }
  422. func GetPluginConfigDir() string {
  423. return env.Get(PluginConfigDirEnvVar, "/opt/opencost/plugin/config")
  424. }
  425. func GetPluginExecutableDir() string {
  426. return env.Get(PluginExecutableDirEnvVar, "/opt/opencost/plugin/bin")
  427. }
  428. func GetCustomCostRefreshRateHours() string {
  429. return env.Get(CustomCostRefreshRateHoursEnvVar, "12h")
  430. }
  431. func IsCarbonEstimatesEnabled() bool {
  432. return env.GetBool(CarbonEstimatesEnabledEnvVar, false)
  433. }
  434. // GetUseCacheV1 is a temporary flag to allow users to opt-in to using the old cache
  435. // Mainly for comparison purposes
  436. func GetUseCacheV1() bool {
  437. return env.GetBool(UseCacheV1, false)
  438. }