Application objects counter

I have a Rust Actix web application.
I integrated Prometheus successfully with this application.
Now I need to count the number of objects within my application ex: the number of Posts.
What steps and tools do I need to achieve that?

What needs to be done specifically depends a lot on the implementation details. But in general terms you should have some sort of registry where you register and then update your metrics. For example, you can take a look at the prometheus-client crate.

Then in order to expose the metrics so that prometheus can ingest them you will have to create an endpoint in your application. Traditionally, the /metrics endpoint would be used. This endpoint would serialize and encode the metrics contained in the registry into a format that can be ingested by prometheus (it can be prometheus format or Open Metrics format).

Finally, you need to configure your prometheus server to scrape your web application’s /metric endpoint at recurring intervals.

I don’t know how helpful that is, but that is the big picture. If you want more info on the specifics on certain parts, let’s follow up.