{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Amazonka.Lightsail.GetRelationalDatabaseMetricData -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Returns the data points of the specified metric for a database in Amazon -- Lightsail. -- -- Metrics report the utilization of your resources, and the error counts -- generated by them. Monitor and collect metric data regularly to maintain -- the reliability, availability, and performance of your resources. module Amazonka.Lightsail.GetRelationalDatabaseMetricData ( -- * Creating a Request GetRelationalDatabaseMetricData (..), newGetRelationalDatabaseMetricData, -- * Request Lenses getRelationalDatabaseMetricData_relationalDatabaseName, getRelationalDatabaseMetricData_metricName, getRelationalDatabaseMetricData_period, getRelationalDatabaseMetricData_startTime, getRelationalDatabaseMetricData_endTime, getRelationalDatabaseMetricData_unit, getRelationalDatabaseMetricData_statistics, -- * Destructuring the Response GetRelationalDatabaseMetricDataResponse (..), newGetRelationalDatabaseMetricDataResponse, -- * Response Lenses getRelationalDatabaseMetricDataResponse_metricData, getRelationalDatabaseMetricDataResponse_metricName, getRelationalDatabaseMetricDataResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.Lightsail.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newGetRelationalDatabaseMetricData' smart constructor. data GetRelationalDatabaseMetricData = GetRelationalDatabaseMetricData' { -- | The name of your database from which to get metric data. relationalDatabaseName :: Prelude.Text, -- | The metric for which you want to return information. -- -- Valid relational database metric names are listed below, along with the -- most useful @statistics@ to include in your request, and the published -- @unit@ value. All relational database metric data is available in -- 1-minute (60 seconds) granularity. -- -- - __@CPUUtilization@__ - The percentage of CPU utilization currently -- in use on the database. -- -- @Statistics@: The most useful statistics are @Maximum@ and -- @Average@. -- -- @Unit@: The published unit is @Percent@. -- -- - __@DatabaseConnections@__ - The number of database connections in -- use. -- -- @Statistics@: The most useful statistics are @Maximum@ and @Sum@. -- -- @Unit@: The published unit is @Count@. -- -- - __@DiskQueueDepth@__ - The number of outstanding IOs (read\/write -- requests) that are waiting to access the disk. -- -- @Statistics@: The most useful statistic is @Sum@. -- -- @Unit@: The published unit is @Count@. -- -- - __@FreeStorageSpace@__ - The amount of available storage space. -- -- @Statistics@: The most useful statistic is @Sum@. -- -- @Unit@: The published unit is @Bytes@. -- -- - __@NetworkReceiveThroughput@__ - The incoming (Receive) network -- traffic on the database, including both customer database traffic -- and AWS traffic used for monitoring and replication. -- -- @Statistics@: The most useful statistic is @Average@. -- -- @Unit@: The published unit is @Bytes\/Second@. -- -- - __@NetworkTransmitThroughput@__ - The outgoing (Transmit) network -- traffic on the database, including both customer database traffic -- and AWS traffic used for monitoring and replication. -- -- @Statistics@: The most useful statistic is @Average@. -- -- @Unit@: The published unit is @Bytes\/Second@. metricName :: RelationalDatabaseMetricName, -- | The granularity, in seconds, of the returned data points. -- -- All relational database metric data is available in 1-minute (60 -- seconds) granularity. period :: Prelude.Natural, -- | The start of the time interval from which to get metric data. -- -- Constraints: -- -- - Specified in Coordinated Universal Time (UTC). -- -- - Specified in the Unix time format. -- -- For example, if you wish to use a start time of October 1, 2018, at -- 8 PM UTC, then you input @1538424000@ as the start time. startTime :: Data.POSIX, -- | The end of the time interval from which to get metric data. -- -- Constraints: -- -- - Specified in Coordinated Universal Time (UTC). -- -- - Specified in the Unix time format. -- -- For example, if you wish to use an end time of October 1, 2018, at 8 -- PM UTC, then you input @1538424000@ as the end time. endTime :: Data.POSIX, -- | The unit for the metric data request. Valid units depend on the metric -- data being requested. For the valid units with each available metric, -- see the @metricName@ parameter. unit :: MetricUnit, -- | The statistic for the metric. -- -- The following statistics are available: -- -- - @Minimum@ - The lowest value observed during the specified period. -- Use this value to determine low volumes of activity for your -- application. -- -- - @Maximum@ - The highest value observed during the specified period. -- Use this value to determine high volumes of activity for your -- application. -- -- - @Sum@ - All values submitted for the matching metric added together. -- You can use this statistic to determine the total volume of a -- metric. -- -- - @Average@ - The value of Sum \/ SampleCount during the specified -- period. By comparing this statistic with the Minimum and Maximum -- values, you can determine the full scope of a metric and how close -- the average use is to the Minimum and Maximum values. This -- comparison helps you to know when to increase or decrease your -- resources. -- -- - @SampleCount@ - The count, or number, of data points used for the -- statistical calculation. statistics :: [MetricStatistic] } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'GetRelationalDatabaseMetricData' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'relationalDatabaseName', 'getRelationalDatabaseMetricData_relationalDatabaseName' - The name of your database from which to get metric data. -- -- 'metricName', 'getRelationalDatabaseMetricData_metricName' - The metric for which you want to return information. -- -- Valid relational database metric names are listed below, along with the -- most useful @statistics@ to include in your request, and the published -- @unit@ value. All relational database metric data is available in -- 1-minute (60 seconds) granularity. -- -- - __@CPUUtilization@__ - The percentage of CPU utilization currently -- in use on the database. -- -- @Statistics@: The most useful statistics are @Maximum@ and -- @Average@. -- -- @Unit@: The published unit is @Percent@. -- -- - __@DatabaseConnections@__ - The number of database connections in -- use. -- -- @Statistics@: The most useful statistics are @Maximum@ and @Sum@. -- -- @Unit@: The published unit is @Count@. -- -- - __@DiskQueueDepth@__ - The number of outstanding IOs (read\/write -- requests) that are waiting to access the disk. -- -- @Statistics@: The most useful statistic is @Sum@. -- -- @Unit@: The published unit is @Count@. -- -- - __@FreeStorageSpace@__ - The amount of available storage space. -- -- @Statistics@: The most useful statistic is @Sum@. -- -- @Unit@: The published unit is @Bytes@. -- -- - __@NetworkReceiveThroughput@__ - The incoming (Receive) network -- traffic on the database, including both customer database traffic -- and AWS traffic used for monitoring and replication. -- -- @Statistics@: The most useful statistic is @Average@. -- -- @Unit@: The published unit is @Bytes\/Second@. -- -- - __@NetworkTransmitThroughput@__ - The outgoing (Transmit) network -- traffic on the database, including both customer database traffic -- and AWS traffic used for monitoring and replication. -- -- @Statistics@: The most useful statistic is @Average@. -- -- @Unit@: The published unit is @Bytes\/Second@. -- -- 'period', 'getRelationalDatabaseMetricData_period' - The granularity, in seconds, of the returned data points. -- -- All relational database metric data is available in 1-minute (60 -- seconds) granularity. -- -- 'startTime', 'getRelationalDatabaseMetricData_startTime' - The start of the time interval from which to get metric data. -- -- Constraints: -- -- - Specified in Coordinated Universal Time (UTC). -- -- - Specified in the Unix time format. -- -- For example, if you wish to use a start time of October 1, 2018, at -- 8 PM UTC, then you input @1538424000@ as the start time. -- -- 'endTime', 'getRelationalDatabaseMetricData_endTime' - The end of the time interval from which to get metric data. -- -- Constraints: -- -- - Specified in Coordinated Universal Time (UTC). -- -- - Specified in the Unix time format. -- -- For example, if you wish to use an end time of October 1, 2018, at 8 -- PM UTC, then you input @1538424000@ as the end time. -- -- 'unit', 'getRelationalDatabaseMetricData_unit' - The unit for the metric data request. Valid units depend on the metric -- data being requested. For the valid units with each available metric, -- see the @metricName@ parameter. -- -- 'statistics', 'getRelationalDatabaseMetricData_statistics' - The statistic for the metric. -- -- The following statistics are available: -- -- - @Minimum@ - The lowest value observed during the specified period. -- Use this value to determine low volumes of activity for your -- application. -- -- - @Maximum@ - The highest value observed during the specified period. -- Use this value to determine high volumes of activity for your -- application. -- -- - @Sum@ - All values submitted for the matching metric added together. -- You can use this statistic to determine the total volume of a -- metric. -- -- - @Average@ - The value of Sum \/ SampleCount during the specified -- period. By comparing this statistic with the Minimum and Maximum -- values, you can determine the full scope of a metric and how close -- the average use is to the Minimum and Maximum values. This -- comparison helps you to know when to increase or decrease your -- resources. -- -- - @SampleCount@ - The count, or number, of data points used for the -- statistical calculation. newGetRelationalDatabaseMetricData :: -- | 'relationalDatabaseName' Prelude.Text -> -- | 'metricName' RelationalDatabaseMetricName -> -- | 'period' Prelude.Natural -> -- | 'startTime' Prelude.UTCTime -> -- | 'endTime' Prelude.UTCTime -> -- | 'unit' MetricUnit -> GetRelationalDatabaseMetricData newGetRelationalDatabaseMetricData pRelationalDatabaseName_ pMetricName_ pPeriod_ pStartTime_ pEndTime_ pUnit_ = GetRelationalDatabaseMetricData' { relationalDatabaseName = pRelationalDatabaseName_, metricName = pMetricName_, period = pPeriod_, startTime = Data._Time Lens.# pStartTime_, endTime = Data._Time Lens.# pEndTime_, unit = pUnit_, statistics = Prelude.mempty } -- | The name of your database from which to get metric data. getRelationalDatabaseMetricData_relationalDatabaseName :: Lens.Lens' GetRelationalDatabaseMetricData Prelude.Text getRelationalDatabaseMetricData_relationalDatabaseName = Lens.lens (\GetRelationalDatabaseMetricData' {relationalDatabaseName} -> relationalDatabaseName) (\s@GetRelationalDatabaseMetricData' {} a -> s {relationalDatabaseName = a} :: GetRelationalDatabaseMetricData) -- | The metric for which you want to return information. -- -- Valid relational database metric names are listed below, along with the -- most useful @statistics@ to include in your request, and the published -- @unit@ value. All relational database metric data is available in -- 1-minute (60 seconds) granularity. -- -- - __@CPUUtilization@__ - The percentage of CPU utilization currently -- in use on the database. -- -- @Statistics@: The most useful statistics are @Maximum@ and -- @Average@. -- -- @Unit@: The published unit is @Percent@. -- -- - __@DatabaseConnections@__ - The number of database connections in -- use. -- -- @Statistics@: The most useful statistics are @Maximum@ and @Sum@. -- -- @Unit@: The published unit is @Count@. -- -- - __@DiskQueueDepth@__ - The number of outstanding IOs (read\/write -- requests) that are waiting to access the disk. -- -- @Statistics@: The most useful statistic is @Sum@. -- -- @Unit@: The published unit is @Count@. -- -- - __@FreeStorageSpace@__ - The amount of available storage space. -- -- @Statistics@: The most useful statistic is @Sum@. -- -- @Unit@: The published unit is @Bytes@. -- -- - __@NetworkReceiveThroughput@__ - The incoming (Receive) network -- traffic on the database, including both customer database traffic -- and AWS traffic used for monitoring and replication. -- -- @Statistics@: The most useful statistic is @Average@. -- -- @Unit@: The published unit is @Bytes\/Second@. -- -- - __@NetworkTransmitThroughput@__ - The outgoing (Transmit) network -- traffic on the database, including both customer database traffic -- and AWS traffic used for monitoring and replication. -- -- @Statistics@: The most useful statistic is @Average@. -- -- @Unit@: The published unit is @Bytes\/Second@. getRelationalDatabaseMetricData_metricName :: Lens.Lens' GetRelationalDatabaseMetricData RelationalDatabaseMetricName getRelationalDatabaseMetricData_metricName = Lens.lens (\GetRelationalDatabaseMetricData' {metricName} -> metricName) (\s@GetRelationalDatabaseMetricData' {} a -> s {metricName = a} :: GetRelationalDatabaseMetricData) -- | The granularity, in seconds, of the returned data points. -- -- All relational database metric data is available in 1-minute (60 -- seconds) granularity. getRelationalDatabaseMetricData_period :: Lens.Lens' GetRelationalDatabaseMetricData Prelude.Natural getRelationalDatabaseMetricData_period = Lens.lens (\GetRelationalDatabaseMetricData' {period} -> period) (\s@GetRelationalDatabaseMetricData' {} a -> s {period = a} :: GetRelationalDatabaseMetricData) -- | The start of the time interval from which to get metric data. -- -- Constraints: -- -- - Specified in Coordinated Universal Time (UTC). -- -- - Specified in the Unix time format. -- -- For example, if you wish to use a start time of October 1, 2018, at -- 8 PM UTC, then you input @1538424000@ as the start time. getRelationalDatabaseMetricData_startTime :: Lens.Lens' GetRelationalDatabaseMetricData Prelude.UTCTime getRelationalDatabaseMetricData_startTime = Lens.lens (\GetRelationalDatabaseMetricData' {startTime} -> startTime) (\s@GetRelationalDatabaseMetricData' {} a -> s {startTime = a} :: GetRelationalDatabaseMetricData) Prelude.. Data._Time -- | The end of the time interval from which to get metric data. -- -- Constraints: -- -- - Specified in Coordinated Universal Time (UTC). -- -- - Specified in the Unix time format. -- -- For example, if you wish to use an end time of October 1, 2018, at 8 -- PM UTC, then you input @1538424000@ as the end time. getRelationalDatabaseMetricData_endTime :: Lens.Lens' GetRelationalDatabaseMetricData Prelude.UTCTime getRelationalDatabaseMetricData_endTime = Lens.lens (\GetRelationalDatabaseMetricData' {endTime} -> endTime) (\s@GetRelationalDatabaseMetricData' {} a -> s {endTime = a} :: GetRelationalDatabaseMetricData) Prelude.. Data._Time -- | The unit for the metric data request. Valid units depend on the metric -- data being requested. For the valid units with each available metric, -- see the @metricName@ parameter. getRelationalDatabaseMetricData_unit :: Lens.Lens' GetRelationalDatabaseMetricData MetricUnit getRelationalDatabaseMetricData_unit = Lens.lens (\GetRelationalDatabaseMetricData' {unit} -> unit) (\s@GetRelationalDatabaseMetricData' {} a -> s {unit = a} :: GetRelationalDatabaseMetricData) -- | The statistic for the metric. -- -- The following statistics are available: -- -- - @Minimum@ - The lowest value observed during the specified period. -- Use this value to determine low volumes of activity for your -- application. -- -- - @Maximum@ - The highest value observed during the specified period. -- Use this value to determine high volumes of activity for your -- application. -- -- - @Sum@ - All values submitted for the matching metric added together. -- You can use this statistic to determine the total volume of a -- metric. -- -- - @Average@ - The value of Sum \/ SampleCount during the specified -- period. By comparing this statistic with the Minimum and Maximum -- values, you can determine the full scope of a metric and how close -- the average use is to the Minimum and Maximum values. This -- comparison helps you to know when to increase or decrease your -- resources. -- -- - @SampleCount@ - The count, or number, of data points used for the -- statistical calculation. getRelationalDatabaseMetricData_statistics :: Lens.Lens' GetRelationalDatabaseMetricData [MetricStatistic] getRelationalDatabaseMetricData_statistics = Lens.lens (\GetRelationalDatabaseMetricData' {statistics} -> statistics) (\s@GetRelationalDatabaseMetricData' {} a -> s {statistics = a} :: GetRelationalDatabaseMetricData) Prelude.. Lens.coerced instance Core.AWSRequest GetRelationalDatabaseMetricData where type AWSResponse GetRelationalDatabaseMetricData = GetRelationalDatabaseMetricDataResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> GetRelationalDatabaseMetricDataResponse' Prelude.<$> (x Data..?> "metricData" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "metricName") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable GetRelationalDatabaseMetricData where hashWithSalt _salt GetRelationalDatabaseMetricData' {..} = _salt `Prelude.hashWithSalt` relationalDatabaseName `Prelude.hashWithSalt` metricName `Prelude.hashWithSalt` period `Prelude.hashWithSalt` startTime `Prelude.hashWithSalt` endTime `Prelude.hashWithSalt` unit `Prelude.hashWithSalt` statistics instance Prelude.NFData GetRelationalDatabaseMetricData where rnf GetRelationalDatabaseMetricData' {..} = Prelude.rnf relationalDatabaseName `Prelude.seq` Prelude.rnf metricName `Prelude.seq` Prelude.rnf period `Prelude.seq` Prelude.rnf startTime `Prelude.seq` Prelude.rnf endTime `Prelude.seq` Prelude.rnf unit `Prelude.seq` Prelude.rnf statistics instance Data.ToHeaders GetRelationalDatabaseMetricData where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "Lightsail_20161128.GetRelationalDatabaseMetricData" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON GetRelationalDatabaseMetricData where toJSON GetRelationalDatabaseMetricData' {..} = Data.object ( Prelude.catMaybes [ Prelude.Just ( "relationalDatabaseName" Data..= relationalDatabaseName ), Prelude.Just ("metricName" Data..= metricName), Prelude.Just ("period" Data..= period), Prelude.Just ("startTime" Data..= startTime), Prelude.Just ("endTime" Data..= endTime), Prelude.Just ("unit" Data..= unit), Prelude.Just ("statistics" Data..= statistics) ] ) instance Data.ToPath GetRelationalDatabaseMetricData where toPath = Prelude.const "/" instance Data.ToQuery GetRelationalDatabaseMetricData where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newGetRelationalDatabaseMetricDataResponse' smart constructor. data GetRelationalDatabaseMetricDataResponse = GetRelationalDatabaseMetricDataResponse' { -- | An array of objects that describe the metric data returned. metricData :: Prelude.Maybe [MetricDatapoint], -- | The name of the metric returned. metricName :: Prelude.Maybe RelationalDatabaseMetricName, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'GetRelationalDatabaseMetricDataResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'metricData', 'getRelationalDatabaseMetricDataResponse_metricData' - An array of objects that describe the metric data returned. -- -- 'metricName', 'getRelationalDatabaseMetricDataResponse_metricName' - The name of the metric returned. -- -- 'httpStatus', 'getRelationalDatabaseMetricDataResponse_httpStatus' - The response's http status code. newGetRelationalDatabaseMetricDataResponse :: -- | 'httpStatus' Prelude.Int -> GetRelationalDatabaseMetricDataResponse newGetRelationalDatabaseMetricDataResponse pHttpStatus_ = GetRelationalDatabaseMetricDataResponse' { metricData = Prelude.Nothing, metricName = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | An array of objects that describe the metric data returned. getRelationalDatabaseMetricDataResponse_metricData :: Lens.Lens' GetRelationalDatabaseMetricDataResponse (Prelude.Maybe [MetricDatapoint]) getRelationalDatabaseMetricDataResponse_metricData = Lens.lens (\GetRelationalDatabaseMetricDataResponse' {metricData} -> metricData) (\s@GetRelationalDatabaseMetricDataResponse' {} a -> s {metricData = a} :: GetRelationalDatabaseMetricDataResponse) Prelude.. Lens.mapping Lens.coerced -- | The name of the metric returned. getRelationalDatabaseMetricDataResponse_metricName :: Lens.Lens' GetRelationalDatabaseMetricDataResponse (Prelude.Maybe RelationalDatabaseMetricName) getRelationalDatabaseMetricDataResponse_metricName = Lens.lens (\GetRelationalDatabaseMetricDataResponse' {metricName} -> metricName) (\s@GetRelationalDatabaseMetricDataResponse' {} a -> s {metricName = a} :: GetRelationalDatabaseMetricDataResponse) -- | The response's http status code. getRelationalDatabaseMetricDataResponse_httpStatus :: Lens.Lens' GetRelationalDatabaseMetricDataResponse Prelude.Int getRelationalDatabaseMetricDataResponse_httpStatus = Lens.lens (\GetRelationalDatabaseMetricDataResponse' {httpStatus} -> httpStatus) (\s@GetRelationalDatabaseMetricDataResponse' {} a -> s {httpStatus = a} :: GetRelationalDatabaseMetricDataResponse) instance Prelude.NFData GetRelationalDatabaseMetricDataResponse where rnf GetRelationalDatabaseMetricDataResponse' {..} = Prelude.rnf metricData `Prelude.seq` Prelude.rnf metricName `Prelude.seq` Prelude.rnf httpStatus