docker 瀹夎prometheus鍜実rafna

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker 瀹夎prometheus鍜実rafna相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/run' title='run'>run   ase   name   ica   points   rem   roc   comm   sudo   

涓€銆佹媺鍙栭暅鍍?/p>

docker pull prom/prometheus

浜屻€侀厤缃?/p>

sudo mkdir /etc/prometheus/
sudo vim /etc/prometheus/prometheus.yml

娣诲姞鐩戞帶鑺傜偣

# 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).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
      monitor: 鈥榗odelab-monitor鈥?span style="color: #000000;">

# Load rules once and periodically evaluate them according to the global 鈥榚valuation_interval鈥?span style="color: #000000;">.
rule_files:
  # - "first.rules"
  # - "second.rules"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it鈥榮 Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 鈥榩rometheus鈥?span style="color: #000000;">

    # metrics_path defaults to 鈥?metrics鈥?span style="color: #000000;">
    # scheme defaults to 鈥榟ttp鈥?span style="color: #000000;">.

    static_configs:
      - targets: [鈥?72.17.0.1:9090鈥?span style="color: #000000;">]

  - job_name: 鈥榤ysql鈥?span style="color: #000000;">
    static_configs:
      - targets: [鈥?72.17.0.1:9104鈥?span style="color: #000000;">]
        labels:
          instance: mysql

  - job_name: 鈥榤onitor鈥?span style="color: #000000;">
    static_configs:
      - targets: [鈥?72.17.0.1:9100鈥?span style="color: #000000;">]
        labels:
          instance: monitor

鍚姩prometheus

# 鍥犱负鐩綍/data鐢ㄦ埛缁勫拰鐢ㄦ埛鏄痡tserver锛宒ocker鎵ц鍛戒护鏄痳oot鐢ㄦ埛锛屽厛灏?data/lib/prometheus缁欏叾浠栫粍鏉冮檺鎵嶈兘鎵ц
sudo mkdir /data/lib/prometheus
sudo chmod 767 /data/lib/prometheus

docker run -d   -p 9090:9090   --restart=always   --name prometheus   -v /data/lib/prometheus:/data/lib/prometheus   -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml   prom/prometheus   --config.file=/etc/prometheus/prometheus.yml   --storage.tsdb.path=/data/lib/prometheus

涓夈€佹媺鍙杗ode-exporter

docker pull prom/node-exporter

鍚姩

docker run -d   -v "/proc:/host/proc:ro"   -v "/sys:/host/sys:ro"   -v "/:/rootfs:ro"   --net="host"   --restart=always   prom/node-exporter   --path.procfs /host/proc   --path.sysfs /host/sys   --collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"

鍥涖€乬rafana

sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_6.7.2_amd64.deb
sudo dpkg -i grafana_6.7.2_amd64.deb

sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
# echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list 
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

sudo apt-get update
sudo apt-get install grafana
sudo update-rc.d grafana-server defaults

 

以上是关于docker 瀹夎prometheus鍜実rafna的主要内容,如果未能解决你的问题,请参考以下文章

Docker CE瀹夎

云原生之Docker实战使用Docker部署Prometheus 服务监控系统

Prometheus - Docker/JVM 监控

无法使用 docker (prom/prometheus) 加载 prometheus.yml 配置文件

基于docker部署prometheus+grafana

监控 - Prometheus让Docker指标可视化