Skip to content

Commit

Permalink
add monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
prajjwalyd committed Jul 12, 2024
1 parent 5a87894 commit cc952b8
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions analytics/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from prometheus_flask_exporter import PrometheusMetrics
from datetime import datetime
import logging

Expand All @@ -8,6 +9,7 @@
logger = logging.getLogger(__name__)

app = Flask(__name__)
metrics = PrometheusMetrics(app)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://user:password@my-postgresql:5432/analytics-db'

try:
Expand Down
3 changes: 2 additions & 1 deletion analytics/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flask
flask_sqlalchemy
psycopg2-binary
psycopg2-binary
prometheus-flask-exporter
2 changes: 2 additions & 0 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from flask import Flask, request, jsonify, send_file, redirect
from pymongo import MongoClient, errors
from prometheus_flask_exporter import PrometheusMetrics
import requests
import io
import logging

app = Flask(__name__)
metrics = PrometheusMetrics(app)

# Set up logging
logging.basicConfig(level=logging.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flask
pymongo
requests
prometheus-flask-exporter
2 changes: 2 additions & 0 deletions qr-code-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
_ "encoding/base64"
"github.com/skip2/go-qrcode"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

func generateQRCode(w http.ResponseWriter, r *http.Request) {
Expand All @@ -22,6 +23,7 @@ func generateQRCode(w http.ResponseWriter, r *http.Request) {
}

func main() {
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/generate_qr", generateQRCode)
http.ListenAndServe("0.0.0.0:5002", nil)
}
2 changes: 2 additions & 0 deletions url-shortener/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from flask import Flask, request, jsonify, abort
from prometheus_flask_exporter import PrometheusMetrics
import random
import string

app = Flask(__name__)
metrics = PrometheusMetrics(app)

# Function to generate a random short URL
def generate_short_url():
Expand Down
1 change: 1 addition & 0 deletions url-shortener/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
flask
prometheus-flask-exporter

0 comments on commit cc952b8

Please sign in to comment.