Skip to content

Commit c6a936b

Browse files
committed
update docs
1 parent 8b1721e commit c6a936b

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ AWS.Lambda.Powertools.sln.DotSettings.user
1818
[Oo]bj/**
1919
[Bb]in/**
2020
.DS_Store
21+
dist/
22+
site/

docs/core/metrics.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@ These metrics can be visualized through [Amazon CloudWatch Console](https://aws.
1010
## Key features
1111

1212
* Aggregate up to 100 metrics using a single CloudWatch EMF object (large JSON blob)
13-
* Validate against common metric definitions mistakes (metric unit, values, max dimensions, max metrics, etc)
14-
* Metrics are created asynchronously by CloudWatch service, no custom stacks needed
13+
* Validating your metrics against common metric definitions mistakes (for example, metric unit, values, max dimensions, max metrics)
14+
* Metrics are created asynchronously by the CloudWatch service. You do not need any custom stacks, and there is no impact to Lambda function latency
1515
* Context manager to create a one off metric with a different dimension
1616

17+
<br />
18+
19+
<figure>
20+
<img src="../../media/metrics_utility_showcase.png" loading="lazy" alt="Screenshot of the Amazon CloudWatch Console showing an example of business metrics in the Metrics Explorer" />
21+
<figcaption>Metrics showcase - Metrics Explorer</figcaption>
22+
</figure>
23+
1724
## Terminologies
1825

1926
If you're new to Amazon CloudWatch, there are two terminologies you must be aware of before using this utility:
2027

21-
* **Namespace**. It's the highest level container that will group multiple metrics from multiple services for a given application, for example `MyCompanyEcommerce`.
28+
* **Namespace**. It's the highest level container that will group multiple metrics from multiple services for a given application, for example `ServerlessEcommerce`.
2229
* **Dimensions**. Metrics metadata in key-value format. They help you slice and dice metrics visualization, for example `ColdStart` metric by Payment `service`.
30+
* **Metric**. It's the name of the metric, for example: SuccessfulBooking or UpdatedBooking.
31+
* **Unit**. It's a value representing the unit of measure for the corresponding metric, for example: Count or Seconds.
32+
* **Resolution**. It's a value representing the storage resolution for the corresponding metric. Metrics can be either Standard or High resolution. Read more [here](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Resolution_definition).
2333

2434
Visit the AWS documentation for a complete explanation for [Amazon CloudWatch concepts](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html).
2535

@@ -130,6 +140,38 @@ You can create metrics using **`AddMetric`**, and you can create dimensions for
130140
!!! warning "Do not create metrics or dimensions outside the handler"
131141
Metrics or dimensions added in the global scope will only be added during cold start. Disregard if that's the intended behavior.
132142

143+
### Adding high-resolution metrics
144+
145+
You can create [high-resolution metrics](https://aws.amazon.com/about-aws/whats-new/2023/02/amazon-cloudwatch-high-resolution-metric-extraction-structured-logs/) passing `MetricResolution` as parameter to `AddMetric`.
146+
147+
!!! tip "When is it useful?"
148+
High-resolution metrics are data with a granularity of one second and are very useful in several situations such as telemetry, time series, real-time incident management, and others.
149+
150+
=== "Metrics with high resolution"
151+
152+
```csharp hl_lines="9 12 15"
153+
using AWS.Lambda.Powertools.Metrics;
154+
155+
public class Function {
156+
157+
[Metrics(Namespace = "ExampleApplication", Service = "Booking")]
158+
public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
159+
{
160+
// Publish a metric with standard resolution i.e. StorageResolution = 60
161+
Metrics.AddMetric("SuccessfulBooking", 1, MetricUnit.Count, MetricResolution.Standard);
162+
163+
// Publish a metric with high resolution i.e. StorageResolution = 1
164+
Metrics.AddMetric("FailedBooking", 1, MetricUnit.Count, MetricResolution.High);
165+
166+
// The last parameter (storage resolution) is optional
167+
Metrics.AddMetric("SuccessfulUpgrade", 1, MetricUnit.Count);
168+
}
169+
}
170+
```
171+
172+
!!! tip "Autocomplete Metric Resolutions"
173+
Use the `MetricResolution` enum to easily find a supported metric resolution by CloudWatch.
174+
133175
### Adding default dimensions
134176

135177
You can use **`SetDefaultDimensions`** method to persist dimensions across Lambda invocations.
165 KB
Loading

mkdocs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ theme:
4242
- navigation.indexes
4343
- navigation.tracking
4444
- content.code.annotate
45+
- toc.follow
46+
- toc.integrate
47+
- announce.dismiss
4548
icon:
4649
repo: fontawesome/brands/github
4750
logo: media/aws-logo-light.svg
@@ -67,7 +70,7 @@ markdown_extensions:
6770
- pymdownx.inlinehilite
6871
- pymdownx.superfences
6972

70-
copyright: Copyright &copy; 2022 Amazon Web Services
73+
copyright: Copyright &copy; 2023 Amazon Web Services
7174

7275
plugins:
7376
- git-revision-date

0 commit comments

Comments
 (0)