Open-sourcing Pushprom: our solution to Prometheus data retrieval issues

Sam Wierema
MessageBird
Published in
2 min readAug 25, 2016

We created a proxy to solve the data retrieval issues we encountered upon integrating Prometheus into our monitoring setup.

A few months ago we decided to improve our monitoring setup at MessageBird. We surveyed what was available on the market and decided on Prometheus. It has a great querying language, it scales well, it’s easy to set up, it comes with great tools, and it’s written in Go (which we love and use). But, we quickly ran into a problem: we couldn’t easily retrieve data from some of our services.

The idea behind Prometheus is that data from services is collected through polling. This requires any service that wants to be polled to keep state somehow. Many of our services are written in PHP and served with nginx. This setup, by nature, doesn’t allow state to be shared between requests easily. We tried to solve this problem in various ways (store counters in memcache, shared memory, nginx plugins), but they were all either too complicated or too slow for our purposes. So, we decided to create a service of our own. Enter: Pushprom.

Pushprom is a proxy to the Prometheus Go client. It allows services to send their monitoring data (in JSON format) over HTTP or UDP, which is then aggregated and exposed for Prometheus to collect. Here’s an example:

When you send the above data to Pushprom it will try to create a metric with type ‘Gauge’ named ‘trees’ and then apply the operation ‘add’ with value ‘3002’ on it. This new metric immediately shows up in the metrics endpoint and (if set up correctly) shows up in Prometheus shortly after. Great! We can now “push” to Prometheus from our services if needed, ensuring we can start using Prometheus across our entire stack.

With all that said, today we’re excited to announce that we are open-sourcing Pushprom! We’ve heard from many other people working with Prometheus that its poll-based model made it difficult to work with. Hopefully Pushprom can help!

Alongside Pushprom, we’re open-sourcing a PHP client, as well as a Yii 2-specific implementation. Both are easy to use and they’re available through the Composer package manager for easy installation. To send the same data as before with PHP, just do the following:

We’re happily using both clients in production today and couldn’t be more pleased with the performance. Feel free to try it out for yourself if you’re experiencing similar issues!

You can check out the code on our Github page now. We’d love to hear what you think.

--

--

Sam Wierema
MessageBird

Platform Evangelist at MessageBird. Organiser of events (IPAs & APIs, DevRel Amsterdam). Formerly CTO at The Next Web.