how to get client app events into prometheus

Viewed 638

We have a client apps running on ios and android phones. We are generating events that we currently send to intercom. We would like to have these events in prometheus.

Is there a quick solution to have them in prometheus, with examples online? If there is not a solution online, would it be a bad idea to add an endpoint clients call with the event and the server exposes it to prom scraper?

1 Answers

In order to let prometheus pull data from your app you have to use a client library from prometheus. There is a list of these organized by the programming language that you ca use https://prometheus.io/docs/instrumenting/clientlibs/ .

But if you don't want or you cannot let your application expose the events using those libraries you can push the events to Pushgateway and let Prometheus pull data from it. "The Pushgateway is an intermediary service which allows you to push metrics from jobs which cannot be scraped. For details, see Pushing metrics." From https://prometheus.io/docs/practices/pushing/

You can configure it on your prometheus.yml config file

scrape_configs:
  - job_name: 'pushgateway'
    scrape_interval: 10s
    honor_labels: true
    static_configs:
      - targets: ['127.0.0.1:9091']

And push metrics using curl or another rest api. Then you are going to see the metric in example some_metric 3.14 on your prometheus dashboard.

echo "some_metric 3.14" | curl --data-binary @- http://127.0.0.1:9091/metrics/job/some_job
Related