Skip to content

Commit

Permalink
Merge branch 'master' into feature/nr_tags_optional
Browse files Browse the repository at this point in the history
  • Loading branch information
adiesner committed Sep 9, 2024
2 parents d26a951 + 020955f commit 8be7f87
Show file tree
Hide file tree
Showing 14 changed files with 2,019 additions and 1,231 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
lint:
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.11"]
poetry-version: ["1.4"]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
Expand All @@ -28,7 +28,7 @@ jobs:
test:
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.11"]
poetry-version: ["1.4"]
os: [ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
release:
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.11"]
poetry-version: ["1.4"]
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ repos:
rev: 22.3.0
hooks:
- id: black
language_version: python3.9
language_version: python3.11
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9
FROM python:3.11
RUN apt-get update
RUN apt-get install -y zip

Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ to deploy the log ingestion function manually.
### SAM

1. Clone this repository: `git clone https://github.com/newrelic/aws-log-ingestion.git`
2. [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) Make sure you have >=0.33.0 installed, you can check with `sam --version`.
2. [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) Make sure you have >=1.105.0 installed, you can check with `sam --version`.
3. [Retrieve your New Relic License Key](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/license-key)
4. Build the SAM application (if on Linux `-u` can be omitted): `sam build -u --parameter-overrides 'ParameterKey=NRLicenseKey,ParameterValue=your-license-key-here'`
5. Deploy the SAM application: `sam deploy --guided`

Additional notes:

* To set `LOGGING_ENABLED`: `sam build ... --parameter-overrides 'ParameterKey=NRLoggingEnabled,ParameterValue=True'`

### Serverless

Expand All @@ -44,9 +42,7 @@ Additional notes:
6. Set the LICENSE_KEY environment variable: `export LICENSE_KEY=your-license-key-here`
7. Deploy the function: `sls deploy`

Additional notes:

* To set `LOGGING_ENABLED`: `export LOGGING_ENABLED=True` (prior to deploy)

### Terraform

Expand Down
3,174 changes: 1,984 additions & 1,190 deletions poetry.lock

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
[tool.poetry]
name = "aws-log-ingestion"
version = "2.7.1"
version = "2.9.4"
description = ""
authors = ["New Relic <[email protected]>"]
license = "Apache 2.0"

[tool.poetry.dependencies]
python = "^3.9"
aiohttp = "^3.8.4"
python = "^3.11"
aiohttp = "^3.9.5"

[tool.poetry.group.dev.dependencies]
asynctest = "^0.13.0"
aws-sam-cli = "^1.33.0"
black = "^23.3.0"
aws-sam-cli = "^1.118.0"
black = "^24.3.0"
boto3 = "^1.19.2"
coverage = "^6.0.2"
flake8 = "^4.0.1"
mock = "^4.0.3"
pytest = "^6.2.5"
pytest = "^7.2.0"
pytest-asyncio = "^0.16.0"
serverlessrepo = {git = "https://github.com/kolanos/aws-serverlessrepo-python.git", rev = "master"}
pyyaml = "!=5.4.1, !=5.4.0" # pyyaml is broken with cython 3

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 88
target-version = ['py39']
target-version = ['py311']
include = '\.pyi?$'
exclude = '''
/(
Expand Down
4 changes: 2 additions & 2 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ service: newrelic-log-ingestion

provider:
name: aws
runtime: python3.9
runtime: python3.11
stage: production
timeout: 30

Expand All @@ -15,7 +15,7 @@ provider:
# Your NewRelic license key
LICENSE_KEY: ${env:LICENSE_KEY}
# Determines if logs are forwarded to New Relic Logging
LOGGING_ENABLED: ${env:LOGGING_ENABLED, "False"}
LOGGING_ENABLED: ${env:LOGGING_ENABLED, "True"}
# A boolean to determine if you want to output debug messages in the CloudWatch console
DEBUG_LOGGING_ENABLED: ${env:DEBUG_LOGGING_ENABLED, "False"}

Expand Down
2 changes: 1 addition & 1 deletion src/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class EntryType(Enum):
r"(?P<request_id>[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})"
)

LOGGING_LAMBDA_VERSION = "1.0.3"
LOGGING_LAMBDA_VERSION = "2.9.4"
LOGGING_PLUGIN_METADATA = {"type": "lambda", "version": LOGGING_LAMBDA_VERSION}


Expand Down
16 changes: 7 additions & 9 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
aiohttp==3.8.4 ; python_version >= "3.9" and python_version < "4.0"
aiosignal==1.3.1 ; python_version >= "3.9" and python_version < "4.0"
async-timeout==4.0.2 ; python_version >= "3.9" and python_version < "4.0"
attrs==23.1.0 ; python_version >= "3.9" and python_version < "4.0"
charset-normalizer==3.1.0 ; python_version >= "3.9" and python_version < "4.0"
frozenlist==1.3.3 ; python_version >= "3.9" and python_version < "4.0"
idna==3.4 ; python_version >= "3.9" and python_version < "4.0"
multidict==6.0.4 ; python_version >= "3.9" and python_version < "4.0"
yarl==1.9.1 ; python_version >= "3.9" and python_version < "4.0"
aiohttp==3.9.5 ; python_version >= "3.11" and python_version < "4.0"
aiosignal==1.3.1 ; python_version >= "3.11" and python_version < "4.0"
attrs==23.2.0 ; python_version >= "3.11" and python_version < "4.0"
frozenlist==1.4.1 ; python_version >= "3.11" and python_version < "4.0"
idna==3.6 ; python_version >= "3.11" and python_version < "4.0"
multidict==6.0.5 ; python_version >= "3.11" and python_version < "4.0"
yarl==1.9.4 ; python_version >= "3.11" and python_version < "4.0"
12 changes: 6 additions & 6 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Parameters:
NRLoggingEnabled:
Type: String
Description: Determines if logs are forwarded to New Relic Logging
Default: 'False'
Default: 'True'
AllowedValues:
- 'True'
- 'False'
Expand Down Expand Up @@ -62,7 +62,7 @@ Metadata:
LicenseUrl: LICENSE
ReadmeUrl: README.md
HomePageUrl: https://github.com/newrelic/aws-log-ingestion
SemanticVersion: 2.7.1
SemanticVersion: 2.9.4
SourceCodeUrl: https://github.com/newrelic/aws-log-ingestion

Resources:
Expand All @@ -74,10 +74,10 @@ Resources:
CodeUri: src/
Description: Sends log data from CloudWatch Logs to New Relic Infrastructure (Cloud integrations) and New Relic Logging
Handler: function.lambda_handler
FunctionName: newrelic-log-ingestion
FunctionName: !Join ['-', ['newrelic-log-ingestion', !Select [4, !Split ['-', !Select [2, !Split ['/', !Ref AWS::StackId]]]]]]
MemorySize:
Ref: MemorySize
Runtime: python3.9
Runtime: python3.11
PermissionsBoundary: !If [ HasPermissionBoundary, !Ref PermissionsBoundary, !Ref AWS::NoValue ]
Role: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${FunctionRole}
Timeout:
Expand All @@ -96,10 +96,10 @@ Resources:
CodeUri: src/
Description: Sends log data from CloudWatch Logs to New Relic Infrastructure (Cloud integrations) and New Relic Logging
Handler: function.lambda_handler
FunctionName: newrelic-log-ingestion
FunctionName: !Join ['-', ['newrelic-log-ingestion', !Select [4, !Split ['-', !Select [2, !Split ['/', !Ref AWS::StackId]]]]]]
MemorySize:
Ref: MemorySize
Runtime: python3.9
Runtime: python3.11
PermissionsBoundary: !If [ HasPermissionBoundary, !Ref PermissionsBoundary, !Ref AWS::NoValue ]
Timeout:
Ref: Timeout
Expand Down
4 changes: 2 additions & 2 deletions terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ variable "nr_license_key" {
variable "nr_logging_enabled" {
type = bool
description = "Determines if logs are forwarded to New Relic Logging"
default = false
default = true
}

variable "nr_infra_logging" {
Expand Down Expand Up @@ -183,7 +183,7 @@ resource "aws_lambda_function" "ingestion_function" {
? var.function_role
: aws_iam_role.lambda_role.0.arn
)
runtime = "python3.9"
runtime = "python3.11"
filename = local.archive_name
handler = "function.lambda_handler"
memory_size = var.memory_size
Expand Down
1 change: 1 addition & 0 deletions test/build-encoded-file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Build a properly encoded payload to test log ingestion without needing to invoke
the lambda.
"""

import json
import sys
import gzip
Expand Down
4 changes: 2 additions & 2 deletions test/log_ingestion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from test.aws_log_events import AwsLogEvents

import asyncio
from asynctest import CoroutineMock, MagicMock
from unittest.mock import MagicMock, AsyncMock

US_URL = "https://log-api.newrelic.com/log/v1"
EU_URL = "https://log-api.eu.newrelic.com/log/v1"
Expand Down Expand Up @@ -56,7 +56,7 @@ def event_loop():

@pytest.fixture
def mock_aio_post():
with patch("aiohttp.ClientSession.post", new=CoroutineMock()) as mocked_aio_post:
with patch("aiohttp.ClientSession.post", new=AsyncMock()) as mocked_aio_post:
yield mocked_aio_post


Expand Down

0 comments on commit 8be7f87

Please sign in to comment.