This document provides instructions to install the necessary dependencies and run the HTTPS notification draft implementation.
Ensure you have Python 3.7+ (for running local utility scripts) and Docker Compose installed on your system. Docker Compose is typically bundled with Docker Desktop on Windows/macOS, or can be installed separately on Linux.
First, clone the repository to your local machine:
git clone https://github.com/MeherRushi/https-notif-draft-impl.git
cd https-notif-draft-impl-
Copy the sample environment file:
cd python/flask_impl/ cp .env.sample .env -
Edit the
.envfile: Open the newly created.envfile in a text editor. Populate it with specific values.- Example
.envcontent:INFLUXDB_TOKEN="your_influxdb_admin_token" INFLUXDB_ORG="your_influxdb_organization" INFLUXDB_BUCKET="your_influxdb_bucket" - Important: These values should match what you've configured for the
influxdbservice'sDOCKER_INFLUXDB_INIT_*environment variables in yourdocker-compose.yml.
- Example
The Collector (Flask/FastAPI) applications utilize SSL certificates for secure communication. Ensure your certs directory, located at the root of your project, contains server.crt and server.key.
If you're setting up for local testing and don't have existing certificates, you can generate self-signed ones using OpenSSL:
mkdir -p certs
openssl req -x509 -newkey rsa:4096 -nodes -keyout certs/server.key -out certs/server.crt -days 365 -subj "/CN=localhost"Note: For production deployments, always use certificates issued by a trusted Certificate Authority.
While the main applications are containerized, any local utility scripts (like read_db.py) or local development of the applications will require Python and their dependencies to be installed on your host machine. It's highly recommended to use a virtual environment to manage these dependencies.
- Create a virtual environment:
Navigate to your project's root directory and run:
python3 -m venv venv
- Activate the virtual environment:
source venv/bin/activate - Install Python dependencies:
Install the dependencies required for your local scripts. For instance, to install dependencies for
read_db.py:If you plan to run publisher or collector locally, install their dependencies too.pip install -r python/flask_impl/requirements.txt
This single command will orchestrate your entire environment. It will build all necessary Docker images, create the network, and start all services, including Zookeeper, Kafka, InfluxDB, Prometheus, Grafana, your Flask/FastAPI Collector, and your Publisher.
Navigate to the root directory of your cloned repository (where docker-compose.yml is located) and run:
docker-compose up --build -d--build: Ensures that any changes to your application'sDockerfiles are incorporated. This is crucial if you've modified application code or dependencies.- The Flask Collector's image will be built using
python/flask_impl/Dockerfile. - The Kafka Consumer's image will be built using
python/flask_impl/kafka_consumer.Dockerfile. - The Publisher's image will be built using
python/publisher/Dockerfile.
- The Flask Collector's image will be built using
-d: Runs the containers in detached mode (in the background).
After the services are up, you might need to perform a one-time setup for InfluxDB, depending on how you've configured its initial credentials in docker-compose.yml.
- Access InfluxDB UI: Open your web browser and go to
https://localhost:8086. - Initial Setup: Follow the on-screen prompts to set up your initial user, organization, and bucket if they weren't fully configured via environment variables.
- Retrieve Token: After setup, navigate to "Data" -> "API Tokens" and copy your Operator Token or create a new "All Access API Token".
- Verify
docker-compose.ymland.env:- Ensure the
INFLUXDB_TOKEN,INFLUXDB_ORG, andINFLUXDB_BUCKETenvironment variables in yourdocker-compose.ymlmatch the values you configured/retrieved from InfluxDB. - Similarly, ensure your local
.envfile (forread_db.py) has these correct values.
- Ensure the
You can check the status of your services and view their logs to confirm everything is running as expected.
-
Check Service Status:
docker-compose ps
All services should show
Uporhealthy.kafka_topic_creatorwill show asExited -
View Logs (e.g., Publisher to Collector flow):
docker-compose logs -f publisher_app docker-compose logs -f flask_collector docker-compose logs -f kafka_consumer_app
You should observe
publisher_appsuccessfully sending data,flask_collectorreceiving and processing it, andkafka_consumer_appconsuming from Kafka and writing to InfluxDB. -
Read data inserted in InfluxDB: InfluxDB UI:
https://localhost:8086or run
python/flask_impl/read_db.py
Once Grafana is running, you can configure it to visualize metrics collected by Prometheus:
-
Access Grafana:
Open your browser and go to http://localhost:3000.
Login with the default credentials (admin/admin). -
Add Prometheus as a Data Source: - In the left sidebar, click the gear icon (⚙️) for Configuration. - Select Data Sources and click Add data source. - Choose Prometheus. - Set the URL to
http://prometheus:9090(if using Docker Compose, this internal name works; otherwise, usehttp://localhost:9090). - Click Save & Test to verify the connection. -
Create a Dashboard: - Click the plus icon (+) in the sidebar and select Dashboard. - Click Add new panel. - In the query editor, select Prometheus as the data source and enter your desired Prometheus query (e.g.,
up,http_requests_total, etc.). - Configure visualization options as needed. - Click Apply to save the panel. -
Save the Dashboard: - Click the disk icon to save your dashboard for future use.
You can now monitor your application's metrics in real time using Grafana dashboards powered by Prometheus data.
-
To stop all running containers and remove their networks:
docker-compose downTo also remove named volumes (which contain your persistent InfluxDB and Prometheus data), ensuring a completely clean slate:
docker-compose down -v