Skip to content

Latest commit

 

History

History
113 lines (79 loc) · 3.56 KB

README.md

File metadata and controls

113 lines (79 loc) · 3.56 KB

newrelic-metrics-example

Example Dockerized New Relic Agent with PostgreSQL Metrics Integration for Aptible

Overview

This repository contains an example setup for monitoring PostgreSQL metrics using the New Relic agent in a Dockerized environment. It is tailored for Aptible deployments, with seamless integration to collect database performance metrics.

Environment Variables

To configure the New Relic agent and database connections, set the following environment variables:

NEW_RELIC_LICENSE_KEY

  • Description: Your New Relic account's license key, required for reporting metrics to New Relic
  • Example: 1234567890abcdef1234567890abcdef12345678

NEW_RELIC_INTERVAL_SEC

  • Description: Polling interval in seconds, defaulted to 30s.
  • Example: 15s

NEW_RELIC_EVENT_QUEUE_DEPTH

  • Description: This is used to configure event_queue_depth which adjusts the size of the queue the Infrastructure agent uses to store events before sending them to New Relic. Default: 5000
  • Example: 10000

PSQL_URLS

  • Description: A comma-delimited list of PostgreSQL database URLs in the format:

    postgresql://USER:PASSWORD@HOST:PORT/DB_NAME|DATABASE_HANDLE|NEW_RELIC_ENV_LABEL
    

    Multiple database URLs can be provided, separated by commas.

  • Example:

    postgresql://user1:[email protected]:5432/database1|database-instance-1|test,postgresql://user2:[email protected]:5432/database2|database-instance-2|staging
    

NEW_RELIC_LICENSE_KEY

  • Description: Your New Relic account's license key, required for reporting metrics to New Relic
  • Example: 1234567890abcdef1234567890abcdef12345678

Local Usage

  1. Clone this repository:

    git clone https://github.com/yourusername/newrelic-metrics-example.git
  2. Navigate to the repository directory:

    cd newrelic-metrics-example
  3. Build the Docker image:

    docker build -t newrelic-metrics-example .
  4. Run the container with the required environment variables:

    docker run -e NEW_RELIC_LICENSE_KEY=1234567890abcdef1234567890abcdef12345678 \
               -e PSQL_URLS="postgresql://user1:[email protected]:5432/database1|database-instance-1|test,postgresql://user2:[email protected]:5432/database2|database-instance-2|staging" \
               newrelic-metrics-example

Using with Aptible

Follow these steps to deploy the New Relic metrics agent on Aptible:

  1. Clone the repository:

    git clone https://github.com/aptible/newrelic-metrics-example.git
    cd newrelic-metrics-example
  2. Create a new Aptible app (newrelic-metrics is just a sample name used in this example):

    aptible apps:create newrelic-metrics
  3. Add Aptible as a remote:

    git remote add aptible [email protected]:app-name/newrelic-metrics.git
  4. Configure the app environment, substituting your own values below:

    aptible config:set --app newrelic-metrics \
      NEW_RELIC_LICENSE_KEY=your-license-key \
      PSQL_URLS=your-database-urls
  5. Deploy to Aptible:

    git push aptible main

Notes

  • Ensure that the PostgreSQL databases are accessible from the container's network
  • The New Relic license key and database urls must remain confidential; avoid sharing them in public repositories

License

This project is open-source and available under the MIT License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have suggestions or improvements.