https://github.com/euiyounghwang/db-interface-export
Python DB Interface with Prometheus-Export
https://github.com/euiyounghwang/db-interface-export
fastapi oracle prometheus-exporter
Last synced: about 2 months ago
JSON representation
Python DB Interface with Prometheus-Export
- Host: GitHub
- URL: https://github.com/euiyounghwang/db-interface-export
- Owner: euiyounghwang
- Created: 2024-05-24T14:06:37.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2026-02-26T17:01:10.000Z (4 months ago)
- Last Synced: 2026-02-26T23:13:02.610Z (4 months ago)
- Topics: fastapi, oracle, prometheus-exporter
- Language: Python
- Homepage:
- Size: 3.56 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DB-Interface-Export
Python DB Interface with Prometheus-Export
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python.
This is a repository that provides to deliver the records to the Prometheus-Export application.
### Install Poerty
```
https://python-poetry.org/docs/?ref=dylancastillo.co#installing-with-the-official-installer
```
### Using Python Virtual Environment
```bash
python -m venv .venv
source .venv/bin/activate
```
### Using Poetry: Create the virtual environment in the same directory as the project and install the dependencies:
- Gunicorn is a Python WSGI HTTP Server that usually lives between a reverse proxy (e.g., Nginx) or load balancer (e.g., AWS ELB) and a web application such as Django or Flask.
- Better performance by optimizing Gunicorn config (https://medium.com/building-the-system/gunicorn-3-means-of-concurrency-efbb547674b7)
- The suggested number of workers is (2*CPU)+1.
- gunicorn --workers=5 --threads=2 --worker-class=gthread main:app, the maximum concurrent requests areworkers * threads 10 in our case.
```bash
poetry config virtualenvs.in-project true
poetry init
poetry add fastapi
poetry add uvicorn
poetry add pytz
poetry add httpx
poetry add pytest
poetry add pytest-cov
poetry add requests
poetry add python-dotenv
poetry add JPype1
poetry add psycopg2-binary
poetry add jaydebeapi
...
# start with gunicorn config
gunicorn.config.py
import multiprocessing
workers = multiprocessing.cpu_count() * 2 + 1
worker_class = "uvicorn.workers.UvicornWorker"
wsgi_app = "app.main:app"
timeout = 60
loglevel = "info"
bind = "0.0.0.0:8000"
max_requests = 1000
max_requests_jitter = 100
...
gunicorn -c app/gunicorn.config.py
gunicorn -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8004 --workers 4
..
uvicorn app.main:app --reload for dev
```
or you can run this shell script `./create_virtual_env.sh` to make an environment. then go to virtual enviroment using `source .venv/bin/activate`
### Register Service
- sudo service db_es_api status/stop/start/restart
```bash
#-- /etc/systemd/system/db_es_api.service
[Unit]
Description=DB ES Service
[Service]
User=devuser
Group=devuser
Type=simple
ExecStart=/bin/bash /home/devuser/db_interface_api/service-start.sh
ExecStop= /usr/bin/killall db_es_service
[Install]
WantedBy=default.target
# Service command
sudo systemctl daemon-reload
sudo systemctl enable db_es_api.service
sudo systemctl start db_es_api.service
sudo systemctl status db_es_api.service
sudo systemctl stop db_es_api.service
sudo service db_es_api status/stop/start
```
### Service
- Run this command `./start-start.sh` or python -m uvicorn main:app --reload --host=0.0.0.0 --port=8002 --workers 4
- Service : http://localhost:8002/docs