Running PostHog Product Analytics on Koyeb
4 minIntroduction
PostHog is a developer-friendly open-source product analytics tool. With PostHog, you can automate the collection of events on your websites and apps and analyze them without sending data to third parties.
By deploying your PostHog application on Koyeb you benefit from native autoscaling, Automatic HTTPS (SSL) on all apps you deployed, high availability, and global load-balancing & CDN to make your applications global.
Requirements
To successfully deploy PostHog on Koyeb, you need:
- A Koyeb account to deploy and run PostHog
- The Koyeb CLI installed to interact with Koyeb from the command line
- A running PostgreSQL database Koyeb can access
Steps
In order to deploy your PostHog app to Koyeb, you have to follow these steps:
- Create a new Koyeb App to deploy PostHog
- Deploy Redis
- Create Secrets for PostHog App and PostgreSQL Connection
- Deploy PostHog on Koyeb
Create a new Koyeb App to deploy PostHog
Start by creating a new Koyeb App we will deploy and run PostHog. In a terminal execute the following commands to create a new App:
Deploy Redis
With the PostHog Koyeb App created, we now can deploy the Redis service required by PostHog. In a terminal, execute the following command to deploy the Redis instance:
Create Secrets for PostHog App and PostgreSQL Database
Koyeb Secrets allow you to securely store and retrieve sensitive information like passwords. All Secret values are automatically encrypted server-side to ensure secure storage. To find out more about Koyeb Secrets, read our documentation about it here.
Koyeb Secret for PostHog Instance
For PostHog to work, you must create a SECRET_KEY
that is unique to your PostHog instance. This SECRET_KEY
is very important because it is used to encrypt cookies and password reset emails.
To create your SECRET_KEY
and store it as a Koyeb Secret, in your terminal execute:
The command below generates a new key and creates a new Koyeb Secret posthog-secret
to securely store the key on Koyeb.
Koyeb Secret for PostgreSQL Database Connection
Create a Koyeb secret to securely store your PostgreSQL connection URL.
In the terminal execute the following command and replace the following values with your own:
<DB_USERNAME>
: PostgreSQL username<DB_PASSWORD>
: PostgreSQL password<DB_HOST>
: PostgreSQL host<DB_PORT>
: PostgreSQL port<DB_NAME>
: PostgreSQL database name
Deploy PostHog on Koyeb
With al the previous steps completed, you are ready to deploy PostHog on Koyeb. In the terminal execute the following command:
Within a few minutes you will be able to access your PostHog instance at https://posthog-<YOUR_KOYEB_ORG_NAME>.koyeb.app/
You can track the deployment logs in your terminal with this command:
Your PostHog application is now running on Koyeb and benefits from native autoscaling, automatic HTTPS (SSL), auto-healing, and global load-balancing across our edge network.
Conclusion
In this guide, we saw how easy it is to deploy PostHog on Koyeb and how to interact with the Koyeb platform using the CLI.
If you would like to read more Koyeb tutorials, checkout out our tutorials collection. Have an idea for a tutorial you'd like us to cover? Let us know by joining the conversation over on the Koyeb community platform!
Want to deploy your workloads on Koyeb? We let you run web apps, APIs, background workers, and more using git-based deployment or Docker containers! Enjoy native autoscaling, free SSL, a global edge network, and built-in service mesh and discovery with near zero configuration. Sign up and get started now