Skip to content

Commit

Permalink
Merge pull request #17706 from brnhensley/patch-29
Browse files Browse the repository at this point in the history
chore: add syntax highlighting
  • Loading branch information
homelessbirds authored Jun 26, 2024
2 parents 4638e92 + a5065ac commit 7dcea5c
Show file tree
Hide file tree
Showing 39 changed files with 525 additions and 528 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ To install using CloudFormation:
>
1. Download the task definition example with the sidecar container to be deployed:

```
```sh
curl -O https://download.newrelic.com/infrastructure_agent/integrations/ecs/newrelic-infra-ecs-fargate-example-latest.json
```

Expand All @@ -89,28 +89,28 @@ One [install option](#install-overview) is using our install script. To use the

1. Download the ECS integration installer:

```
```sh
curl -O https://download.newrelic.com/infrastructure_agent/integrations/ecs/newrelic-infra-ecs-installer.sh
```
2. Add execute permissions to the installer:

```
```sh
chmod +x newrelic-infra-ecs-installer.sh
```
3. Execute it with `-h` to see the documentation and requirements:

```
```sh
./newrelic-infra-ecs-installer.sh -h
```
4. Check that your AWS profile points to the same region where your ECS cluster was created:

```
$ aws configure get region
us-east-1
$ aws ecs list-clusters
YOUR_CLUSTER_ARNS
arn:aws:ecs:us-east-1:YOUR_AWS_ACCOUNT:cluster/YOUR_CLUSTER
```sh
aws configure get region
[output] us-east-1
[output]
aws ecs list-clusters
[output] YOUR_CLUSTER_ARNS
[output] arn:aws:ecs:us-east-1:YOUR_AWS_ACCOUNT:cluster/YOUR_CLUSTER
```
5. Execute the installer, specifying your <InlinePopover type="licenseKey" /> and cluster name.

Expand All @@ -119,15 +119,15 @@ One [install option](#install-overview) is using our install script. To use the
id="auto-script-ec2"
title="EC2 launch type"
>
```
```sh
./newrelic-infra-ecs-installer.sh -c YOUR_CLUSTER_NAME -l YOUR_LICENSE_KEY
```
</Collapser>
<Collapser
id="auto-script-external"
title="External (ECS Anywhere) launch type"
>
```
```sh
./newrelic-infra-ecs-installer.sh -c YOUR_CLUSTER_NAME -l YOUR_LICENSE_KEY -e
```
</Collapser>
Expand All @@ -136,7 +136,7 @@ One [install option](#install-overview) is using our install script. To use the
title="AWS Fargate launch type"
>

```
```sh
./newrelic-infra-ecs-installer.sh -f -c YOUR_CLUSTER_NAME -l YOUR_LICENSE_KEY
```
</Collapser>
Expand All @@ -146,7 +146,7 @@ One [install option](#install-overview) is using our install script. To use the

* Download the task definition example with the sidecar container to be deployed:

```
```sh
curl -O https://download.newrelic.com/infrastructure_agent/integrations/ecs/newrelic-infra-ecs-fargate-example-latest.json
```

Expand All @@ -156,8 +156,8 @@ One [install option](#install-overview) is using our install script. To use the

Notice that the just created `NewRelicECSTaskExecutionRole` needs to be used as the task execution role.
Policies attached to the role (All launch types):
- NewRelicSSMLicenseKeyReadAccess which enables access to the SSM parameter with the license key.
- AmazonECSTaskExecutionRolePolicy
- `NewRelicSSMLicenseKeyReadAccess` which enables access to the SSM parameter with the license key.
- `AmazonECSTaskExecutionRolePolicy`

* Then, you can add the container you want to monitor as a sidecar.

Expand All @@ -170,17 +170,17 @@ One [install option](#install-overview) is to manually do the steps that are don
1. Check that your AWS profile points to the same region where your ECS cluster was created:
```
$ aws configure get region
us-east-1
$ aws ecs list-clusters
YOUR_CLUSTER_ARNS
arn:aws:ecs:us-east-1:YOUR_AWS_ACCOUNT:cluster/YOUR_CLUSTER
```sh
aws configure get region
[output] us-east-1
[output]
aws ecs list-clusters
[output] YOUR_CLUSTER_ARNS
[output] arn:aws:ecs:us-east-1:YOUR_AWS_ACCOUNT:cluster/YOUR_CLUSTER
```
2. Save your <InlinePopover type="licenseKey" /> as a Systems Manager (SSM) parameter:
```
```sh
aws ssm put-parameter \
--name "/newrelic-infra/ecs/license-key" \
--type SecureString \
Expand All @@ -189,26 +189,26 @@ One [install option](#install-overview) is to manually do the steps that are don
```
3. Create an IAM policy to access the license key parameter:
```
```sh
aws iam create-policy \
--policy-name "NewRelicSSMLicenseKeyReadAccess" \
--policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"ssm:GetParameters\"],\"Resource\":[\"ARN_OF_LICENSE_KEY_PARAMETER\"]}]}" \
--description "Provides read access to the New Relic SSM license key parameter"
--policy-name "NewRelicSSMLicenseKeyReadAccess" \
--policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"ssm:GetParameters\"],\"Resource\":[\"ARN_OF_LICENSE_KEY_PARAMETER\"]}]}" \
--description "Provides read access to the New Relic SSM license key parameter"
```
4. Create an IAM role to be used as the task execution role:
```
```sh
aws iam create-role \
--role-name "NewRelicECSTaskExecutionRole" \
--assume-role-policy-document '{"Version":"2008-10-17","Statement":[{"Sid":"","Effect":"Allow","Principal":{"Service":"ecs-tasks.amazonaws.com"},"Action":"sts:AssumeRole"}]}' \
--description "ECS task execution role for New Relic infrastructure"
```
5. Attach the policies `NewRelicSSMLicenseKeyReadAccess`, and `AmazonECSTaskExecutionRolePolicy` to the role:
```
```sh
aws iam attach-role-policy \
--role-name "NewRelicECSTaskExecutionRole" \
--policy-arn "POLICY_ARN"
--role-name "NewRelicECSTaskExecutionRole" \
--policy-arn "POLICY_ARN"
```
6. Choose your launch type for more instructions:
Expand All @@ -221,18 +221,18 @@ One [install option](#install-overview) is to manually do the steps that are don
1. Download the New Relic ECS integration task definition template file:
```
```sh
curl -O https://download.newrelic.com/infrastructure_agent/integrations/ecs/newrelic-infra-ecs-ec2-latest.json
```
2. Replace the task execution role in the template file with the newly created role:
```
```json
"executionRoleArn": "NewRelicECSTaskExecutionRole",
```
3. Replace the `valueFrom` attribute of the `secret` with the name of the Systems Manager parameter:
```
secrets": [
```json
"secrets": [
{
"valueFrom": "/newrelic-infra/ecs/license-key",
"name": "NRIA_LICENSE_KEY"
Expand All @@ -241,20 +241,20 @@ One [install option](#install-overview) is to manually do the steps that are don
```
4. Register the task definition file:
```
```sh
aws ecs register-task-definition --cli-input-json file://newrelic-infra-ecs-ec2-latest.json
```
5. Create a service with the [daemon scheduling](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html) strategy for the registered task:
For EC2 launch type:
```
```sh
aws ecs create-service --cluster "YOUR_CLUSTER_NAME" --service-name "newrelic-infra" --task-definition "newrelic-infra" --scheduling-strategy DAEMON --launch-type EC2
```
For EXTERNAL (ECS Anywhere) launch type:
```
```sh
aws ecs create-service --cluster "YOUR_CLUSTER_NAME" --service-name "newrelic-infra-external" --task-definition "newrelic-infra" --scheduling-strategy DAEMON --launch-type EXTERNAL
```
</Collapser>
Expand All @@ -267,7 +267,7 @@ One [install option](#install-overview) is to manually do the steps that are don
1. Download the task definition example with the sidecar container to be deployed:
```
```sh
curl -O https://download.newrelic.com/infrastructure_agent/integrations/ecs/newrelic-infra-ecs-fargate-example-latest.json
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ To get logs via CloudWatch:
Read [more about these options](/docs/infrastructure/install-configure-manage-infrastructure/configuration/infrastructure-configuration-settings#verbose).
2. We use a CloudWatch log group called `/newrelic-infra/ecs` to forward the logs to. To see if it already exists, run:

```
```sh
aws logs describe-log-groups --log-group-name-prefix /newrelic-infra/ecs
```

If a log group exists with that prefix, you'll get this output:
```
```json
{
"logGroups": [
{
Expand All @@ -112,19 +112,19 @@ To get logs via CloudWatch:
Because this command matches log groups with prefixes, ensure the log group name returned is exactly `/newrelic-infra/ecs`. If the log group doesn't exist, the output will be:

```
```json
{
"logGroups": []
}
```
3. If the log group doesn't exist, create it by running:
```
```sh
aws logs create-log-group --log-group-name /newrelic-infra/ecs
```
4. Edit your task definition. In the container definition for the `newrelic-infra` container, add the following `logConfiguration`:
```
```json
"logConfiguration": {
"logDriver": "awslogs",
"options": {
Expand All @@ -139,41 +139,41 @@ To get logs via CloudWatch:
To get all the log streams for a given log group, run this command:
```
```sh
aws logs describe-log-streams --log-group-name /newrelic-infra/ecs
```
The following is an example output of a log group with two streams:
```
{
"logStreams": [
{
"logStreamName": "verbose/newrelic-infra/9dfb28114e40415ebc399ec1e53a21b7",
"creationTime": 1586166741197,
"firstEventTimestamp": 1586166742030,
"lastEventTimestamp": 1586173933472,
"lastIngestionTime": 1586175101220,
"uploadSequenceToken": "49599989655680038369205623273330095416487086853777112338",
"arn": "arn:aws:logs:AWS_REGION_OF_YOUR_CLUSTER:YOUR_AWS_ACCOUNT:log-group:/newrelic-infra/ecs:log-stream:verbose/newrelic-infra/9dfb28114e40415ebc399ec1e53a21b7",
"storedBytes": 0
},
{
"logStreamName": "verbose/newrelic-infra/f6ce0be416804bc4bfa658da5514eb00",
"creationTime": 1586166745643,
"firstEventTimestamp": 1586166746491,
"lastEventTimestamp": 1586173037927,
"lastIngestionTime": 1586175100660,
"uploadSequenceToken": "49605664273821671319096446647846424799651902350804230514",
"arn": "arn:aws:logs:AWS_REGION_OF_YOUR_CLUSTER:YOUR_AWS_ACCOUNT:log-group:/newrelic-infra/ecs:log-stream:verbose/newrelic-infra/f6ce0be416804bc4bfa658da5514eb00",
"storedBytes": 0
}
]
}
```
```json
{
"logStreams": [
{
"logStreamName": "verbose/newrelic-infra/9dfb28114e40415ebc399ec1e53a21b7",
"creationTime": 1586166741197,
"firstEventTimestamp": 1586166742030,
"lastEventTimestamp": 1586173933472,
"lastIngestionTime": 1586175101220,
"uploadSequenceToken": "49599989655680038369205623273330095416487086853777112338",
"arn": "arn:aws:logs:AWS_REGION_OF_YOUR_CLUSTER:YOUR_AWS_ACCOUNT:log-group:/newrelic-infra/ecs:log-stream:verbose/newrelic-infra/9dfb28114e40415ebc399ec1e53a21b7",
"storedBytes": 0
},
{
"logStreamName": "verbose/newrelic-infra/f6ce0be416804bc4bfa658da5514eb00",
"creationTime": 1586166745643,
"firstEventTimestamp": 1586166746491,
"lastEventTimestamp": 1586173037927,
"lastIngestionTime": 1586175100660,
"uploadSequenceToken": "49605664273821671319096446647846424799651902350804230514",
"arn": "arn:aws:logs:AWS_REGION_OF_YOUR_CLUSTER:YOUR_AWS_ACCOUNT:log-group:/newrelic-infra/ecs:log-stream:verbose/newrelic-infra/f6ce0be416804bc4bfa658da5514eb00",
"storedBytes": 0
}
]
}
```
7. From the previous list of log streams, identify the one with the task ID for which you want to retrieve the logs and use the logStreamName in this command:
```
```sh
aws logs get-log-events --log-group-name /newrelic-infra/ecs --log-stream-name "LOG_STREAM_NAME" --output text > logs.txt
```
8. Continue with the [enable verbose logs](#env-variable) instructions.
Expand All @@ -186,14 +186,14 @@ To enable verbose logs by running a command from the running container:
2. Find the container ID of the New Relic integration container by running the command `docker ps -a`. The name of the container should be `nri-ecs`.
3. Enable verbose logs for a limited period of time by using `newrelic-infra-ctl`. Run the command:
```
```sh
docker exec INTEGRATION_CONTAINER_ID /usr/bin/newrelic-infra-ctl
```
For more details, see [Troubleshoot the agent](/docs/infrastructure/install-configure-manage-infrastructure/manage-your-agent/troubleshoot-running-agent).
4. Save the logs from the container with the command
```
```sh
docker logs INTEGRATION_CONTAINER_ID > logs.txt
```
Expand Down
Loading

0 comments on commit 7dcea5c

Please sign in to comment.