C++ with prometheus
- Compile and run the C++ application:
Navigate to your C++ project directory and run these commands:
mkdir build
cd build
cmake ..
make
./MyProject
This will start your C++ application, and it will start exposing metrics at http://127.0.0.1:8001/metrics.
- Run the Python application:
python3 server.py
Ensure your Python script is running and exposing metrics at http://127.0.0.1:8000.
-
Run Prometheus: Download and unzip prometheus from: https://prometheus.io/download/
-
Start the Prometheus server with the configuration file: Example: ~/Downloads/prometheus-2.45.0.darwin-amd64/prometheus --config.file=prometheus.yml
-
Check the Prometheus UI: Open a web browser and go to http://127.0.0.1:9090.
Click on "Graph" from the top menu, then choose "Console" below. In the "Expression" input box, type app_requests_total (or whatever metric you're collecting), then click "Execute". You should see the metric values from both your Python and C++ applications.