-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhenmu.zyl
committed
Oct 22, 2018
1 parent
2550a4a
commit ac0279e
Showing
7 changed files
with
309 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
内容正在建设中 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
## 安装Prometheus Server | ||
|
||
Prometheus基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖。用户只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prometheus Server。 | ||
|
||
### 从二进制包安装 | ||
|
||
对于非Docker用户,可以从[https://prometheus.io/download/](https://prometheus.io/download/)找到最新版本的Prometheus Sevrer软件包: | ||
|
||
``` | ||
export VERSION=2.4.3 | ||
curl -LO https://github.com/prometheus/prometheus/releases/download/$VERSION/prometheus-$VERSION.darwin-amd64.tar.gz | ||
``` | ||
|
||
解压,并将Prometheus相关的命令,添加到系统环境变量路径即可: | ||
|
||
``` | ||
tar -xzf prometheus-${VERSION}.darwin-amd64.tar.gz | ||
cp prometheus-${VERSION}.darwin-amd64/prometheus /usr/local/bin/ | ||
cp prometheus-${VERSION}.darwin-amd64/promtool /usr/local/bin/ | ||
sudo mkdir -p /data/prometheus | ||
``` | ||
|
||
解压后当前目录会包含默认的Prometheus配置文件promethes.yml,拷贝配置文件到/etc/prometheus/prometheus.yml: | ||
|
||
``` | ||
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'] | ||
``` | ||
|
||
启动prometheus服务: | ||
|
||
``` | ||
prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus | ||
``` | ||
|
||
正常的情况下,你可以看到以下输出内容: | ||
|
||
``` | ||
msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml | ||
level=info ts=2018-03-11T13:38:06.317645234Z caller=main.go:486 msg="Server is ready to receive web requests." | ||
level=info ts=2018-03-11T13:38:06.317679086Z caller=manager.go:59 component="scrape manager" msg="Starting scrape manager..." | ||
``` | ||
|
||
### 使用容器安装 | ||
|
||
对于Docker用户,直接使用Prometheus的镜像即可启动Prometheus Server: | ||
|
||
``` | ||
docker run -p 9090:9090 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus | ||
``` | ||
|
||
启动完成后,可以通过[http://localhost:9090](http://localhost:9090)访问Prometheus的UI界面: | ||
|
||
![Prometheus UI](./static/prometheus-ui-graph.png) |
Oops, something went wrong.