From 6feeeab7d6b1a72ac1d266ddf87ccf7ac9f04e3e Mon Sep 17 00:00:00 2001 From: Gordon Pham-Nguyen Date: Thu, 25 May 2023 22:20:53 -0400 Subject: [PATCH 1/2] Update examples --- README.md | 1 + examples/README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 examples/README.md diff --git a/README.md b/README.md index 3e3e5ee..199161f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Generate CloudWatch Metrics embedded within structured log events. The embedded - Easily generate custom metrics from Lambda functions without requiring custom batching code, making blocking network requests or relying on 3rd party software. - Other compute environments (EC2, On-prem, ECS, EKS, and other container environments) are supported by installing the [CloudWatch Agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Generation_CloudWatch_Agent.html). + - Examples can be found in [examples/README.md](examples/README.md) - **Linking metrics to high cardinality context** diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..51acbca --- /dev/null +++ b/examples/README.md @@ -0,0 +1,59 @@ +# Examples + +## Lambda + +You can deploy the Lambda example by running: + +```sh +export AWS_REGION=us-west-2 +export LAMBDA_ARN="arn:aws:lambda:$AWS_REGION::function:" +./examples/lambda/deploy/deploy-lambda.sh $LAMBDA_ARN $AWS_REGION +``` + +## Docker + +With Docker images, using the `awslogs` log driver will send your container logs to CloudWatch Logs. All you have to do is write to STDOUT and your EMF logs will be processed. + +[Official Docker documentation for `awslogs` driver](https://docs.docker.com/config/containers/logging/awslogs/) + +## ECS and Fargate + +With ECS and Fargate, you can use the `awslogs` log driver to have your logs sent to CloudWatch Logs on your behalf. After configuring your task to use the `awslogs` log driver, you may write your EMF logs to STDOUT and they will be processed. + +[ECS documentation on `awslogs` log driver](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html) + +## Fluent Bit and Fluentd + +Fluent Bit can be used to collect logs and push them to CloudWatch Logs. After configuring the Amazon CloudWatch Logs output plugin, you may write your EMF logs to STDOUT and they will be processed. + +[Getting Started with Fluent Bit](https://docs.fluentbit.io/manual/installation/getting-started-with-fluent-bit) + +[Amazon CloudWatch output plugin for Fluent Bit](https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch) + +### Example Metrics + +```json +{ + "_aws": { + "Timestamp": 1583902595342, + "CloudWatchMetrics": [ + { + "Dimensions": [[ "ServiceName", "ServiceType" ]], + "Metrics": [{ "Name": "ProcessingTime", "Unit": "Milliseconds" }], + "Namespace": "aws-embedded-metrics" + } + ] + }, + "ServiceName": "example", + "ServiceType": "AWS::ECS::Container", + "Method": "GET", + "Url": "/test", + "containerId": "702e4bcf1345", + "createdAt": "2020-03-11T04:54:24.981207801Z", + "startedAt": "2020-03-11T04:54:25.594413051Z", + "image": ".dkr.ecr..amazonaws.com/emf-examples:latest", + "cluster": "emf-example", + "taskArn": "arn:aws:ecs:::task/2fe946f6-8a2e-41a4-8fec-c4983bad8f74", + "ProcessingTime": 5 +} +``` From fbe7e2c5f2530ec875356af601578eb812e523dc Mon Sep 17 00:00:00 2001 From: Gordon Pham-Nguyen Date: Fri, 26 May 2023 15:55:20 -0400 Subject: [PATCH 2/2] Remove Lambda header example because it's already available in the subdirectory --- examples/README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/examples/README.md b/examples/README.md index 51acbca..493bf86 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,15 +1,5 @@ # Examples -## Lambda - -You can deploy the Lambda example by running: - -```sh -export AWS_REGION=us-west-2 -export LAMBDA_ARN="arn:aws:lambda:$AWS_REGION::function:" -./examples/lambda/deploy/deploy-lambda.sh $LAMBDA_ARN $AWS_REGION -``` - ## Docker With Docker images, using the `awslogs` log driver will send your container logs to CloudWatch Logs. All you have to do is write to STDOUT and your EMF logs will be processed.