Skip to content

Commit d4aabc4

Browse files
committed
docs: infra payload format
- add infra payload details and example - update pre-commit to latest standard - update .gitignore to ignore samconfig.toml files
1 parent 1430a24 commit d4aabc4

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ __pycache__/
1414

1515
packaged.yaml
1616
.aws-sam/
17+
samconfig.toml
1718
/src/requirements.txt
1819

1920
.serverless

.pre-commit-config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
repos:
12
- repo: https://github.com/psf/black
2-
rev: stable
3+
rev: 22.3.0
34
hooks:
45
- id: black
56
language_version: python3.7

README.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ To forward data to New Relic you need a [New Relic License Key](https://docs.new
1313
To install and configure the New Relic Cloudwatch Logs Lambda, [see our documentation](https://docs.newrelic.com/docs/logs/enable-logs/enable-logs/aws-cloudwatch-plugin-logs).
1414

1515
Additional notes:
16-
* Some users in UTF-8 environments have reported difficulty with defining strings of `NR_TAGS` delimited by the semicolon `;` character. If this applies to you, you can set an alternative delimiter character as the value of `NR_ENV_DELIMITER`, and separate your `NR_TAGS` with that.
16+
17+
* Some users in UTF-8 environments have reported difficulty with defining strings of `NR_TAGS` delimited by the semicolon `;` character. If this applies to you, you can set an alternative delimiter character as the value of `NR_ENV_DELIMITER`, and separate your `NR_TAGS` with that.
1718
* Custom Lambda and VPC log groups can be set using the `NR_LAMBDA_LOG_GROUP_PREFIX` and `NR_VPC_LOG_GROUP_PREFIX` environment variables.
1819

1920
## Manual Deployment
@@ -59,3 +60,39 @@ module "newrelic_log_ingestion" {
5960
```
6061

6162
By default, this will build and pack the lambda zip inside of the Terraform Module. You can supply your own by switching `build_lambda = false`, and specify the path to your lambda, using `lambda_archive = "{{LAMBDA_PATH}}"`, replacing `{{LAMBDA_PATH}}` with the path to your lambda.
63+
64+
## Infra Payload Format
65+
66+
The maximum payload size in bytes is:
67+
68+
<https://github.com/newrelic/aws-log-ingestion/blob/1430a247f1fb5feb844f0707838a6ef48d21fc41/src/function.py#L76>
69+
70+
If your payload exceeds this size, you will need to split it into pieces:
71+
72+
<https://github.com/newrelic/aws-log-ingestion/blob/1430a247f1fb5feb844f0707838a6ef48d21fc41/src/function.py#L292-L306>
73+
74+
The payload should be gzipped before sending:
75+
76+
<https://github.com/newrelic/aws-log-ingestion/blob/1430a247f1fb5feb844f0707838a6ef48d21fc41/src/function.py#L298>
77+
78+
Required headers include:
79+
80+
* <https://github.com/newrelic/aws-log-ingestion/blob/1430a247f1fb5feb844f0707838a6ef48d21fc41/src/function.py#L360-L361>
81+
* `Content-Length`
82+
* `Host`
83+
84+
The payload should include the following elements (properly escaped):
85+
86+
```json
87+
{
88+
"context": {
89+
"function_name": "newrelic-log-ingestion",
90+
"invoked_function_arn": "arn:aws:lambda:<your_aws_region>:<your_aws_account>:function:<your_function_name>",
91+
"log_group_name": "/aws/lambda/newrelic-log-ingestion",
92+
"log_stream_name": "2022/05/17/[$LATEST]30dce751bc1a4e7497eb644171d70153"
93+
},
94+
"entry": "{\"messageType\": \"DATA_MESSAGE\", \"owner\": \"<your_aws_account>\", \"logGroup\": \"/aws/lambda/<your_function_name>\", \"logStream\": \"2022/05/17/[$LATEST]80a45416bdb4436ab148bca161a22fa4\", \"subscriptionFilters\": [\"<your_function_name>\"], \"logEvents\": [{\"id\": \"36858672311120633630098786383886689203484013407063113737\", \"timestamp\": 1652800029012, \"message\": \"[1,\\\"NR_LAMBDA_MONITORING\\\",\\\"H4sIAAAAAAAAA+1Y3W/bNhB/919hCHu0JUrUF40hQLZ2WIBiLWBveygKgZZOHjea0kjJiRvkfx8lS66s2Elqx0XXVC/U3ZG8u98djx+3g+HQWEJBE1pQYzK81bTmUCk0UTUTeq0mnC7nCZ38uM5KGWlGJGHBMnHR4dA4zkpRXEzSUsSFFjaylowEXcKFMdrMv+WuQCrdVsp+eHM5ez2dtV3gBuKy7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672311232137356091439499594367794847255214593015820\", \"timestamp\": 1652800029017, \"message\": \"REPORT RequestId: 60d9a6a3-f31e-43e6-94a7-8485e06f8aa6\\tDuration: 13.98 ms\\tBilled Duration: 14 ms\\tMemory Size: 1024 MB\\tMax Memory Used: 87 MB\\tInit Duration: 584.39 ms\\t\\n\"}]}"
95+
}
96+
```
97+
98+
*Note: Replace <your_xyz> elements with your content.*

0 commit comments

Comments
 (0)