Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
ae4af055
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ae4af055
编写于
3月 28, 2017
作者:
J
Joshua Lambert
提交者:
Rémy Coutable
3月 28, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support wider range of monitored environments with Prometheus
上级
ad831ace
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
7 addition
and
7 deletion
+7
-7
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+3
-3
doc/user/project/integrations/prometheus.md
doc/user/project/integrations/prometheus.md
+2
-2
spec/support/prometheus_helpers.rb
spec/support/prometheus_helpers.rb
+2
-2
未找到文件。
app/models/project_services/prometheus_service.rb
浏览文件 @
ae4af055
...
...
@@ -31,7 +31,7 @@ class PrometheusService < MonitoringService
def
help
<<-
MD
.
strip_heredoc
Retrieves the Kubernetes node metrics `container_cpu_usage_seconds_total`
Retrieves the Kubernetes node metrics `container_cpu_usage_seconds_total`
and `container_memory_usage_bytes` from the configured Prometheus server.
If you are not using [Auto-Deploy](https://docs.gitlab.com/ee/ci/autodeploy/index.html)
...
...
@@ -74,8 +74,8 @@ class PrometheusService < MonitoringService
def
calculate_reactive_cache
(
environment_slug
)
return
unless
active?
&&
project
&&
!
project
.
pending_delete?
memory_query
=
%{(sum(container_memory_usage_bytes{container_name
="app",environment="#{environment_slug}"}) / count(container_memory_usage_bytes{container_name="app
",environment="#{environment_slug}"})) /1024/1024}
cpu_query
=
%{sum(rate(container_cpu_usage_seconds_total{container_name
="app",environment="#{environment_slug}"}[2m])) / count(container_cpu_usage_seconds_total{container_name="app
",environment="#{environment_slug}"}) * 100}
memory_query
=
%{(sum(container_memory_usage_bytes{container_name
!="POD",environment="#{environment_slug}"}) / count(container_memory_usage_bytes{container_name!="POD
",environment="#{environment_slug}"})) /1024/1024}
cpu_query
=
%{sum(rate(container_cpu_usage_seconds_total{container_name
!="POD",environment="#{environment_slug}"}[2m])) / count(container_cpu_usage_seconds_total{container_name!="POD
",environment="#{environment_slug}"}) * 100}
{
success:
true
,
...
...
doc/user/project/integrations/prometheus.md
浏览文件 @
ae4af055
...
...
@@ -153,8 +153,8 @@ The queries utilized by GitLab are shown in the following table.
| Metric | Query |
| ------ | ----- |
| Average Memory (MB) |
`(sum(container_memory_usage_bytes{container_name
="app",environment="$CI_ENVIRONMENT_SLUG"}) / count(container_memory_usage_bytes{container_name="app
",environment="$CI_ENVIRONMENT_SLUG"})) /1024/1024`
|
| Average CPU Utilization (%) |
`sum(rate(container_cpu_usage_seconds_total{container_name
="app",environment="$CI_ENVIRONMENT_SLUG"}[2m])) / count(container_cpu_usage_seconds_total{container_name="app
",environment="$CI_ENVIRONMENT_SLUG"}) * 100`
|
| Average Memory (MB) |
`(sum(container_memory_usage_bytes{container_name
!="POD",environment="$CI_ENVIRONMENT_SLUG"}) / count(container_memory_usage_bytes{container_name!="POD
",environment="$CI_ENVIRONMENT_SLUG"})) /1024/1024`
|
| Average CPU Utilization (%) |
`sum(rate(container_cpu_usage_seconds_total{container_name
!="POD",environment="$CI_ENVIRONMENT_SLUG"}[2m])) / count(container_cpu_usage_seconds_total{container_name!="POD
",environment="$CI_ENVIRONMENT_SLUG"}) * 100`
|
## Monitoring CI/CD Environments
...
...
spec/support/prometheus_helpers.rb
浏览文件 @
ae4af055
module
PrometheusHelpers
def
prometheus_memory_query
(
environment_slug
)
%{(sum(container_memory_usage_bytes{container_name
="app",environment="#{environment_slug}"}) / count(container_memory_usage_bytes{container_name="app
",environment="#{environment_slug}"})) /1024/1024}
%{(sum(container_memory_usage_bytes{container_name
!="POD",environment="#{environment_slug}"}) / count(container_memory_usage_bytes{container_name!="POD
",environment="#{environment_slug}"})) /1024/1024}
end
def
prometheus_cpu_query
(
environment_slug
)
%{sum(rate(container_cpu_usage_seconds_total{container_name
="app",environment="#{environment_slug}"}[2m])) / count(container_cpu_usage_seconds_total{container_name="app
",environment="#{environment_slug}"}) * 100}
%{sum(rate(container_cpu_usage_seconds_total{container_name
!="POD",environment="#{environment_slug}"}[2m])) / count(container_cpu_usage_seconds_total{container_name!="POD
",environment="#{environment_slug}"}) * 100}
end
def
prometheus_query_url
(
prometheus_query
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录