An Interest In:
Web News this Week
- April 29, 2024
- April 28, 2024
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
Docker Compose ile Prometheus Kurulumu
lgili makinede Docker ve Docker-Compose kurulu olduu varsaylarak anlatm gerekletirilmitir. Eer kurulu deilse, ilk adm olarak kurulumlarn gerekletirmeniz gerekmektedir. Bu kaynaktan yaralanlabilir.
1. Prometheus Nedir?
Prometheus, lm ve izleme sistemlerini bir araya getirmek iin kullanlan ak kaynakl bir aratr. Prometheus, hizmetlerin saln, performansn ve verimliliini izlemek iin birok lm ve gsterge toplar.
Ayrca, esnek ve leklenebilir bir yapya sahiptir ve HTTP zerinden metrikleri alabilir. Bir dier yazda bahsi geecek olan Grafana ile birlikte kullanlarak grselletirme ve raporlama iin kullanlabilir.
2. Konfigrasyon
Prometheus konfigrasyonu iin iki yaml dosyas oluturulur:
- prometheus/prometheus.yml
- docker-compose.yml
2.1 Konfigrasyon dosyas: prometheus/prometheus.yml
prometheus.yml dosyasnn konfigre edilebilmesi iin aadaki admlar izlenir.
- lk olarak u komut ile ana dizinde prometheus adl bir dosya oluturulur:
mkdir prometheus
- Ardndan bu dizine gidilir:
cd prometheus
- prometheus.yml dosyasnn iine girilir:
nano prometheus.yml
- Dosyann iine aadaki aadaki veriler girilir ve kaydedilip klr:
my global configglobal: scrape_interval: 15s # By default, scrape targets every 15 seconds. evaluation_interval: 15s # By default, scrape targets every 15 seconds. # scrape_timeout is set to the global default (10s). # Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: 'my-project'# Load and evaluate rules in this file every 'evaluation_interval' seconds.rule_files: - 'alert.rules' # - "first.rules" # - "second.rules"# alertalerting: alertmanagers: - scheme: http static_configs: - targets: - "alertmanager:9093"# 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' # Override the global default and scrape targets from this job every 5 seconds. scrape_interval: 15s static_configs: - targets: ['localhost:9090'] - job_name: 'cadvisor' # Override the global default and scrape targets from this job every 5 seconds. scrape_interval: 15s static_configs: - targets: ['cadvisor:8080'] - job_name: 'node-exporter' # Override the global default and scrape targets from this job every 5 seconds. scrape_interval: 15s static_configs: - targets: ['node-exporter:9100']
2.2 Docker Compose: docker-compose.yml
Prometheus'u balatabilmek adna aadaki admlar izlenir.
- lk olarak u komut ile ana dizine geilir:
cd ..
- Daha sonra docker-compose.yml dosyasnn iine girilir:
nano docker-compose.yml
- Dosyann iine aadaki aadaki veriler girilir ve kaydedilip klr:
version: '3.7'volumes: prometheus_data: {} grafana_data: {}networks: front-tier: back-tier:services: prometheus: image: prom/prometheus:v2.36.2 volumes: - ./prometheus/:/etc/prometheus/ - prometheus_data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--web.console.libraries=/usr/share/prometheus/console_libraries' - '--web.console.templates=/usr/share/prometheus/consoles' ports: - 9090:9090 links: - cadvisor:cadvisor - alertmanager:alertmanager depends_on: - cadvisor networks: - back-tier restart: always node-exporter: image: quay.io/prometheus/node-exporter:latest volumes: - /proc:/host/proc:ro - /sys:/host/sys:ro - /:/rootfs:ro - /:/host:ro,rslave command: - '--path.rootfs=/host' - '--path.procfs=/host/proc' - '--path.sysfs=/host/sys' - --collector.filesystem.ignored-mount-points - "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)" ports: - 9100:9100 networks: - back-tier restart: always deploy: mode: global alertmanager: image: prom/alertmanager ports: - 9093:9093 volumes: - ./alertmanager/:/etc/alertmanager/ networks: - back-tier restart: always command: - '--config.file=/etc/alertmanager/config.yml' - '--storage.path=/alertmanager' cadvisor: image: gcr.io/cadvisor/cadvisor volumes: - /:/rootfs:ro - /var/run:/var/run:rw - /sys:/sys:ro - /var/lib/docker/:/var/lib/docker:ro ports: - 8080:8080 networks: - back-tier restart: always deploy: mode: global grafana: image: grafana/grafana user: "472" depends_on: - prometheus ports: - 3000:3000 volumes: - grafana_data:/var/lib/grafana - ./grafana/provisioning/:/etc/grafana/provisioning/ env_file: - ./grafana/config.monitoring networks: - back-tier - front-tier restart: always
3. Prometheus Balat
- Son olarak u komut ile Prometheus balatlr:
docker-compose up -d
- Ardndan taraycya "http://IP:9090" girilir ve Prometheus arayzne eriilir:
IP: Prometheus kurulu olan makine'nin IP'si yazlr.
Original Link: https://dev.to/aciklab/docker-compose-ile-prometheus-kurulumu-5dpg
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To