jeremyjordan / ml-monitoring

A demo of Prometheus+Grafana for monitoring an ML model served with FastAPI.
https://www.jeremyjordan.me/ml-monitoring/
MIT License
226 stars 60 forks source link

Latency & Counter Metrics Not Detected By Prometheus #7

Closed rileyhun closed 3 years ago

rileyhun commented 3 years ago

Hello @jeremyjordan,

I've been following your fastapi ml-monitoring repository as a template for my own project and it's been super helpful! Thanks so much for setting this up. Unfortunately, I'm experiencing a lot of trouble getting prometheus to scrape my Counter metric and latency as well. Interestingly, when I run your wine-quality application and add a Counter metric though, it seems to be working fine, but mine which pretty much follows your same approach (only difference being that I set up my application using application factory design pattern) doesn't seem to be working. It seems like histogram and summary are going through though.

Do you have any insight as to what the issue could be? Would really appreciate your guidance as I've been trying to figure this out for 3 days.

Here is my monitoring.py file: https://github.com/rileyhun/fastapi-ml-example/blob/main/app/core/monitoring.py

Reproducible example:

git clone https://github.com/rileyhun/fastapi-ml-example.git

docker build -t ${IMAGE_NAME}:${IMAGE_TAG} -f Dockerfile .
docker tag ${IMAGE_NAME}:${IMAGE_TAG} rhun/${IMAGE_NAME}:${IMAGE_TAG}
docker push rhun/${IMAGE_NAME}:${IMAGE_TAG}

minikube start --driver=docker --memory 4g --nodes 2
kubectl create namespace monitoring
helm install prometheus-stack prometheus-community/kube-prometheus-stack -n monitoring

kubectl apply -f deployment/wine-model-local.yaml
kubectl port-forward svc/wine-model-service 8080:80

python api_call.py
jeremyjordan commented 3 years ago

Hi Riley, I'm just now seeing this - glad you found the repo to be helpful! Were you able to figure out your issue?

rileyhun commented 3 years ago

Hi @jeremyjordan, yes - figured it out. Thank you very much for following up :)