mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-03 12:37:36 +08:00
feature: added check for openresty version and fixed style of documents. (#244)
This commit is contained in:
parent
ee8d8b89ad
commit
faeb07cadb
@ -1,3 +1,4 @@
|
||||
[中文](README_CN.md)
|
||||
## APISIX
|
||||
|
||||
[![Build Status](https://travis-ci.org/iresty/apisix.svg?branch=master)](https://travis-ci.org/iresty/apisix)
|
||||
@ -14,7 +15,6 @@ APISIX is a cloud-native microservices API gateway, delivering the ultimate perf
|
||||
|
||||
APISIX is based on OpenResty and etcd. Compared with traditional API gateways, APISIX has dynamic routing and plug-in hot loading, which is especially suitable for API management under micro-service system.
|
||||
|
||||
[中文简介](README_CN.md)
|
||||
|
||||
## Why APISIX?
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
[English](README.md)
|
||||
## APISIX
|
||||
|
||||
[![Build Status](https://travis-ci.org/iresty/apisix.svg?branch=master)](https://travis-ci.org/iresty/apisix)
|
||||
|
24
bin/apisix
24
bin/apisix
@ -248,6 +248,22 @@ local function read_yaml_conf()
|
||||
return yaml.parse(ymal_conf)
|
||||
end
|
||||
|
||||
local function checkOpenrestyVersion(need_version)
|
||||
local shell="need_ver="..need_version ..";"
|
||||
.."str=`openresty -v 2>&1`;"
|
||||
.."op_ver=${str##*/};"
|
||||
--.."echo \"op_ver:\"$op_ver;"
|
||||
.."max_ver=`echo \"${need_ver} ${op_ver}\" | tr \" \" \"\n\" | sort -rV | head -n 1`;"
|
||||
--.."echo \"max_ver:\"${max_ver};"
|
||||
.."if [ $max_ver != $need_ver ];then"
|
||||
.." echo 1;"
|
||||
.."else"
|
||||
.." echo 0;"
|
||||
.."fi"
|
||||
local ret = excute_cmd(shell)
|
||||
return trim(ret)=="1"
|
||||
end
|
||||
|
||||
local _M = {version = 0.1}
|
||||
|
||||
function _M.help()
|
||||
@ -339,6 +355,12 @@ function _M.start(...)
|
||||
init(...)
|
||||
init_etcd(...)
|
||||
|
||||
local need_version="1.15.8";
|
||||
if not checkOpenrestyVersion(need_version) then
|
||||
print("the openresty version must >=", need_version, "\n")
|
||||
return
|
||||
end
|
||||
|
||||
local cmd = openresty_args
|
||||
-- print(cmd)
|
||||
os.execute(cmd)
|
||||
@ -355,7 +377,7 @@ function _M.reload()
|
||||
if os.execute((test_cmd)) ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local cmd = openresty_args .. [[ -s reload]]
|
||||
-- print(cmd)
|
||||
os.execute(cmd)
|
||||
|
@ -1,3 +1,4 @@
|
||||
[English](benchmark.md)
|
||||
### 测试环境
|
||||
使用谷歌云的服务器进行测试,型号为 n1-highcpu-8 (8 vCPUs, 7.2 GB memory)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
[中文](benchmark-cn.md)
|
||||
### Benchmark Environments
|
||||
n1-highcpu-8 (8 vCPUs, 7.2 GB memory) on Google Cloud
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
[English](https.md)
|
||||
### HTTPS
|
||||
|
||||
`APISIX` 支持通过 TLS 扩展 SNI 实现加载特定的 SSL 证书以实现对 https 的支持。
|
||||
|
@ -1,3 +1,4 @@
|
||||
[中文](https-cn.md)
|
||||
### HTTPS
|
||||
|
||||
`APISIX` supports to load a specific SSL certificate by TLS extension Server Name Indication (SNI).
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
[English](plugins.md)
|
||||
## 插件
|
||||
目前已支持这些插件:
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
[中文](plugins-cn.md)
|
||||
## Plugins
|
||||
Now we support the following plugins:
|
||||
* [HTTPS](https.md): dynamic load the SSL Certificate by Server Name Indication (SNI).
|
||||
|
@ -1,4 +1,4 @@
|
||||
[中文](key-auth-cn.md) [英文](key-auth.md)
|
||||
[English](key-auth.md)
|
||||
|
||||
# 目录
|
||||
- [**名字**](#名字)
|
||||
|
@ -1,4 +1,4 @@
|
||||
[中文](key-auth-cn.md) [英文](key-auth.md)
|
||||
[中文](key-auth-cn.md)
|
||||
|
||||
# Summary
|
||||
- [**Name**](#name)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# limit-conn
|
||||
[English](limit-conn.md)
|
||||
# limit-conn
|
||||
|
||||
Apisix 的限制并发请求(或并发连接)插件。
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# limit-conn
|
||||
[中文](limit-conn-cn.md)
|
||||
# limit-conn
|
||||
|
||||
Limiting request concurrency (or concurrent connections) plugin for Apisix.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# limit-count
|
||||
[English](limit-count.md)
|
||||
# limit-count
|
||||
|
||||
和 [GitHub API 的限速](https://developer.github.com/v3/#rate-limiting)类似,
|
||||
在指定的时间范围内,限制总的请求个数。并且在 HTTP 响应头中返回剩余可以请求的个数。
|
||||
|
@ -1,5 +1,5 @@
|
||||
# limit-count
|
||||
[中文](limit-count-cn.md)
|
||||
# limit-count
|
||||
|
||||
### Parameters
|
||||
* `count`: is the specified number of requests threshold.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# limit-req
|
||||
[English](limit-req.md)
|
||||
# limit-req
|
||||
|
||||
限制请求速度的插件,使用的是漏桶算法。
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# limit-count
|
||||
[中文](limit-count-cn.md)
|
||||
# limit-count
|
||||
|
||||
limit request rate using the "leaky bucket" method.
|
||||
|
||||
|
98
doc/plugins/prometheus-cn.md
Normal file
98
doc/plugins/prometheus-cn.md
Normal file
@ -0,0 +1,98 @@
|
||||
[English](prometheus.md)
|
||||
# prometheus
|
||||
|
||||
此插件是提供符合prometheus数据格式的监控指标数据。
|
||||
|
||||
## 属性
|
||||
|
||||
无
|
||||
|
||||
## 如何开启插件
|
||||
|
||||
`prometheus` 插件用空{}就可以开启了,他没有任何的选项。
|
||||
|
||||
例子如下:
|
||||
|
||||
```shell
|
||||
curl http://127.0.0.1:9080/apisix/admin/routes/1 -X PUT -d '
|
||||
{
|
||||
"uri": "/hello",
|
||||
"plugins": {
|
||||
"prometheus":{}
|
||||
},
|
||||
"upstream": {
|
||||
"type": "roundrobin",
|
||||
"nodes": {
|
||||
"127.0.0.1:80": 1
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
## 如何提取指标数据
|
||||
|
||||
我们可以从指定的url中提取指标数据 `/apisix/prometheus/metrics`.
|
||||
|
||||
把改uri地址配置到 prometheus 中去,就会自动完成指标数据提取.
|
||||
|
||||
例子如下:
|
||||
|
||||
```yaml
|
||||
scrape_configs:
|
||||
- job_name: 'apisix'
|
||||
metrics_path: '/apisix/prometheus/metrics'
|
||||
static_configs:
|
||||
- targets: ['127.0.0.1:9080']
|
||||
```
|
||||
|
||||
我们也可以在 prometheus 控制台中去检查状态:
|
||||
|
||||
![](../../doc/images/plugin/prometheus01.png)
|
||||
|
||||
![](../../doc/images/plugin/prometheus02.png)
|
||||
|
||||
|
||||
### Grafana 面板
|
||||
|
||||
.插件导出的指标可以在 Grafana 进行图形化绘制显示。https://grafana.com/dashboards/7424
|
||||
|
||||
### 可有的指标
|
||||
|
||||
* `Status codes`: upstream 服务返回的 HTTP 状态码,每个服务返回状态码的次数或者所有服务的状态码次数总和都可以统计到。
|
||||
* `Bandwidth`: 流经apisix的总带宽(可分出口带宽和入口带宽). 每个服务指标或者是所有服务指标的总和都可以统计到。
|
||||
* `etcd reachability`: apisix 连接 etcd 的可用性,用 0 和 1来表示。
|
||||
* `Connections`: 各种的 Nginx 连接指标,如 active(正处理的活动连接数),reading(nginx 读取到客户端的 Header 信息数),writing(nginx 返回给客户端的 Header 信息数),已建立的连接数。.
|
||||
|
||||
这里是apisix的原始的指标数据集:
|
||||
|
||||
```
|
||||
$ curl http://127.0.0.2:9080/apisix/prometheus/metrics
|
||||
# HELP apisix_bandwidth Total bandwidth in bytes consumed per service in Apisix
|
||||
# TYPE apisix_bandwidth counter
|
||||
apisix_bandwidth{type="egress",service="127.0.0.2"} 183
|
||||
apisix_bandwidth{type="egress",service="bar.com"} 183
|
||||
apisix_bandwidth{type="egress",service="foo.com"} 2379
|
||||
apisix_bandwidth{type="ingress",service="127.0.0.2"} 83
|
||||
apisix_bandwidth{type="ingress",service="bar.com"} 76
|
||||
apisix_bandwidth{type="ingress",service="foo.com"} 988
|
||||
# HELP apisix_etcd_reachable Config server etcd reachable from Apisix, 0 is unreachable
|
||||
# TYPE apisix_etcd_reachable gauge
|
||||
apisix_etcd_reachable 1
|
||||
# HELP apisix_http_status HTTP status codes per service in Apisix
|
||||
# TYPE apisix_http_status counter
|
||||
apisix_http_status{code="200",service="127.0.0.2"} 1
|
||||
apisix_http_status{code="200",service="bar.com"} 1
|
||||
apisix_http_status{code="200",service="foo.com"} 13
|
||||
# HELP apisix_nginx_http_current_connections Number of HTTP connections
|
||||
# TYPE apisix_nginx_http_current_connections gauge
|
||||
apisix_nginx_http_current_connections{state="accepted"} 11994
|
||||
apisix_nginx_http_current_connections{state="active"} 2
|
||||
apisix_nginx_http_current_connections{state="handled"} 11994
|
||||
apisix_nginx_http_current_connections{state="reading"} 0
|
||||
apisix_nginx_http_current_connections{state="total"} 1191780
|
||||
apisix_nginx_http_current_connections{state="waiting"} 1
|
||||
apisix_nginx_http_current_connections{state="writing"} 1
|
||||
# HELP apisix_nginx_metric_errors_total Number of nginx-lua-prometheus errors
|
||||
# TYPE apisix_nginx_metric_errors_total counter
|
||||
apisix_nginx_metric_errors_total 0
|
||||
```
|
@ -1,9 +1,8 @@
|
||||
[中文](prometheus-cn.md)
|
||||
# prometheus
|
||||
|
||||
This plugin exposes metrics in Prometheus Exposition format.
|
||||
|
||||
<!-- [中文](prometheus-cn.md) [英文](prometheus.md) -->
|
||||
|
||||
## Attributes
|
||||
|
||||
none.
|
||||
@ -50,9 +49,9 @@ scrape_configs:
|
||||
|
||||
And we can check the status at prometheus console:
|
||||
|
||||
![](../../../doc/images/plugin/prometheus01.png)
|
||||
![](../../doc/images/plugin/prometheus01.png)
|
||||
|
||||
![](../../../doc/images/plugin/prometheus02.png)
|
||||
![](../../doc/images/plugin/prometheus02.png)
|
||||
|
||||
|
||||
### Grafana dashboard
|
||||
|
Loading…
Reference in New Issue
Block a user