{-# 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.DevOpsGuru.Types.LogAnomalyClass
-- 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.DevOpsGuru.Types.LogAnomalyClass where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DevOpsGuru.Types.LogAnomalyType
import qualified Amazonka.Prelude as Prelude

-- | Information about an anomalous log event found within a log group.
--
-- /See:/ 'newLogAnomalyClass' smart constructor.
data LogAnomalyClass = LogAnomalyClass'
  { -- | The explanation for why the log event is considered an anomaly.
    LogAnomalyClass -> Maybe Text
explanation :: Prelude.Maybe Prelude.Text,
    -- | The token where the anomaly was detected. This may refer to an exception
    -- or another location, or it may be blank for log anomalies such as format
    -- anomalies.
    LogAnomalyClass -> Maybe Text
logAnomalyToken :: Prelude.Maybe Prelude.Text,
    -- | The type of log anomaly that has been detected.
    LogAnomalyClass -> Maybe LogAnomalyType
logAnomalyType :: Prelude.Maybe LogAnomalyType,
    -- | The ID of the log event.
    LogAnomalyClass -> Maybe Text
logEventId :: Prelude.Maybe Prelude.Text,
    -- | The time of the first occurrence of the anomalous log event.
    LogAnomalyClass -> Maybe POSIX
logEventTimestamp :: Prelude.Maybe Data.POSIX,
    -- | The name of the Amazon CloudWatch log stream that the anomalous log
    -- event belongs to. A log stream is a sequence of log events that share
    -- the same source.
    LogAnomalyClass -> Maybe Text
logStreamName :: Prelude.Maybe Prelude.Text,
    -- | The number of log lines where this anomalous log event occurs.
    LogAnomalyClass -> Maybe Int
numberOfLogLinesOccurrences :: Prelude.Maybe Prelude.Int
  }
  deriving (LogAnomalyClass -> LogAnomalyClass -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogAnomalyClass -> LogAnomalyClass -> Bool
$c/= :: LogAnomalyClass -> LogAnomalyClass -> Bool
== :: LogAnomalyClass -> LogAnomalyClass -> Bool
$c== :: LogAnomalyClass -> LogAnomalyClass -> Bool
Prelude.Eq, ReadPrec [LogAnomalyClass]
ReadPrec LogAnomalyClass
Int -> ReadS LogAnomalyClass
ReadS [LogAnomalyClass]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogAnomalyClass]
$creadListPrec :: ReadPrec [LogAnomalyClass]
readPrec :: ReadPrec LogAnomalyClass
$creadPrec :: ReadPrec LogAnomalyClass
readList :: ReadS [LogAnomalyClass]
$creadList :: ReadS [LogAnomalyClass]
readsPrec :: Int -> ReadS LogAnomalyClass
$creadsPrec :: Int -> ReadS LogAnomalyClass
Prelude.Read, Int -> LogAnomalyClass -> ShowS
[LogAnomalyClass] -> ShowS
LogAnomalyClass -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogAnomalyClass] -> ShowS
$cshowList :: [LogAnomalyClass] -> ShowS
show :: LogAnomalyClass -> String
$cshow :: LogAnomalyClass -> String
showsPrec :: Int -> LogAnomalyClass -> ShowS
$cshowsPrec :: Int -> LogAnomalyClass -> ShowS
Prelude.Show, forall x. Rep LogAnomalyClass x -> LogAnomalyClass
forall x. LogAnomalyClass -> Rep LogAnomalyClass x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogAnomalyClass x -> LogAnomalyClass
$cfrom :: forall x. LogAnomalyClass -> Rep LogAnomalyClass x
Prelude.Generic)

-- |
-- Create a value of 'LogAnomalyClass' 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:
--
-- 'explanation', 'logAnomalyClass_explanation' - The explanation for why the log event is considered an anomaly.
--
-- 'logAnomalyToken', 'logAnomalyClass_logAnomalyToken' - The token where the anomaly was detected. This may refer to an exception
-- or another location, or it may be blank for log anomalies such as format
-- anomalies.
--
-- 'logAnomalyType', 'logAnomalyClass_logAnomalyType' - The type of log anomaly that has been detected.
--
-- 'logEventId', 'logAnomalyClass_logEventId' - The ID of the log event.
--
-- 'logEventTimestamp', 'logAnomalyClass_logEventTimestamp' - The time of the first occurrence of the anomalous log event.
--
-- 'logStreamName', 'logAnomalyClass_logStreamName' - The name of the Amazon CloudWatch log stream that the anomalous log
-- event belongs to. A log stream is a sequence of log events that share
-- the same source.
--
-- 'numberOfLogLinesOccurrences', 'logAnomalyClass_numberOfLogLinesOccurrences' - The number of log lines where this anomalous log event occurs.
newLogAnomalyClass ::
  LogAnomalyClass
newLogAnomalyClass :: LogAnomalyClass
newLogAnomalyClass =
  LogAnomalyClass'
    { $sel:explanation:LogAnomalyClass' :: Maybe Text
explanation = forall a. Maybe a
Prelude.Nothing,
      $sel:logAnomalyToken:LogAnomalyClass' :: Maybe Text
logAnomalyToken = forall a. Maybe a
Prelude.Nothing,
      $sel:logAnomalyType:LogAnomalyClass' :: Maybe LogAnomalyType
logAnomalyType = forall a. Maybe a
Prelude.Nothing,
      $sel:logEventId:LogAnomalyClass' :: Maybe Text
logEventId = forall a. Maybe a
Prelude.Nothing,
      $sel:logEventTimestamp:LogAnomalyClass' :: Maybe POSIX
logEventTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:logStreamName:LogAnomalyClass' :: Maybe Text
logStreamName = forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfLogLinesOccurrences:LogAnomalyClass' :: Maybe Int
numberOfLogLinesOccurrences = forall a. Maybe a
Prelude.Nothing
    }

-- | The explanation for why the log event is considered an anomaly.
logAnomalyClass_explanation :: Lens.Lens' LogAnomalyClass (Prelude.Maybe Prelude.Text)
logAnomalyClass_explanation :: Lens' LogAnomalyClass (Maybe Text)
logAnomalyClass_explanation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogAnomalyClass' {Maybe Text
explanation :: Maybe Text
$sel:explanation:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
explanation} -> Maybe Text
explanation) (\s :: LogAnomalyClass
s@LogAnomalyClass' {} Maybe Text
a -> LogAnomalyClass
s {$sel:explanation:LogAnomalyClass' :: Maybe Text
explanation = Maybe Text
a} :: LogAnomalyClass)

-- | The token where the anomaly was detected. This may refer to an exception
-- or another location, or it may be blank for log anomalies such as format
-- anomalies.
logAnomalyClass_logAnomalyToken :: Lens.Lens' LogAnomalyClass (Prelude.Maybe Prelude.Text)
logAnomalyClass_logAnomalyToken :: Lens' LogAnomalyClass (Maybe Text)
logAnomalyClass_logAnomalyToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogAnomalyClass' {Maybe Text
logAnomalyToken :: Maybe Text
$sel:logAnomalyToken:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
logAnomalyToken} -> Maybe Text
logAnomalyToken) (\s :: LogAnomalyClass
s@LogAnomalyClass' {} Maybe Text
a -> LogAnomalyClass
s {$sel:logAnomalyToken:LogAnomalyClass' :: Maybe Text
logAnomalyToken = Maybe Text
a} :: LogAnomalyClass)

-- | The type of log anomaly that has been detected.
logAnomalyClass_logAnomalyType :: Lens.Lens' LogAnomalyClass (Prelude.Maybe LogAnomalyType)
logAnomalyClass_logAnomalyType :: Lens' LogAnomalyClass (Maybe LogAnomalyType)
logAnomalyClass_logAnomalyType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogAnomalyClass' {Maybe LogAnomalyType
logAnomalyType :: Maybe LogAnomalyType
$sel:logAnomalyType:LogAnomalyClass' :: LogAnomalyClass -> Maybe LogAnomalyType
logAnomalyType} -> Maybe LogAnomalyType
logAnomalyType) (\s :: LogAnomalyClass
s@LogAnomalyClass' {} Maybe LogAnomalyType
a -> LogAnomalyClass
s {$sel:logAnomalyType:LogAnomalyClass' :: Maybe LogAnomalyType
logAnomalyType = Maybe LogAnomalyType
a} :: LogAnomalyClass)

-- | The ID of the log event.
logAnomalyClass_logEventId :: Lens.Lens' LogAnomalyClass (Prelude.Maybe Prelude.Text)
logAnomalyClass_logEventId :: Lens' LogAnomalyClass (Maybe Text)
logAnomalyClass_logEventId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogAnomalyClass' {Maybe Text
logEventId :: Maybe Text
$sel:logEventId:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
logEventId} -> Maybe Text
logEventId) (\s :: LogAnomalyClass
s@LogAnomalyClass' {} Maybe Text
a -> LogAnomalyClass
s {$sel:logEventId:LogAnomalyClass' :: Maybe Text
logEventId = Maybe Text
a} :: LogAnomalyClass)

-- | The time of the first occurrence of the anomalous log event.
logAnomalyClass_logEventTimestamp :: Lens.Lens' LogAnomalyClass (Prelude.Maybe Prelude.UTCTime)
logAnomalyClass_logEventTimestamp :: Lens' LogAnomalyClass (Maybe UTCTime)
logAnomalyClass_logEventTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogAnomalyClass' {Maybe POSIX
logEventTimestamp :: Maybe POSIX
$sel:logEventTimestamp:LogAnomalyClass' :: LogAnomalyClass -> Maybe POSIX
logEventTimestamp} -> Maybe POSIX
logEventTimestamp) (\s :: LogAnomalyClass
s@LogAnomalyClass' {} Maybe POSIX
a -> LogAnomalyClass
s {$sel:logEventTimestamp:LogAnomalyClass' :: Maybe POSIX
logEventTimestamp = Maybe POSIX
a} :: LogAnomalyClass) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the Amazon CloudWatch log stream that the anomalous log
-- event belongs to. A log stream is a sequence of log events that share
-- the same source.
logAnomalyClass_logStreamName :: Lens.Lens' LogAnomalyClass (Prelude.Maybe Prelude.Text)
logAnomalyClass_logStreamName :: Lens' LogAnomalyClass (Maybe Text)
logAnomalyClass_logStreamName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogAnomalyClass' {Maybe Text
logStreamName :: Maybe Text
$sel:logStreamName:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
logStreamName} -> Maybe Text
logStreamName) (\s :: LogAnomalyClass
s@LogAnomalyClass' {} Maybe Text
a -> LogAnomalyClass
s {$sel:logStreamName:LogAnomalyClass' :: Maybe Text
logStreamName = Maybe Text
a} :: LogAnomalyClass)

-- | The number of log lines where this anomalous log event occurs.
logAnomalyClass_numberOfLogLinesOccurrences :: Lens.Lens' LogAnomalyClass (Prelude.Maybe Prelude.Int)
logAnomalyClass_numberOfLogLinesOccurrences :: Lens' LogAnomalyClass (Maybe Int)
logAnomalyClass_numberOfLogLinesOccurrences = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogAnomalyClass' {Maybe Int
numberOfLogLinesOccurrences :: Maybe Int
$sel:numberOfLogLinesOccurrences:LogAnomalyClass' :: LogAnomalyClass -> Maybe Int
numberOfLogLinesOccurrences} -> Maybe Int
numberOfLogLinesOccurrences) (\s :: LogAnomalyClass
s@LogAnomalyClass' {} Maybe Int
a -> LogAnomalyClass
s {$sel:numberOfLogLinesOccurrences:LogAnomalyClass' :: Maybe Int
numberOfLogLinesOccurrences = Maybe Int
a} :: LogAnomalyClass)

instance Data.FromJSON LogAnomalyClass where
  parseJSON :: Value -> Parser LogAnomalyClass
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LogAnomalyClass"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe LogAnomalyType
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Int
-> LogAnomalyClass
LogAnomalyClass'
            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
"Explanation")
            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
"LogAnomalyToken")
            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
"LogAnomalyType")
            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
"LogEventId")
            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
"LogEventTimestamp")
            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
"LogStreamName")
            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
"NumberOfLogLinesOccurrences")
      )

instance Prelude.Hashable LogAnomalyClass where
  hashWithSalt :: Int -> LogAnomalyClass -> Int
hashWithSalt Int
_salt LogAnomalyClass' {Maybe Int
Maybe Text
Maybe POSIX
Maybe LogAnomalyType
numberOfLogLinesOccurrences :: Maybe Int
logStreamName :: Maybe Text
logEventTimestamp :: Maybe POSIX
logEventId :: Maybe Text
logAnomalyType :: Maybe LogAnomalyType
logAnomalyToken :: Maybe Text
explanation :: Maybe Text
$sel:numberOfLogLinesOccurrences:LogAnomalyClass' :: LogAnomalyClass -> Maybe Int
$sel:logStreamName:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
$sel:logEventTimestamp:LogAnomalyClass' :: LogAnomalyClass -> Maybe POSIX
$sel:logEventId:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
$sel:logAnomalyType:LogAnomalyClass' :: LogAnomalyClass -> Maybe LogAnomalyType
$sel:logAnomalyToken:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
$sel:explanation:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
explanation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logAnomalyToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LogAnomalyType
logAnomalyType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logEventId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
logEventTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logStreamName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
numberOfLogLinesOccurrences

instance Prelude.NFData LogAnomalyClass where
  rnf :: LogAnomalyClass -> ()
rnf LogAnomalyClass' {Maybe Int
Maybe Text
Maybe POSIX
Maybe LogAnomalyType
numberOfLogLinesOccurrences :: Maybe Int
logStreamName :: Maybe Text
logEventTimestamp :: Maybe POSIX
logEventId :: Maybe Text
logAnomalyType :: Maybe LogAnomalyType
logAnomalyToken :: Maybe Text
explanation :: Maybe Text
$sel:numberOfLogLinesOccurrences:LogAnomalyClass' :: LogAnomalyClass -> Maybe Int
$sel:logStreamName:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
$sel:logEventTimestamp:LogAnomalyClass' :: LogAnomalyClass -> Maybe POSIX
$sel:logEventId:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
$sel:logAnomalyType:LogAnomalyClass' :: LogAnomalyClass -> Maybe LogAnomalyType
$sel:logAnomalyToken:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
$sel:explanation:LogAnomalyClass' :: LogAnomalyClass -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
explanation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logAnomalyToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LogAnomalyType
logAnomalyType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logEventId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
logEventTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logStreamName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
numberOfLogLinesOccurrences