extra-php-extensions icon indicating copy to clipboard operation
extra-php-extensions copied to clipboard

bref-extra:newrelic-php-82 is not working

Open kristijorgji opened this issue 1 year ago • 1 comments

Hi all,

I am using serverless and your plugin bref-extra:newrelic-php-82 I have one Laravel 10.22.0 PHP application.

My issue is that no data is sent to newrelic. The lambda is working great

Example serverless.yaml file, (credentials and stuff are of course removed)

frameworkVersion: ^3.18.2

service: api

# allows loading .env and using them via $(env:variableName}
useDotenv: true

provider:
  name: aws
  region: eu-central-1
  stage: ${opt:stage, 'dev'}
  deploymentBucket:
    name: ${ssm:/${self:provider.stage}/${self:provider.region}/infra/serverless_deployment_bucket_name}
  tags:
    Environment: ${opt:stage, 'dev'}
    Project: ${self:custom.serviceName}
  environment:
    # our .env is loaded here via the plugin serverless-dotenv-plugin
    # required because we cannot write anywhere else within the AWS Lambda
    LARAVEL_STORAGE_PATH: /tmp/storage
    NEW_RELIC_LICENSE_KEY: "key"

custom:
  serviceName: 'api'

package:
  # Files and directories to exclude from deployment
  patterns:
    - '!node_modules/**'
    - '!public/storage'
    - '!resources/assets/**'
    - '!storage/**'
    - '!tests/**'
    - '!.env'
    - '!build/**'
    - '!dev-tools/**'
    - '!ext-config/**'
    - '!queries/**'

functions:
  # This function runs the Laravel website/API
  web:
    handler: public/index.php
    vpc:
      securityGroupIds:
        - ${ssm:/${self:provider.stage}/${self:provider.region}/applications/${self:custom.serviceName}/lambda_security_group}
      subnetIds: ${ssm:/${self:provider.stage}/${self:provider.region}/infra/vpc_private_subnets}
    runtime: php-82-fpm
    layers:
      - ${bref-extra:redis-php-82}
      - ${bref-extra:gd-php-82}
      - ${bref-extra:newrelic-php-82}
    environment:
      LOGGER_EMAIL_NAME: "[${env:APP_ENV}] API-api logger"
      NEW_RELIC_APP_NAME: "api-api-${env:APP_ENV}"
    events:
      - alb:
          listenerArn: ${ssm:/${self:provider.stage}/${self:provider.region}/infra/lb_https_listener_arn}
          multiValueHeaders: true
          priority: 1
          conditions:
            path:
              - /api/*

plugins:
  - ./vendor/bref/bref                        # lambda layer allowing laravel to work within aws serverless
  - ./vendor/bref/extra-php-extensions        # for enabling php extensions via bref
  - serverless-lift                           # provides aws functionalities for creating the sqs queue
  - serverless-dotenv-plugin                  # loads .env file into serverless variables

I checked

  1. The variables under lambda -> envrionment and they are really set
  2. The lambda layers in aws and I do see newrelic lambda layer there Screenshot 2024-09-04 at 16 51 29

What can be the issue? I am lost on how to make this work

kristijorgji avatar Sep 04 '24 14:09 kristijorgji

Hi @kristijorgji

Sorry I never noticed you asked this question. Do you still having issues? Im using the NewRelic php agent, and also used it with php 8.2, so I know it should work.

To make some details clear:

  • This bref extension only contains the php agent
  • You also need a running newrelic daemon that will forward your data to newrelic. You can run this in many ways, but I did it via ECS and later with Fargate
  • You need to create a ini file with configuration, especially the newrelic.daemon.address is important

I can try to help out if needed!

starred-gijs avatar Apr 23 '25 19:04 starred-gijs