How to run new relic command on koyeb to enable infrastructure and logs metrics

I want add new relic to my fastapi in koyeb I tried to use console but it keeps throwing sudo error. how can I implement this


How are you installing newrelic? From what I understand of your message, you are trying to run pip install newrelic from a shell on your instance.

You should instead update your requirements.txt file and add newrelic in it.

If my message doesn’t help, can you please provide:

  • a screenshot of the error
  • explain how do you package your application?


1 Like

Thank you for your response I already have new relic in my requirements.txt and it works partially at the moment so basically there are 2 things you have to do

  1. Adding the new relic file and adding the build command in koyeb [I already did this successfully]
NEW_RELIC_CONFIG_FILE=newrelic. ini newrelic-admin run-program $YOUR_COMMAND_OPTIONS
  1. this is where I am stuck as it requires me to download the cli on the host but I do not know how to … I tried “Console” but no luck

still waiting :slight_smile:


I’m sorry it took me a while to answer.
I think the only option is to use a Dockerfile, instead of the buildpack builder.

Create a Dockerfile, install your application and the CLI, and it should work.

Do you need help to do so?

Yes I do since I do not know docker

Alright. Below is a small explanation how to start a fastapi application. You will have to adapt this to fit your use-case.

Let’s say you have a fastapi application stored in

from fastapi import FastAPI

app = FastAPI()

async def root():
    return {"message": "Hello World"}

Next to it, let’s say you have a requirements.txt file to install fastapi and uvicorn:


All you have to do is create a file named Dockerfile with the following content:

FROM python

RUN curl | bash

COPY requirements.txt /app/

# Install dependencies
RUN pip install -r requirements.txt

COPY . /app

CMD ["uvicorn", "app:app", "--host", ""]

Notice we install the newrelic CLI, using the link you gave in your previous answer.

From Koyeb, create a new service and select the Docker builder, and expose the port 8000.