> For the complete documentation index, see [llms.txt](https://ilinux.gitbook.io/prometheus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ilinux.gitbook.io/prometheus/prometheusmaster-bu-shu.md).

# Prometheus-Master

**新建Prometheus持久化目录及文件**

```
mkdir /etc/prometheus/{configs,rules} -p
vim /etc/prometheus/prometheus.yml
```

```
global:
  scrape_interval:     15s
  evaluation_interval: 15s
alerting:
  alertmanagers:
  - static_configs:
    - targets:
       - 127.0.0.1:9093
rule_files:
  - "rules/*.yml"
scrape_configs:
  - job_name: '卡片联邦监控'
    honor_labels: true
    metrics_path: '/federate'
    params:
      'match[]':
        - '{job="国内"}'
        - '{job="海外"}'
    static_configs:
    - targets: ['IP:9090']
    - targets: ['IP:9090']
```

**Docker运行Prometheus**

```
docker run   --name prometheus   -d -p 9090:9090   -v /etc/hosts:/etc/hosts   -v /etc/prometheus/:/etc/prometheus/   prom/prometheus   --web.read-timeout=5m   --config.file=/etc/prometheus/prometheus.yml   --storage.tsdb.path=/prometheus   --web.max-connections=512   --storage.tsdb.retention=30d   --query.timeout=2m  --web.enable-lifecycle
```
