Membuat directory dengan nama prometheus
mkdir -p /monitoring-data/prometheus/prometheus-data mkdir -p /monitoring-data/prometheus/prometheus-config
Membuat file docker-compose.yml didalam folder prometheus
nano /monitoring-data/prometheus/docker-compose.yml
Adapun isi dari docker-compose.yml sebagai berikut :
version: '3.1' services: prometheus: # we will use grafana 4.6.2 image: prom/prometheus user: "1000:1000" volumes: - ./prometheus-config:/etc/prometheus - ./prometheus-data:/prometheus networks: - prometheus-net - traefik-net command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--storage.tsdb.retention=365d' - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' labels: - "traefik.enable=true" - "traefik.http.routers.prom.rule=Host(`prometheus.wachid.web.id`)" - "traefik.http.routers.prom.entrypoints=websecure" - "traefik.http.routers.prom.tls=true" - "traefik.http.routers.prom.tls.certresolver=myresolver" - "traefik.http.services.prom.loadbalancer.server.port=9090" networks: prometheus-net: name: prometheus-net external: true traefik-net: name: traefik-net external: true
Buat file konfigurasi untuk prometheus.yml didalam folder konfigurasi
nano /monitoring-data/prometheus/prometheus-config
Adapun isi dari file konfigurasinya sebagai berikut :
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: "prometheus" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ["localhost:9090"] - job_name: 'node_exporter' static_configs: - targets: ['node-exporter'] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: node-exporter:9100 # The real hostname:port. - job_name: 'cadvisor_exporter' static_configs: - targets: ['cadvisor'] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: cadvisor:8080 # The real hostname:port. - job_name: 'windows_exporter' static_configs: - targets: ['rpa-client'] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 149.xx.xx.xx:9182 # The real hostname:port.
Menjalankan docker cAdvisor dengan menjalankan perintah docker compose up -d . didalam directory prometheus
docker compose up -d .
Tampilan target monitoring prometheus