{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ComputeOptimizer.Types.ProjectedMetric
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ComputeOptimizer.Types.ProjectedMetric where

import Amazonka.ComputeOptimizer.Types.MetricName
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes a projected utilization metric of a recommendation option,
-- such as an Amazon EC2 instance. This represents the projected
-- utilization of a recommendation option had you used that resource during
-- the analyzed period.
--
-- Compare the utilization metric data of your resource against its
-- projected utilization metric data to determine the performance
-- difference between your current resource and the recommended option.
--
-- The @Cpu@ and @Memory@ metrics are the only projected utilization
-- metrics returned when you run the GetEC2RecommendationProjectedMetrics
-- action. Additionally, the @Memory@ metric is returned only for resources
-- that have the unified CloudWatch agent installed on them. For more
-- information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
--
-- /See:/ 'newProjectedMetric' smart constructor.
data ProjectedMetric = ProjectedMetric'
  { -- | The name of the projected utilization metric.
    --
    -- The following projected utilization metrics are returned:
    --
    -- -   @Cpu@ - The projected percentage of allocated EC2 compute units that
    --     would be in use on the recommendation option had you used that
    --     resource during the analyzed period. This metric identifies the
    --     processing power required to run an application on the
    --     recommendation option.
    --
    --     Depending on the instance type, tools in your operating system can
    --     show a lower percentage than CloudWatch when the instance is not
    --     allocated a full processor core.
    --
    --     Units: Percent
    --
    -- -   @Memory@ - The percentage of memory that would be in use on the
    --     recommendation option had you used that resource during the analyzed
    --     period. This metric identifies the amount of memory required to run
    --     an application on the recommendation option.
    --
    --     Units: Percent
    --
    --     The @Memory@ metric is returned only for resources that have the
    --     unified CloudWatch agent installed on them. For more information,
    --     see
    --     <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
    ProjectedMetric -> Maybe MetricName
name :: Prelude.Maybe MetricName,
    -- | The timestamps of the projected utilization metric.
    ProjectedMetric -> Maybe [POSIX]
timestamps :: Prelude.Maybe [Data.POSIX],
    -- | The values of the projected utilization metrics.
    ProjectedMetric -> Maybe [Double]
values :: Prelude.Maybe [Prelude.Double]
  }
  deriving (ProjectedMetric -> ProjectedMetric -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProjectedMetric -> ProjectedMetric -> Bool
$c/= :: ProjectedMetric -> ProjectedMetric -> Bool
== :: ProjectedMetric -> ProjectedMetric -> Bool
$c== :: ProjectedMetric -> ProjectedMetric -> Bool
Prelude.Eq, ReadPrec [ProjectedMetric]
ReadPrec ProjectedMetric
Int -> ReadS ProjectedMetric
ReadS [ProjectedMetric]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProjectedMetric]
$creadListPrec :: ReadPrec [ProjectedMetric]
readPrec :: ReadPrec ProjectedMetric
$creadPrec :: ReadPrec ProjectedMetric
readList :: ReadS [ProjectedMetric]
$creadList :: ReadS [ProjectedMetric]
readsPrec :: Int -> ReadS ProjectedMetric
$creadsPrec :: Int -> ReadS ProjectedMetric
Prelude.Read, Int -> ProjectedMetric -> ShowS
[ProjectedMetric] -> ShowS
ProjectedMetric -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProjectedMetric] -> ShowS
$cshowList :: [ProjectedMetric] -> ShowS
show :: ProjectedMetric -> String
$cshow :: ProjectedMetric -> String
showsPrec :: Int -> ProjectedMetric -> ShowS
$cshowsPrec :: Int -> ProjectedMetric -> ShowS
Prelude.Show, forall x. Rep ProjectedMetric x -> ProjectedMetric
forall x. ProjectedMetric -> Rep ProjectedMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProjectedMetric x -> ProjectedMetric
$cfrom :: forall x. ProjectedMetric -> Rep ProjectedMetric x
Prelude.Generic)

-- |
-- Create a value of 'ProjectedMetric' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'name', 'projectedMetric_name' - The name of the projected utilization metric.
--
-- The following projected utilization metrics are returned:
--
-- -   @Cpu@ - The projected percentage of allocated EC2 compute units that
--     would be in use on the recommendation option had you used that
--     resource during the analyzed period. This metric identifies the
--     processing power required to run an application on the
--     recommendation option.
--
--     Depending on the instance type, tools in your operating system can
--     show a lower percentage than CloudWatch when the instance is not
--     allocated a full processor core.
--
--     Units: Percent
--
-- -   @Memory@ - The percentage of memory that would be in use on the
--     recommendation option had you used that resource during the analyzed
--     period. This metric identifies the amount of memory required to run
--     an application on the recommendation option.
--
--     Units: Percent
--
--     The @Memory@ metric is returned only for resources that have the
--     unified CloudWatch agent installed on them. For more information,
--     see
--     <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
--
-- 'timestamps', 'projectedMetric_timestamps' - The timestamps of the projected utilization metric.
--
-- 'values', 'projectedMetric_values' - The values of the projected utilization metrics.
newProjectedMetric ::
  ProjectedMetric
newProjectedMetric :: ProjectedMetric
newProjectedMetric =
  ProjectedMetric'
    { $sel:name:ProjectedMetric' :: Maybe MetricName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamps:ProjectedMetric' :: Maybe [POSIX]
timestamps = forall a. Maybe a
Prelude.Nothing,
      $sel:values:ProjectedMetric' :: Maybe [Double]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the projected utilization metric.
--
-- The following projected utilization metrics are returned:
--
-- -   @Cpu@ - The projected percentage of allocated EC2 compute units that
--     would be in use on the recommendation option had you used that
--     resource during the analyzed period. This metric identifies the
--     processing power required to run an application on the
--     recommendation option.
--
--     Depending on the instance type, tools in your operating system can
--     show a lower percentage than CloudWatch when the instance is not
--     allocated a full processor core.
--
--     Units: Percent
--
-- -   @Memory@ - The percentage of memory that would be in use on the
--     recommendation option had you used that resource during the analyzed
--     period. This metric identifies the amount of memory required to run
--     an application on the recommendation option.
--
--     Units: Percent
--
--     The @Memory@ metric is returned only for resources that have the
--     unified CloudWatch agent installed on them. For more information,
--     see
--     <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
projectedMetric_name :: Lens.Lens' ProjectedMetric (Prelude.Maybe MetricName)
projectedMetric_name :: Lens' ProjectedMetric (Maybe MetricName)
projectedMetric_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectedMetric' {Maybe MetricName
name :: Maybe MetricName
$sel:name:ProjectedMetric' :: ProjectedMetric -> Maybe MetricName
name} -> Maybe MetricName
name) (\s :: ProjectedMetric
s@ProjectedMetric' {} Maybe MetricName
a -> ProjectedMetric
s {$sel:name:ProjectedMetric' :: Maybe MetricName
name = Maybe MetricName
a} :: ProjectedMetric)

-- | The timestamps of the projected utilization metric.
projectedMetric_timestamps :: Lens.Lens' ProjectedMetric (Prelude.Maybe [Prelude.UTCTime])
projectedMetric_timestamps :: Lens' ProjectedMetric (Maybe [UTCTime])
projectedMetric_timestamps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectedMetric' {Maybe [POSIX]
timestamps :: Maybe [POSIX]
$sel:timestamps:ProjectedMetric' :: ProjectedMetric -> Maybe [POSIX]
timestamps} -> Maybe [POSIX]
timestamps) (\s :: ProjectedMetric
s@ProjectedMetric' {} Maybe [POSIX]
a -> ProjectedMetric
s {$sel:timestamps:ProjectedMetric' :: Maybe [POSIX]
timestamps = Maybe [POSIX]
a} :: ProjectedMetric) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The values of the projected utilization metrics.
projectedMetric_values :: Lens.Lens' ProjectedMetric (Prelude.Maybe [Prelude.Double])
projectedMetric_values :: Lens' ProjectedMetric (Maybe [Double])
projectedMetric_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectedMetric' {Maybe [Double]
values :: Maybe [Double]
$sel:values:ProjectedMetric' :: ProjectedMetric -> Maybe [Double]
values} -> Maybe [Double]
values) (\s :: ProjectedMetric
s@ProjectedMetric' {} Maybe [Double]
a -> ProjectedMetric
s {$sel:values:ProjectedMetric' :: Maybe [Double]
values = Maybe [Double]
a} :: ProjectedMetric) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ProjectedMetric where
  parseJSON :: Value -> Parser ProjectedMetric
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProjectedMetric"
      ( \Object
x ->
          Maybe MetricName
-> Maybe [POSIX] -> Maybe [Double] -> ProjectedMetric
ProjectedMetric'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"timestamps" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ProjectedMetric where
  hashWithSalt :: Int -> ProjectedMetric -> Int
hashWithSalt Int
_salt ProjectedMetric' {Maybe [Double]
Maybe [POSIX]
Maybe MetricName
values :: Maybe [Double]
timestamps :: Maybe [POSIX]
name :: Maybe MetricName
$sel:values:ProjectedMetric' :: ProjectedMetric -> Maybe [Double]
$sel:timestamps:ProjectedMetric' :: ProjectedMetric -> Maybe [POSIX]
$sel:name:ProjectedMetric' :: ProjectedMetric -> Maybe MetricName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MetricName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [POSIX]
timestamps
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Double]
values

instance Prelude.NFData ProjectedMetric where
  rnf :: ProjectedMetric -> ()
rnf ProjectedMetric' {Maybe [Double]
Maybe [POSIX]
Maybe MetricName
values :: Maybe [Double]
timestamps :: Maybe [POSIX]
name :: Maybe MetricName
$sel:values:ProjectedMetric' :: ProjectedMetric -> Maybe [Double]
$sel:timestamps:ProjectedMetric' :: ProjectedMetric -> Maybe [POSIX]
$sel:name:ProjectedMetric' :: ProjectedMetric -> Maybe MetricName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MetricName
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [POSIX]
timestamps
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Double]
values