metrics.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package env
  2. const (
  3. EmitPodAnnotationsMetricEnvVar = "EMIT_POD_ANNOTATIONS_METRIC"
  4. EmitNamespaceAnnotationsMetricEnvVar = "EMIT_NAMESPACE_ANNOTATIONS_METRIC"
  5. EmitDeprecatedMetrics = "EMIT_DEPRECATED_METRICS"
  6. EmitKsmV1MetricsEnvVar = "EMIT_KSM_V1_METRICS"
  7. EmitKsmV1MetricsOnly = "EMIT_KSM_V1_METRICS_ONLY"
  8. EmitDeploymentLabelsMetricEnvVar = "EMIT_DEPLOYMENT_LABELS_METRIC"
  9. EmitDeploymentAnnotationsMetricEnvVar = "EMIT_DEPLOYMENT_ANNOTATIONS_METRIC"
  10. EmitStatefulSetLabelsMetricEnvVar = "EMIT_STATEFULSET_LABELS_METRIC"
  11. EmitStatefulSetAnnotationsMetricEnvVar = "EMIT_STATEFULSET_ANNOTATIONS_METRIC"
  12. EmitDaemonSetLabelsMetricEnvVar = "EMIT_DAEMONSET_LABELS_METRIC"
  13. EmitDaemonSetAnnotationsMetricEnvVar = "EMIT_DAEMONSET_ANNOTATIONS_METRIC"
  14. EmitJobLabelsMetricEnvVar = "EMIT_JOB_LABELS_METRIC"
  15. EmitJobAnnotationsMetricEnvVar = "EMIT_JOB_ANNOTATIONS_METRIC"
  16. EmitCronJobLabelsMetricEnvVar = "EMIT_CRONJOB_LABELS_METRIC"
  17. EmitCronJobAnnotationsMetricEnvVar = "EMIT_CRONJOB_ANNOTATIONS_METRIC"
  18. EmitReplicaSetLabelsMetricEnvVar = "EMIT_REPLICASET_LABELS_METRIC"
  19. EmitReplicaSetAnnotationsMetricEnvVar = "EMIT_REPLICASET_ANNOTATIONS_METRIC"
  20. )
  21. // IsEmitNamespaceAnnotationsMetric returns true if cost-model is configured to emit the kube_namespace_annotations metric
  22. // containing the namespace annotations
  23. func IsEmitNamespaceAnnotationsMetric() bool {
  24. return GetBool(EmitNamespaceAnnotationsMetricEnvVar, false)
  25. }
  26. // IsEmitPodAnnotationsMetric returns true if cost-model is configured to emit the kube_pod_annotations metric containing
  27. // pod annotations.
  28. func IsEmitPodAnnotationsMetric() bool {
  29. return GetBool(EmitPodAnnotationsMetricEnvVar, false)
  30. }
  31. // IsEmitKsmV1Metrics returns true if cost-model is configured to emit all necessary KSM v1
  32. // metrics that were removed in KSM v2
  33. func IsEmitKsmV1Metrics() bool {
  34. return GetBool(EmitKsmV1MetricsEnvVar, true)
  35. }
  36. func IsEmitKsmV1MetricsOnly() bool {
  37. return GetBool(EmitKsmV1MetricsOnly, false)
  38. }
  39. func IsEmitDeprecatedMetrics() bool {
  40. return GetBool(EmitDeprecatedMetrics, false)
  41. }
  42. func IsEmitDeploymentLabelsMetric() bool {
  43. return GetBool(EmitDeploymentLabelsMetricEnvVar, true)
  44. }
  45. func IsEmitDeploymentAnnotationsMetric() bool {
  46. return GetBool(EmitDeploymentAnnotationsMetricEnvVar, false)
  47. }
  48. func IsEmitStatefulSetLabelsMetric() bool {
  49. return GetBool(EmitStatefulSetLabelsMetricEnvVar, true)
  50. }
  51. func IsEmitStatefulSetAnnotationsMetric() bool {
  52. return GetBool(EmitStatefulSetAnnotationsMetricEnvVar, false)
  53. }
  54. func IsEmitDaemonSetLabelsMetric() bool {
  55. return GetBool(EmitDaemonSetLabelsMetricEnvVar, true)
  56. }
  57. func IsEmitDaemonSetAnnotationsMetric() bool {
  58. return GetBool(EmitDaemonSetAnnotationsMetricEnvVar, false)
  59. }
  60. func IsEmitJobLabelsMetric() bool {
  61. return GetBool(EmitJobLabelsMetricEnvVar, true)
  62. }
  63. func IsEmitJobAnnotationsMetric() bool {
  64. return GetBool(EmitJobAnnotationsMetricEnvVar, false)
  65. }
  66. func IsEmitCronJobLabelsMetric() bool {
  67. return GetBool(EmitCronJobLabelsMetricEnvVar, true)
  68. }
  69. func IsEmitCronJobAnnotationsMetric() bool {
  70. return GetBool(EmitCronJobAnnotationsMetricEnvVar, false)
  71. }
  72. func IsEmitReplicaSetLabelsMetric() bool {
  73. return GetBool(EmitReplicaSetLabelsMetricEnvVar, true)
  74. }
  75. func IsEmitReplicaSetAnnotationsMetric() bool {
  76. return GetBool(EmitReplicaSetAnnotationsMetricEnvVar, false)
  77. }