---
# System prepended metadata

title: 普羅米修斯筆記

---

# 普羅米修斯筆記

官方linux(內含教學):
[https://prometheus.io/docs/guides/cadvisor/](https://)

官方win:
下載win版本ZIP
https://prometheus.io/download/
解壓縮編寫文件prometheus.yml

啟動查看
```
prometheus.exe --config.file=prometheus.yml
```
前往 http://localhost:9090

我的docker與html:
```
FROM nginx:latest

COPY index.html /usr/share/nginx/html

EXPOSE 80
```
```
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Docker 網頁</title>
</head>

<body>
    <h1>Docker 網頁</h1>
    <p>這是一個簡單的 Docker 網頁，可以用 Prometheus 進行監控。</p>
</body>

</html>
```
我的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).

# 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: "docker-web-app"
    static_configs:
      - targets: ["host.docker.internal:8080"]  # 使用 host.docker.internal 來訪問主機上的容器
```scrape_configs:
  - job_name: "dockerfile"

    # 指定 Dockerfile 容器的 IP 地址或主機名。
    static_configs:
      - targets: ["<dockerfile_container_ip_address>:80"]
