VOOZH about

URL: https://www.nuget.org/packages/AWS.Lambda.Powertools.Metrics/

⇱ NuGet Gallery | AWS.Lambda.Powertools.Metrics 3.2.2




👁 Image
AWS.Lambda.Powertools.Metrics 3.2.2

Prefix Reserved
dotnet add package AWS.Lambda.Powertools.Metrics --version 3.2.2
 
 
NuGet\Install-Package AWS.Lambda.Powertools.Metrics -Version 3.2.2
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="3.2.2" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AWS.Lambda.Powertools.Metrics" Version="3.2.2" />
 
Directory.Packages.props
<PackageReference Include="AWS.Lambda.Powertools.Metrics" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AWS.Lambda.Powertools.Metrics --version 3.2.2
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AWS.Lambda.Powertools.Metrics, 3.2.2"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AWS.Lambda.Powertools.Metrics@3.2.2
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AWS.Lambda.Powertools.Metrics&version=3.2.2
 
Install as a Cake Addin
#tool nuget:?package=AWS.Lambda.Powertools.Metrics&version=3.2.2
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

AWS.Lambda.Powertools.Metrics

Metrics creates custom metrics asynchronously by logging metrics to standard output following Amazon CloudWatch Embedded Metric Format (EMF).

These metrics can be visualized through Amazon CloudWatch Console.

Key features

  • Aggregate up to 100 metrics using a single CloudWatch EMF object (large JSON blob)
  • Validate against common metric definitions mistakes (metric unit, values, max dimensions, max metrics, etc)
  • Metrics are created asynchronously by CloudWatch service, no custom stacks needed
  • Context manager to create a one off metric with a different dimension

Read the docs

For a full list of features go to docs.aws.amazon.com/powertools/dotnet/core/metrics/

GitHub: https://github.com/aws-powertools/powertools-lambda-dotnet/

Sample Function

View the full example here: https://github.com/aws-powertools/powertools-lambda-dotnet/tree/develop/examples/Metrics

public class Function
{
 /// <summary>
 /// Lambda Handler
 /// </summary>
 /// <param name="apigwProxyEvent">API Gateway Proxy event</param>
 /// <param name="context">AWS Lambda context</param>
 /// <returns>API Gateway Proxy response</returns>
 [Logging(LogEvent = true)]
 [Metrics(CaptureColdStart = true)]
 public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest apigwProxyEvent,
 ILambdaContext context)
 {
 var requestContextRequestId = apigwProxyEvent.RequestContext.RequestId;

 Logger.LogInformation("Getting ip address from external service");

 // Add Metric to capture the amount of time 
 Metrics.PushSingleMetric(
 metricName: "CallingIP",
 value: 1,
 unit: MetricUnit.Count,
 service: "lambda-powertools-metrics-example",
 defaultDimensions: new Dictionary<string, string>
 {
 { "Metric Type", "Single" }
 });
 
 var watch = Stopwatch.StartNew();
 var location = await GetCallingIp();
 watch.Stop();
 
 Metrics.AddMetric("ElapsedExecutionTime", watch.ElapsedMilliseconds, MetricUnit.Milliseconds);
 Metrics.AddMetric("SuccessfulLocations", 1, MetricUnit.Count);
 
 var lookupRecord = new LookupRecord(lookupId: requestContextRequestId,
 greeting: "Hello Powertools for AWS Lambda (.NET)", ipAddress: location);

 try
 {
 Metrics.PushSingleMetric(
 metricName: "RecordsSaved",
 value: 1,
 unit: MetricUnit.Count,
 service: "lambda-powertools-metrics-example",
 defaultDimensions: new Dictionary<string, string>
 {
 { "Metric Type", "Single" }
 });
 
 await SaveRecordInDynamo(lookupRecord);
 
 Metrics.AddMetric("SuccessfulWrites", 1, MetricUnit.Count);
 
 return new APIGatewayProxyResponse
 {
 Body = JsonSerializer.Serialize(lookupRecord),
 StatusCode = 200,
 Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
 };
 }
 catch (Exception e)
 {
 Logger.LogError(e.Message);
 
 return new APIGatewayProxyResponse
 {
 Body = e.Message,
 StatusCode = 500,
 Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
 };
 }
 }
}

Sample output

{
 "_aws": {
 "Timestamp": 1648181318790,
 "CloudWatchMetrics": [
 {
 "Namespace": "AWSLambdaPowertools",
 "Metrics": [
 {
 "Name": "CallingIP",
 "Unit": "Count"
 }
 ],
 "Dimensions": [
 [
 "Metric Type"
 ],
 [
 "Service"
 ]
 ]
 }
 ]
 },
 "Metric Type": "Single",
 "Service": "lambda-powertools-metrics-example",
 "CallingIP": 1
}
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AWS.Lambda.Powertools.Metrics:

Package Downloads
AWS.Lambda.Powertools.Metrics.AspNetCore

Powertools for AWS Lambda (.NET) - Metrics AspNetCore package.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on AWS.Lambda.Powertools.Metrics:

Repository Stars
aws/aws-lambda-dotnet
Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
aws-samples/serverless-dotnet-demo
Version Downloads Last Updated
3.2.2 4,603 5/25/2026
3.2.1 22,815 3/19/2026
3.2.0 2,102 3/12/2026
3.1.0 19,886 1/6/2026
3.0.2 30,048 11/5/2025
3.0.1 3,316 10/21/2025
3.0.1-alpha 245 10/15/2025
3.0.0 3,596 10/8/2025
2.2.0 5,999 9/25/2025
2.2.0-alpha3 250 9/22/2025
2.2.0-alpha2 303 9/22/2025
2.2.0-alpha 291 9/19/2025
2.1.1 49,690 7/29/2025
2.1.0 5,228 7/15/2025
2.0.0 99,291 3/7/2025
2.0.0-alpha1 26,821 10/21/2024
1.8.1-alpha 243 10/9/2024
1.7.0-alpha3 221 7/14/2024
1.7.0-alpha2 184 7/12/2024
Loading failed