Skip to main content

cAdvisor

cAdvisor (Container Advisor) is a container monitoring tool developed by Google that collects, aggregates, processes, and exports information about running containers. To send your Prometheus cAdvisor metrics to a Logz.io Infrastructure Monitoring account, use remote write to connect to Logz.io as the endpoint.

Before you begin

These are the prerequisites you’ll need before you can begin:

  • Docker and Docker Compose installed on your machine.
  • Logz.io account

Create a Prometheus configuration file

Navigate to your application directory or create a new one. In this directory, create a prometheus.yml file with the following content:

global:
scrape_interval: 15s
external_labels:
monitor: 'docker-monitor'

scrape_configs:
- job_name: 'cadvisor'
static_configs:
- targets: ['cadvisor:8080']

remote_write:
- url: "https://<<LISTENER-HOST>>:8053"
bearer_token: "<<PROMETHEUS-METRICS-SHIPPING-TOKEN>>"
remote_timeout: 30s
queue_config:
batch_send_deadline: 5s
max_shards: 10
min_shards: 1
max_samples_per_send: 500
capacity: 10000

Replace the placeholders to match your specifics. (They are indicated by the double angle brackets << >>):

  • Replace <<LISTENER-HOST>> with the Logz.io Listener URL for your region, configured to use port 8052 for http traffic, or port 8053 for https traffic. For example, listener.logz.io if your account is hosted on AWS US East, or listener-nl.logz.io if hosted on Azure West Europe.
  • Replace <<PROMETHEUS-METRICS-SHIPPING-TOKEN>> with a token for the Metrics account you want to ship to.
    Here's how to look up your Metrics token.

Create a Docker Compose file

In the same directory, create a docker-compose.yml file with the following content:

version: '3.7'

services:
prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- 9090:9090

cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
ports:
- 8080:8080

Run the setup

From your application directory, run:

docker-compose up -d

Verify the setup

To verify that your metrics are being sent correctly:

  1. Open your browser and go to http://localhost:9090 to access the Prometheus UI.
  2. In the Prometheus UI, run a query for prometheus_remote_storage_samples_in_total. You should see metrics if everything is set up correctly.

Check Logz.io for your metrics

Give your data some time to get from your system to ours, then log in to your Logz.io Metrics account, and open the Logz.io Metrics tab.