Hello,
I am building a Django application and I have configured web and worker process in the same Fly application. Following the metrics documentation, I set up custom prometheus metrics on the “/m/metrics” path of my application. I configured the metrics section of the fly.toml file as follows
[metrics]
port = 8000
path = "/m/metrics"
When I access the HTTP route, I can see the prometheus response.
But when I want to request the prometheus metrics via the Fly api using the following script, I see nothing
import httpx
import os
# Configuration
FLY_API_TOKEN = os.getenv("FLY_API_TOKEN") # I use a personal read only token created with the command "fly tokens create readonly my-org"
ORG_SLUG = "XXX"
BASE_URL = f"https://api.fly.io/prometheus/{ORG_SLUG}"
# Get the size of the queue
query = 'dramatiq_queue_messages{queue="default",app="XXX"}'
# query = 'query=sum(increase(fly_edge_http_responses_count))'
headers = {
"Authorization": FLY_API_TOKEN
}
with httpx.Client(base_url=BASE_URL, headers=headers) as client:
response = client.get("/api/v1/query", params={"query": query})
data = response.json()
print(data)
if data["status"] == "success" and data["data"]["result"]:
queue_size = data["data"]["result"][0]["value"][1]
print(f"Size of the 'default' queue: {queue_size}")
else:
print("Nothing found")
Here is the response
{'status': 'success', 'isPartial': False, 'data': {'resultType': 'vector', 'result': []}, 'stats': {'seriesFetched': '0', 'executionTimeMsec': 14}}
Nothing found
Does anyone have any idea what the potential issue I’m facing might be?