Skip to main content
When an App exposes Prometheus metrics on Aptible, a traditional external Prometheus scraper usually cannot collect accurate per-container metrics. Aptible Containers are ephemeral and sit behind Endpoints, so an external scraper reaches the Endpoint instead of individual Containers. With multiple Containers, that can produce round-robin samples instead of a complete per-container view. Use a push-based collection pattern instead: each Container sends its metrics to a collector App running on Aptible, and that collector forwards metrics to your monitoring backend.
App Container -> Telegraf Collector App -> Monitoring Backend
This pattern works well with tools such as Telegraf because the collector can receive Prometheus-formatted metrics and forward them to an output destination like Datadog, InfluxDB, or another metrics backend.

Set Up Push-Based Collection

1

Deploy a metrics collector

Deploy a separate App in the same Environment to run Telegraf or another collector that can receive Prometheus-formatted metrics.
2

Configure the collector input

Configure Telegraf with the Prometheus listener input, such as [[inputs.prometheus_listener]], so it can receive metrics pushed by your app Containers.
3

Configure the collector output

Configure the output plugin for your monitoring backend, such as [[outputs.datadog]] for Datadog.
4

Push metrics from each app Container

Update your application to send its local Prometheus metrics endpoint to the collector on a regular interval.

Ruby Example

This example reads metrics from a local Prometheus endpoint and posts them to a Telegraf collector:
require "net/http"

Thread.new do
  loop do
    begin
      metrics = Net::HTTP.get(URI("http://0.0.0.0:9394/metrics"))
      Net::HTTP.post(
        URI("https://your-telegraf-app.aptible.in:9126/metrics"),
        metrics,
        { "Content-Type" => "text/plain" }
      )
    rescue => e
      puts "Metrics push failed: #{e.message}"
    end

    sleep 15
  end
end
For Ruby applications, the prometheus_exporter gem can help collect and format metrics before you push them to your collector.
Keep your push interval aligned with the retention and alerting needs of your monitoring backend. Shorter intervals improve visibility but increase network traffic and backend ingest volume.