Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 031fb20

Browse files
committed
ECS and Docker instructions
1 parent 4904cec commit 031fb20

22 files changed

+296
-86
lines changed

doc-source/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Amazon's trademarks and trade dress may not be used in
3535
+ [Instrumenting Outgoing HTTP Calls](scorekeep-httpclient.md)
3636
+ [Instrumenting Calls to a PostgreSQL Database](scorekeep-postgresql.md)
3737
+ [Instrumenting AWS Lambda Functions](scorekeep-lambda.md)
38+
+ [Instrumenting Amazon ECS Applications](scorekeep-ecs.md)
3839
+ [Instrumenting Startup Code](scorekeep-startup.md)
3940
+ [Instrumenting Scripts](scorekeep-scripts.md)
4041
+ [Instrumenting a Web App Client](scorekeep-client.md)

doc-source/scorekeep-ecs.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Instrumenting Amazon ECS Applications<a name="scorekeep-ecs"></a>
2+
3+
In the [https://github.com/awslabs/eb-java-scorekeep/tree/xray-ecs](https://github.com/awslabs/eb-java-scorekeep/tree/xray-ecs) branch, the Scorekeep sample application shows how to instrument an application running in Amazon Elastic Container Service \(Amazon ECS\)\. The branch provides scripts and configuration files for creating, uploading, and running Docker images in a Multicontainer Docker environment in AWS Elastic Beanstalk\.
4+
5+
The project includes three Dockerfiles that define container images for the API, front end, and X\-Ray daemon components\.
6+
7+
+ `/Dockerfile` – The Scorekeep API\.
8+
9+
+ `/scorekeep-frontend/Dockerfile` – The Angular web app client, and the nginx proxy that routes incoming traffic\.
10+
11+
+ `/xray-daemon/Dockerfile` – The X\-Ray daemon\.
12+
13+
The X\-Ray daemon Dockerfile creates an image based on Amazon Linux that runs the X\-Ray daemon\.
14+
15+
**Example Dockerfile – Amazon Linux**
16+
17+
```
18+
FROM amazonlinux
19+
RUN yum install -y unzip
20+
RUN curl -o daemon.zip https://s3.dualstack.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-linux-2.x.zip
21+
RUN unzip daemon.zip && cp xray /usr/bin/xray
22+
ENTRYPOINT ["/usr/bin/xray", "-b", "0.0.0.0:2000"]
23+
EXPOSE 2000/udp
24+
```
25+
26+
The makefile in the same directory defines commands for building the image, uploading it to Amazon ECR, and [running it locally](xray-daemon-local.md#xray-daemon-local-docker)\.
27+
28+
To run the containers on Amazon ECS, the branch includes a script to generate a `Dockerrun.aws.json` file, which you can deploy to a multicontainer Docker environment in Elastic Beanstalk\. The [template](https://github.com/awslabs/eb-java-scorekeep/tree/xray-ecs/task-definition/template/scorekeep-dockerrun.template) that the script uses shows how to write a task definition that configures [networking between the containers in Amazon ECS](xray-daemon-ecs.md)\.
29+
30+
**Note**
31+
`Dockerrun.aws.json` is the Elastic Beanstalk version of an Amazon ECS task definition file\. If you don't want to use Elastic Beanstalk to create your Amazon ECS cluster, you can modify the `Dockerrun.aws.json` file to run on Amazon ECS directly by removing the `AWSEBDockerrunVersion` key from the file\.
32+
33+
See the [branch README](https://github.com/awslabs/eb-java-scorekeep/tree/xray-ecs) for instructions on how to deploy Scorekeep to Amazon ECS\.

doc-source/scorekeep-scripts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ You can also instrument code that isn't part of your application\. When the X\-R
88
SEGMENT=$(python bin/xray_start.py)
99
gradle build --quiet --stacktrace &> /var/log/gradle.log; GRADLE_RETURN=$?
1010
if (( GRADLE_RETURN != 0 )); then
11-
echo "Grade failed with exit status $GRADLE_RETURN" >&2
11+
echo "Gradle failed with exit status $GRADLE_RETURN" >&2
1212
python bin/xray_error.py "$SEGMENT" "$(cat /var/log/gradle.log)"
1313
exit 1
1414
fi

doc-source/xray-api-sendingdata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ $ cat segment.txt > /dev/udp/127.0.0.1/2000
166166
{"trace_id": "1-594aed87-ad72e26896b3f9d3a27054bb", "id": "6226467e3f845502", "start_time": 1498082657.37518, "end_time": 1498082695.4042, "name": "test.elasticbeanstalk.com"}
167167
```
168168

169-
Check the daemon log to verify that it sent the segment to X\-Ray\.
169+
Check the [daemon log](xray-daemon.md#xray-daemon-logging) to verify that it sent the segment to X\-Ray\.
170170

171171
```
172172
2017-07-07T01:57:24Z [Debug] processor: sending partial batch

doc-source/xray-console-deeplinks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ https://console.aws.amazon.com/xray/home#/service-map?timeRange=PT1H
6363
**Example Time range accurate to seconds**
6464

6565
```
66-
https://console.aws.amazon.com/xray/home#/traces?timeRange=2018-2-01T16:00:00~2018-2-01T22:00:00
66+
https://console.aws.amazon.com/xray/home#/traces?timeRange=2018-3-01T16:00:00~2018-3-01T22:00:00
6767
```
6868

6969
**Example Time range accurate to minutes**
7070

7171
```
72-
https://console.aws.amazon.com/xray/home#/traces?timeRange=2018-2-01T16:00~2018-2-01T22:00
72+
https://console.aws.amazon.com/xray/home#/traces?timeRange=2018-3-01T16:00~2018-3-01T22:00
7373
```
7474

7575
## Region<a name="xray-console-deeplinks-region"></a>

doc-source/xray-console-filters.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ Complex keywords let you find requests based on service name, edge name, or anno
184184

185185
+ `edge(name) {filter}` – Connection between services *source* and *destination*\. Optional curly braces can contain a filter expression that applies to segments on this connection\.
186186

187-
+ `annotation.key` – Value of annotation with field *key*\. The value of an annotation can be a boolean, number, or string, so you can use any of those type's comparison operators\.
187+
+ `annotation.key` – Value of annotation with field *key*\. The value of an annotation can be a boolean, number, or string, so you can use any of those type's comparison operators\. You cannot use this keyword in combination with the `service` or `edge` keywords\.
188188

189189
Use the service keyword to find traces for requests that hit a certain node on your service map\.
190190

191191
**Example Service filter**
192-
Requests that included a call to "api\.example\.com" with a fault \(500 series error\)\.
192+
Requests that included a call to `api.example.com` with a fault \(500 series error\)\.
193193

194194
```
195195
service("api.example.com") { fault }
@@ -207,7 +207,7 @@ service() { fault }
207207
The edge keyword applies a filter expression to a connection between two nodes\.
208208

209209
**Example Edge filter**
210-
Request where the service "api\.example\.com" made a call to "backend\.example\.com" that failed with an error\.
210+
Request where the service `api.example.com` made a call to `backend.example.com` that failed with an error\.
211211

212212
```
213213
edge("api.example.com", "backend.example.com") { error }
@@ -216,7 +216,7 @@ edge("api.example.com", "backend.example.com") { error }
216216
You can also use the `!` operator with service and edge keywords to exclude a service or edge from the results of another filter expression\.
217217

218218
**Example Service and request filter**
219-
Request where the URL begins with "http://api\.example\.com/" and contains "/v2/" but does not reach a service named "api\.example\.com"\.
219+
Request where the URL begins with `http://api.example.com/` and contains `/v2/` but does not reach a service named `api.example.com`\.
220220

221221
```
222222
http.url BEGINSWITH "http://api.example.com/" AND http.url CONTAINS "/v2/" AND !service("api.example.com")
@@ -225,28 +225,28 @@ http.url BEGINSWITH "http://api.example.com/" AND http.url CONTAINS "/v2/" AND !
225225
For annotations, use the comparison operators that correspond to the type of value\.
226226

227227
**Example Annotation with string value**
228-
Requests that caused a fault anywhere on your service map\.
228+
Requests with an annotation named `gameid` with string value `"817DL6VO"`\.
229229

230230
```
231231
annotation.gameid = "817DL6VO"
232232
```
233233

234234
**Example Annotation with number value**
235-
Requests that caused a fault anywhere on your service map\.
235+
Requests with annotation age with numerical value greater than 29\.
236236

237237
```
238238
annotation.age > 29
239239
```
240240

241241
## The ID Function<a name="console-filters-functions"></a>
242242

243-
When you provide a service name to the service\(\) or edge\(\) keywords, you get results for all nodes that have that name\. For more precise filtering, you can use the id\(\) function to specify a service type in addition to a name to distinguish between nodes with the same name\.
243+
When you provide a service name to the `service` or `edge` keywords, you get results for all nodes that have that name\. For more precise filtering, you can use the `id` function to specify a service type in addition to a name to distinguish between nodes with the same name\.
244244

245245
```
246246
id(name: "service-name", type:"service::type")
247247
```
248248

249-
You can use the id\(\) function in place of a service name in service and edge filters\.
249+
You can use the `id` function in place of a service name in service and edge filters\.
250250

251251
```
252252
service(id(name: "service-name", type:"service::type")) { filter }
@@ -263,16 +263,16 @@ For example, the [Scorekeep sample application](xray-scorekeep.md) includes an A
263263
The two nodes have the same name but different types\. A standard service filter will find traces for both\.
264264

265265
**Example Service filter**
266-
Requests that include an error on any service named "random\-name"\.
266+
Requests that include an error on any service named `random-name`\.
267267

268268
```
269269
service("random-name") { error }
270270
```
271271

272-
Use the id\(\) function to narrow the search down to errors on the function itself, excluding errors from the service\.
272+
Use the `id` function to narrow the search down to errors on the function itself, excluding errors from the service\.
273273

274-
**Example Service filter with id\(\) function**
275-
Requests that include an error on a service named "random\-name" with type "AWS::Lambda::Function"\.
274+
**Example Service filter with id function**
275+
Requests that include an error on a service named `random-name` with type `AWS::Lambda::Function`\.
276276

277277
```
278278
service(id(name: "random-name", type: "AWS::Lambda::Function")) { error }
@@ -281,7 +281,7 @@ service(id(name: "random-name", type: "AWS::Lambda::Function")) { error }
281281
You can also exclude the name entirely, to search for nodes by type\.
282282

283283
**Example Service filter with id\(\) function**
284-
Requests that include an error on a service with type "AWS::Lambda::Function"\.
284+
Requests that include an error on a service with type `AWS::Lambda::Function`\.
285285

286286
```
287287
service(id(type: "AWS::Lambda::Function")) { error }

doc-source/xray-daemon-beanstalk.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
# Running the X\-Ray Daemon on AWS Elastic Beanstalk<a name="xray-daemon-beanstalk"></a>
22

3-
You can run the X\-Ray daemon on your Elastic Beanstalk environment's EC2 instances to relay trace data from your application to AWS X\-Ray\.
3+
To relay trace data from your application to AWS X\-Ray, you can run the X\-Ray daemon on your Elastic Beanstalk environment's Amazon EC2 instances\. For a list of supported platforms, see [Configuring AWS X\-Ray Debugging](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-debugging.html) in the *AWS Elastic Beanstalk Developer Guide*\.
44

55
**Note**
6-
For a list of supported platforms, see [Configuring AWS X\-Ray Debugging](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-debugging.html) in the AWS Elastic Beanstalk Developer Guide\.
7-
86
The daemon uses your environment's instance profile for permissions\. For instructions about adding permissions to the Elastic Beanstalk instance profile, see [Giving the Daemon Permission to Send Data to X\-Ray](xray-daemon.md#xray-daemon-permissions)\.
97

10-
AWS Elastic Beanstalk platforms provide a configuration option that you can set to run the daemon automatically\. You can enable the daemon in a configuration file in your source code or by checking an option in the Elastic Beanstalk console\.
8+
Elastic Beanstalk platforms provide a configuration option that you can set to run the daemon automatically\. You can enable the daemon in a configuration file in your source code or by choosing an option in the Elastic Beanstalk console\. When you enable the configuration option, the daemon is installed on the instance and runs as a service\.
119

12-
The daemon is installed on the instance and runs as a service when you enable the configuration option\.
10+
The version included on Elastic Beanstalk platforms might not be the latest version\. See the [Supported Platforms topic](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html) to find out the version of the daemon that is available for your platform configuration\.
1311

14-
The version included on Elastic Beanstalk platforms may not be the latest version\. See the Elastic Beanstalk release notes to find out the version of the daemon that is available for the platform configuration that you use\.
12+
Elastic Beanstalk does not provide the X\-Ray daemon on the Multicontainer Docker \(Amazon ECS\) platform\. The Scorekeep sample application shows how to use the X\-Ray daemon on Amazon ECS with Elastic Beanstalk\. See [Instrumenting Amazon ECS Applications](scorekeep-ecs.md) for details\.
1513

16-
## Using Elastic Beanstalk's X\-Ray Integration to Run the X\-Ray Daemon<a name="xray-daemon-beanstalk-option"></a>
14+
## Using the Elastic Beanstalk X\-Ray Integration to Run the X\-Ray Daemon<a name="xray-daemon-beanstalk-option"></a>
1715

1816
Use the console to turn on X\-Ray integration, or configure it in your application source code with a configuration file\.
1917

@@ -47,7 +45,7 @@ Elastic Beanstalk passes a configuration file to the daemon and outputs logs to
4745

4846
+ **Configuration file**`C:\Progam Files\Amazon\XRay\cfg.yaml`
4947

50-
+ **Logs**`c:\Progam Files\Amazon\XRay\logs\xray-service.log`
48+
+ **Logs**`c:\Program Files\Amazon\XRay\logs\xray-service.log`
5149

5250
**On Linux Platforms**
5351

@@ -164,4 +162,4 @@ files:
164162
C:\Program Files\Amazon\XRay\xray-daemon.log
165163
```
166164

167-
These examples also adds the daemon's log file to Elastic Beanstalk's tail logs task, to include it when you request logs with the console or Elastic Beanstalk Command Line Interface \(EB CLI\)\.
165+
These examples also add the daemon's log file to the Elastic Beanstalk tail logs task, so that it's included when you request logs with the console or Elastic Beanstalk Command Line Interface \(EB CLI\)\.

doc-source/xray-daemon-configuration.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# Configuring the AWS X\-Ray Daemon<a name="xray-daemon-configuration"></a>
22

3-
You can use command line options or a configuration file to customize the X\-Ray daemon's behavior\.
3+
You can use command line options or a configuration file to customize the X\-Ray daemon's behavior\. Most options are available using both methods, but some are only available in configuration files and some only at the command line\.
4+
5+
To get started, the only option that you need to know is `-n` or `--region`, which you use to set the region that the daemon uses to send trace data to X\-Ray\.
6+
7+
```
8+
~/xray-daemon$ ./xray -n us-east-2
9+
```
10+
11+
If you are running the daemon locally, that is, not on Amazon EC2, you can add the `-o` option to skip checking for instance profile credentials so the daemon will become ready more quickly\.
12+
13+
```
14+
~/xray-daemon$ ./xray -o -n us-east-2
15+
```
16+
17+
The rest of the command line options let you configure logging, listen on a different port, limit the amount of memory that the daemon can use, or assume a role to send trace data to a different account\.
18+
19+
You can pass a configuration file to the daemon to access advanced configuration options and do things like limit the number of concurrent calls to X\-Ray, disable log rotation, and send traffic to a proxy\.
420

521

622
+ [Using Command Line Options](#xray-daemon-configuration-commandline)
@@ -106,9 +122,8 @@ You can also use a YAML format file to configure the daemon\. Pass the configura
106122

107123
+ `Version` – Daemon configuration file format version\.
108124

109-
The following configuration file changes the daemon's listening port to 3000, turns off checks for instance metadata, sets a role to use for uploading segments, and changes region and logging options\.
110-
111125
**Example xray\-daemon\.yaml**
126+
This configuration file changes the daemon's listening port to 3000, turns off checks for instance metadata, sets a role to use for uploading segments, and changes region and logging options\.
112127

113128
```
114129
Socket:

0 commit comments

Comments
 (0)