Skip to content

Commit

Permalink
move static resources to local
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenmu.zyl committed Oct 21, 2018
1 parent 69a2446 commit 02a57e8
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 19 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Prometheus操作指南:云原生监控之道
* [自定义Prometheus告警规则](./alert/prometheus-alert-rule.md)
* [部署AlertManager](./alert/install-alert-manager.md)
* [基于Label的动态告警处理](./alert/alert-manager-routes.md)
* [内置告警接收器Receiver](./alert/alert-manager-with-smtp.md)
* [使用内置告警接收器Receiver](./alert/alert-manager-with-smtp.md)
* [使用Webhook扩展Alertmanager](./alert/alert-manager-extension-with-webhook.md)
* [屏蔽告警通知](./alert/alert-manager-inhibit.md)
* [使用Recoding Rules优化性能](./alert/prometheus-recoding-rules.md)
* 通知模板详解
* [小结](./alert/SUMMARY.md)

## Part II - Prometheus进阶
Expand Down
8 changes: 8 additions & 0 deletions alert/alert-manager-with-smtp.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ receivers:

![告警](http://p2n2em8ut.bkt.clouddn.com/mail-alert-page.png)

## 与Slack集成

> TODO
## 与微信集成

>
## 自定义模板

默认情况下Alertmanager使用了系统自带的默认通知模板,模板源码可以从[https://github.com/prometheus/alertmanager/blob/master/template/default.tmpl](https://github.com/prometheus/alertmanager/blob/master/template/default.tmpl)获得。Alertmanager的通知模板基于[Go的模板系统](http://golang.org/pkg/text/template)。Alertmanager也支持用户定义和使用自己的模板,一般来说有两种方式可以选择。
Expand Down
28 changes: 14 additions & 14 deletions quickstart/prometheus-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ level=info ts=2018-03-11T13:38:06.317679086Z caller=manager.go:59 component="scr

启动完成后,可以通过[http://localhost:9090](http://localhost:9090)访问Prometheus的UI界面。

![Prometheus UI](http://p2n2em8ut.bkt.clouddn.com/prometheus-ui-graph.png)
![Prometheus UI](./static/prometheus-ui-graph.png)

##### 运行node exporter

Expand Down Expand Up @@ -117,13 +117,13 @@ INFO[0000] Listening on :9100 source="node_exporter.g

访问[http://localhost:9100/](http://localhost:9100/)可以看到以下页面:

![node exporter页面](http://p2n2em8ut.bkt.clouddn.com/node_exporter_home_page.png)
![node exporter页面](./static/node_exporter_home_page.png)

## Node Exporter监控指标

访问[http://localhost:9100/metrics](http://localhost:9100/metrics),可以看到当前node exporter获取到的当前主机的所有监控数据,如下所示:

![主机监控指标](http://p2n2em8ut.bkt.clouddn.com/node_exporter_metrics_page.png)
![主机监控指标](./static/node_exporter_metrics_page.png)

每一个监控指标之前都会有一段类似于如下形式的信息:

Expand Down Expand Up @@ -168,7 +168,7 @@ scrape_configs:

访问[http://localhost:9090](http://localhost:9090),进入到Prometheus Server。如果输入“up”并且点击执行按钮以后,可以看到如下结果:

![Expression Browser](http://p2n2em8ut.bkt.clouddn.com/prometheus_ui_up_query.png)
![Expression Browser](./static/prometheus_ui_up_query.png)

如果Prometheus能够正常从node exporter获取数据,则会看到以下结果:

Expand All @@ -185,39 +185,39 @@ up{instance="localhost:9100",job="node"} 1

通过Prometheus UI用户可以利用PromQL实时查询监控数据,并且支持一些基本的数据可视化能力。进入到Prometheus UI,切换到Graph标签

![Graph Query](http://p2n2em8ut.bkt.clouddn.com/prometheus_ui_graph_query.png)
![Graph Query](./static/prometheus_ui_graph_query.png)

通过PromQL则可以直接以可视化的形式显示查询到的数据。例如,查询主机负载变化情况,可以使用:

```
node_load1
```

![主机负载情况](http://p2n2em8ut.bkt.clouddn.com/node_node1_graph.png)
![主机负载情况](./static/node_node1_graph.png)

查询主机CPU的使用率,由于node_cpu的数据类型是Counter,计算使用率需要使用rate()函数:

```
rate(node_cpu[2m])
```

![系统进程的CPU使用率](http://p2n2em8ut.bkt.clouddn.com/node_cpu_usage_by_cpu_and_mode.png)
![系统进程的CPU使用率](./static/node_cpu_usage_by_cpu_and_mode.png)

这时如果要忽略是哪一个CPU的,只需要使用without表达式,将标签CPU去除后聚合数据即可:

```
avg without(cpu) (rate(node_cpu[2m]))
```

![系统各mode的CPU使用率](http://p2n2em8ut.bkt.clouddn.com/node_cpu_usage_by_mode.png)
![系统各mode的CPU使用率](./static/node_cpu_usage_by_mode.png)

那如果需要计算系统CPU的总体使用率,通过排除系统闲置的CPU使用率即可获得:

```
1 - avg without(cpu) (rate(node_cpu{mode="idle"}[2m]))
```

![系统CPU使用率](http://p2n2em8ut.bkt.clouddn.com/node_cpu_usage_total.png)
![系统CPU使用率](./static/node_cpu_usage_total.png)

从上面这些例子中可以看出,根据样本中的标签可以很方便地对数据进行查询,过滤以及聚合等操作。同时PromQL中还提供了大量的诸如rate()这样的函数可以实现对数据的更多个性化的处理。

Expand All @@ -231,20 +231,20 @@ docker run -d -p 3000:3000 grafana/grafana

访问[http://localhost:3000](http://localhost:3000)就可以进入到Grafana的界面中,默认情况下使用账户admin/admin进行登录。在Grafana首页中显示默认的使用向导,包括:安装、添加数据源、创建Dashboard、邀请成员、以及安装应用和插件等主要流程:

![Grafana向导](http://p2n2em8ut.bkt.clouddn.com/get_start_with_grafana2.png)
![Grafana向导](./static/get_start_with_grafana2.png)

这里将添加Prometheus作为默认的数据源,如下图所示,指定数据源类型为Prometheus并且设置Prometheus的访问地址即可,在配置正确的情况下点击“Add”按钮,会提示连接成功的信息:

![添加Prometheus作为数据源](http://p2n2em8ut.bkt.clouddn.com/add_default_prometheus_datasource.png)
![添加Prometheus作为数据源](./static/add_default_prometheus_datasource.png)

在完成数据源的添加之后就可以在Grafana中创建我们可视化Dashboard了。Grafana提供了对PromQL的完整支持,如下所示,通过Grafana添加Dashboard并且为该Dashboard添加一个类型为“Graph”的面板。 并在该面板的“Metrics”选项下通过PromQL查询需要可视化的数据:

![第一个可视化面板](http://p2n2em8ut.bkt.clouddn.com/first_grafana_dashboard.png)
![第一个可视化面板](./static/first_grafana_dashboard.png)

点击界面中的保存选项,就创建了我们的第一个可视化Dashboard了。 当然作为开源软件,Grafana社区鼓励用户分享Dashboard通过[https://grafana.com/dashboards](https://grafana.com/dashboards)网站,可以找到大量可直接使用的Dashboard:

![用户共享的Dashboard](http://p2n2em8ut.bkt.clouddn.com/grafana_dashboards.png)
![用户共享的Dashboard](./static/grafana_dashboards.png)

Grafana中所有的Dashboard通过JSON进行共享,下载并且导入这些JSON文件,就可以直接使用这些已经定义好的Dashboard:

![Host Stats Dashboard](http://p2n2em8ut.bkt.clouddn.com/node_exporter_dashboard.png)
![Host Stats Dashboard](./static/node_exporter_dashboard.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/first_grafana_dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/get_start_with_grafana2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added quickstart/static/image049.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/nagios-platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/node_cpu_usage_by_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/node_cpu_usage_total.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/node_exporter_dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/node_exporter_home_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/node_exporter_metrics_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/node_node1_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/prometheus-ui-graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/prometheus_ui_graph_query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/prometheus_ui_up_query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quickstart/static/pullvspush.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions quickstart/why-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Prometheus受启发于Google的Brogmon监控系统(相似的Kubernetes是从Google的Brog系统演变而来),从2012年开始由前Google工程师在Soundcloud以开源软件的形式进行研发,并且于2015年早期对外发布早期版本。2016年5月继Kubernetes之后成为第二个正式加入CNCF基金会的项目,同年6月正式发布1.0版本。2017年底发布了基于全新存储层的2.0版本,能更好地与容器平台、云平台配合。

![Prometheus简史](http://p2n2em8ut.bkt.clouddn.com/prometheus-release-roadmaps.png)
![Prometheus简史](./static/prometheus-release-roadmaps.png)

Prometheus作为新一代的云原生监控系统,目前已经有超过650+位贡献者参与到Prometheus的研发工作上,并且超过120+项的第三方集成。

Expand All @@ -20,11 +20,11 @@ Prometheus作为新一代的云原生监控系统,目前已经有超过650+位

对于常用的监控系统,如Nagios、Zabbix的用户而言,往往并不能很好的解决上述问题。这里以Nagios为例,如下图所示是Nagios监控系统的基本架构:

![Nagios监控系统](http://p2n2em8ut.bkt.clouddn.com/nagios-platform.png)
![Nagios监控系统](./static/nagios-platform.png)

Nagios的主要功能是监控服务和主机。Nagios软件需要安装在一台独立的服务器上运行,该服务器称为监控中心。每一台被监控的硬件主机或者服务都需要运行一个与监控中心服务器进行通信的Nagios软件后台程序,可以理解为Agent或者插件。

![Nagios主机监控页面](https://www.ibm.com/developerworks/cn/linux/1309_luojun_nagios/image049.jpg)
![Nagios主机监控页面](./static/image049.jpg)

首先对于Nagios而言,大部分的监控能力都是围绕系统的一些边缘性的问题,主要针对系统服务和资源的状态以及应用程序的可用性。 例如:Nagios通过check_disk插件可以用于检查磁盘空间,check_load用于检查CPU负载等。这些插件会返回4种Nagios可识别的状态,0(OK)表示正常,1(WARNING)表示警告,2(CRITTCAL)表示错误,3(UNKNOWN)表示未知错误,并通过Web UI显示出来。

Expand All @@ -49,7 +49,7 @@ Prometheus基于Pull模型的架构方式,可以在任何地方(本地电脑

Pometheus鼓励用户监控服务的内部状态,基于Prometheus丰富的Client库,用户可以轻松的在应用程序中添加对Prometheus的支持,从而让用户可以获取服务和应用内部真正的运行状态。

![监控服务内部运行状态](http://p2n2em8ut.bkt.clouddn.com/pull%20vspush.png)
![监控服务内部运行状态](./static/pullvspush.png)

##### 强大的数据模型

Expand Down

0 comments on commit 02a57e8

Please sign in to comment.