dmc94
dmc94

Reputation: 536

How can I get metrics based on URL Path?

I have a flask API that handles ML models and I want to get metrics based on each model but the way we grab each model is based on the path. ex: https://api.someapi.com/cmd/<model-name> is it possible to grab metrics per model name? I was reading the docs and I guess we could hack something together with labels but that doesn't seem like the right solution. Has anyone run into this problem? I am using prometheus-flask-exporter.

Upvotes: 0

Views: 299

Answers (1)

DazWilkin
DazWilkin

Reputation: 40091

labels is always the right solution in Prometheus' to differentiate between otherwise identical metrics.

The "trick" is in identifying the unique metrics and the way to determine these is to ask "Will we ever want to (dynamically) query metrics by all or by some label values?". Corollary: what measurements of your models will you want to compare across models?

Without knowing more about your solution, you may have metrics corresponding to model invocations, failures etc. and you would differentiate between e.g. model invocations by applying at least one label.

In your case, perhaps a label key would be model_name and you'd use the path parameter <model-name> as the value.

It's unclear whether your paths are statically or dynamically generated but it makes no difference to the metrics and labels; just how you apply them.

Upvotes: 2

Related Questions