Skip to content
v2.275.0

Stats Class ​

Factory functions for standard statistics strings.

Example ​

ts
declare const dashboard: cloudwatch.Dashboard;
declare const executionCountMetric: cloudwatch.Metric;
declare const errorCountMetric: cloudwatch.Metric;

dashboard.addWidgets(new cloudwatch.GraphWidget({
  title: "Executions vs error rate",

  left: [executionCountMetric],

  right: [errorCountMetric.with({
    statistic: cloudwatch.Stats.AVERAGE,
    label: "Error rate",
    color: cloudwatch.Color.GREEN,
  })]
}));

Initializer ​

ts
new Stats()
python
Stats()
java
new Stats()
csharp
new Stats()
go
NewStats()

Properties ​

AVERAGEstringaveragestrAVERAGEStringAVERAGEstringAVERAGE*stringstatic#
The value of Sum / SampleCount during the specified period.
IQMstringiqmstrIQMStringIQMstringIQM*stringstatic#
Interquartile mean (IQM) is the trimmed mean of the interquartile range, or the middle 50% of values.

It is equivalent to trimmedMean(25, 75).

MAXIMUMstringmaximumstrMAXIMUMStringMAXIMUMstringMAXIMUM*stringstatic#
The highest value observed during the specified period.

You can use this value to determine high volumes of activity for your application.

MINIMUMstringminimumstrMINIMUMStringMINIMUMstringMINIMUM*stringstatic#
The lowest value observed during the specified period.

You can use this value to determine low volumes of activity for your application.

SAMPLE_COUNTstringsample_countstrSAMPLE_COUNTStringSAMPLE_COUNTstringSAMPLE_COUNT*stringstatic#
The count (number) of data points used for the statistical calculation.
SUMstringsumstrSUMStringSUMstringSUM*stringstatic#
All values submitted for the matching metric added together.

This statistic can be useful for determining the total volume of a metric.

Methods ​

p(percentile: number): string@staticmethod def p(percentile: int | float) -> strpublic static String p(Number percentile)public static string P(double percentile)func P(Percentile *float64) *stringstatic#
A shorter alias for `percentile()`.
percentile(percentile: number): string@staticmethod def percentile(percentile: int | float) -> strpublic static String percentile(Number percentile)public static string Percentile(double percentile)func Percentile(Percentile *float64) *stringstatic#
Percentile indicates the relative standing of a value in a dataset.
notes

Percentiles help you get a better understanding of the distribution of your metric data.

For example, p(90) is the 90th percentile and means that 90% of the data within the period is lower than this value and 10% of the data is higher than this value.

percentileRank(v1: number, v2?: number): string@staticmethod def percentile_rank(v1: int | float, v2: typing.Optional[int | float] = None) -> strpublic static String percentileRank(Number v1, Number v2)public static string PercentileRank(double v1, double? v2 = null)func PercentileRank(V1 *float64, V2 *float64) *stringstatic#
Percentile rank (PR) is the percentage of values that meet a fixed threshold.
notes
  • If two numbers are given, they define the lower and upper bounds in absolute values, respectively.
  • If one number is given, it defines the upper bound (the lower bound is assumed to be 0).

For example, percentileRank(300) returns the percentage of data points that have a value of 300 or less. percentileRank(100, 2000) returns the percentage of data points that have a value between 100 and 2000.

pr(v1: number, v2?: number): string@staticmethod def pr(v1: int | float, v2: typing.Optional[int | float] = None) -> strpublic static String pr(Number v1, Number v2)public static string Pr(double v1, double? v2 = null)func Pr(V1 *float64, V2 *float64) *stringstatic#
Shorter alias for `percentileRank()`.
tc(p1: number, p2?: number): string@staticmethod def tc(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String tc(Number p1, Number p2)public static string Tc(double p1, double? p2 = null)func Tc(P1 *float64, P2 *float64) *stringstatic#
Shorter alias for `trimmedCount()`.
tm(p1: number, p2?: number): string@staticmethod def tm(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String tm(Number p1, Number p2)public static string Tm(double p1, double? p2 = null)func Tm(P1 *float64, P2 *float64) *stringstatic#
A shorter alias for `trimmedMean()`.
trimmedCount(p1: number, p2?: number): string@staticmethod def trimmed_count(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String trimmedCount(Number p1, Number p2)public static string TrimmedCount(double p1, double? p2 = null)func TrimmedCount(P1 *float64, P2 *float64) *stringstatic#
Trimmed count (TC) is the number of data points in the chosen range for a trimmed mean statistic.
notes
  • If two numbers are given, they define the lower and upper bounds in percentages, respectively.
  • If one number is given, it defines the upper bound (the lower bound is assumed to be 0).

For example, tc(90) returns the number of data points not including any data points that fall in the highest 10% of the values. tc(10, 90) returns the number of data points not including any data points that fall in the lowest 10% of the values and the highest 90% of the values.

trimmedMean(p1: number, p2?: number): string@staticmethod def trimmed_mean(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String trimmedMean(Number p1, Number p2)public static string TrimmedMean(double p1, double? p2 = null)func TrimmedMean(P1 *float64, P2 *float64) *stringstatic#
Trimmed mean (TM) is the mean of all values that are between two specified boundaries.
notes

Values outside of the boundaries are ignored when the mean is calculated. You define the boundaries as one or two numbers between 0 and 100, up to 10 decimal places. The numbers are percentages.

  • If two numbers are given, they define the lower and upper bounds in percentages, respectively.
  • If one number is given, it defines the upper bound (the lower bound is assumed to be 0).

For example, tm(90) calculates the average after removing the 10% of data points with the highest values; tm(10, 90) calculates the average after removing the 10% with the lowest and 10% with the highest values.

trimmedSum(p1: number, p2?: number): string@staticmethod def trimmed_sum(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String trimmedSum(Number p1, Number p2)public static string TrimmedSum(double p1, double? p2 = null)func TrimmedSum(P1 *float64, P2 *float64) *stringstatic#
Trimmed sum (TS) is the sum of the values of data points in a chosen range for a trimmed mean statistic.
notes

It is equivalent to (Trimmed Mean) * (Trimmed count).

  • If two numbers are given, they define the lower and upper bounds in percentages, respectively.
  • If one number is given, it defines the upper bound (the lower bound is assumed to be 0).

For example, ts(90) returns the sum of the data points not including any data points that fall in the highest 10% of the values. ts(10, 90) returns the sum of the data points not including any data points that fall in the lowest 10% of the values and the highest 90% of the values.

ts(p1: number, p2?: number): string@staticmethod def ts(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String ts(Number p1, Number p2)public static string Ts(double p1, double? p2 = null)func Ts(P1 *float64, P2 *float64) *stringstatic#
Shorter alias for `trimmedSum()`.
winsorizedMean(p1: number, p2?: number): string@staticmethod def winsorized_mean(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String winsorizedMean(Number p1, Number p2)public static string WinsorizedMean(double p1, double? p2 = null)func WinsorizedMean(P1 *float64, P2 *float64) *stringstatic#
Winsorized mean (WM) is similar to trimmed mean.
notes

However, with winsorized mean, the values that are outside the boundary are not ignored, but instead are considered to be equal to the value at the edge of the appropriate boundary. After this normalization, the average is calculated. You define the boundaries as one or two numbers between 0 and 100, up to 10 decimal places.

  • If two numbers are given, they define the lower and upper bounds in percentages, respectively.
  • If one number is given, it defines the upper bound (the lower bound is assumed to be 0).

For example, tm(90) calculates the average after removing the 10% of data points with the highest values; tm(10, 90) calculates the average after removing the 10% with the lowest and 10% with the highest values.

For example, wm(90) calculates the average while treating the 10% of the highest values to be equal to the value at the 90th percentile. wm(10, 90) calculates the average while treaing the bottom 10% and the top 10% of values to be equal to the boundary values.

wm(p1: number, p2?: number): string@staticmethod def wm(p1: int | float, p2: typing.Optional[int | float] = None) -> strpublic static String wm(Number p1, Number p2)public static string Wm(double p1, double? p2 = null)func Wm(P1 *float64, P2 *float64) *stringstatic#
A shorter alias for `winsorizedMean()`.