Skip to content

Commit 079941f

Browse files
authored
Update examples (awslabs#103)
1 parent f44aaf2 commit 079941f

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Generate CloudWatch Metrics embedded within structured log events. The embedded
1818

1919
- Easily generate custom metrics from Lambda functions without requiring custom batching code, making blocking network requests or relying on 3rd party software.
2020
- 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).
21+
- Examples can be found in [examples/README.md](examples/README.md)
2122

2223
- **Linking metrics to high cardinality context**
2324

examples/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Examples
2+
3+
## Docker
4+
5+
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.
6+
7+
[Official Docker documentation for `awslogs` driver](https://docs.docker.com/config/containers/logging/awslogs/)
8+
9+
## ECS and Fargate
10+
11+
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.
12+
13+
[ECS documentation on `awslogs` log driver](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html)
14+
15+
## Fluent Bit and Fluentd
16+
17+
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.
18+
19+
[Getting Started with Fluent Bit](https://docs.fluentbit.io/manual/installation/getting-started-with-fluent-bit)
20+
21+
[Amazon CloudWatch output plugin for Fluent Bit](https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch)
22+
23+
### Example Metrics
24+
25+
```json
26+
{
27+
"_aws": {
28+
"Timestamp": 1583902595342,
29+
"CloudWatchMetrics": [
30+
{
31+
"Dimensions": [[ "ServiceName", "ServiceType" ]],
32+
"Metrics": [{ "Name": "ProcessingTime", "Unit": "Milliseconds" }],
33+
"Namespace": "aws-embedded-metrics"
34+
}
35+
]
36+
},
37+
"ServiceName": "example",
38+
"ServiceType": "AWS::ECS::Container",
39+
"Method": "GET",
40+
"Url": "/test",
41+
"containerId": "702e4bcf1345",
42+
"createdAt": "2020-03-11T04:54:24.981207801Z",
43+
"startedAt": "2020-03-11T04:54:25.594413051Z",
44+
"image": "<account-id>.dkr.ecr.<region>.amazonaws.com/emf-examples:latest",
45+
"cluster": "emf-example",
46+
"taskArn": "arn:aws:ecs:<region>:<account-id>:task/2fe946f6-8a2e-41a4-8fec-c4983bad8f74",
47+
"ProcessingTime": 5
48+
}
49+
```

0 commit comments

Comments
 (0)