BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
feb94e8e
Commit
feb94e8e
authored
Aug 01, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move timeframe_start and timeframe_end to common query context
parent
b243c3ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
14 deletions
+8
-14
additional_metrics_deployment_query.rb
...prometheus/queries/additional_metrics_deployment_query.rb
+4
-5
additional_metrics_environment_query.rb
...rometheus/queries/additional_metrics_environment_query.rb
+1
-8
query_additional_metrics.rb
lib/gitlab/prometheus/queries/query_additional_metrics.rb
+3
-1
No files found.
lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
View file @
feb94e8e
...
...
@@ -6,14 +6,13 @@ module Gitlab
def
query
(
deployment_id
)
Deployment
.
find_by
(
id:
deployment_id
).
try
do
|
deployment
|
query_context
=
common_query_context
(
deployment
.
environment
).
merge
(
{
query_metrics
(
common_query_context
(
deployment
.
environment
,
timeframe_start:
(
deployment
.
created_at
-
30
.
minutes
).
to_f
,
timeframe_end:
(
deployment
.
created_at
+
30
.
minutes
).
to_f
}
)
)
query_metrics
(
query_context
)
end
end
end
...
...
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
View file @
feb94e8e
...
...
@@ -6,14 +6,7 @@ module Gitlab
def
query
(
environment_id
)
Environment
.
find_by
(
id:
environment_id
).
try
do
|
environment
|
query_context
=
common_query_context
(
environment
).
merge
(
{
timeframe_start:
8
.
hours
.
ago
.
to_f
,
timeframe_end:
Time
.
now
.
to_f
}
)
query_metrics
(
query_context
)
query_metrics
(
common_query_context
(
environment
))
end
end
end
...
...
lib/gitlab/prometheus/queries/query_additional_metrics.rb
View file @
feb94e8e
...
...
@@ -71,8 +71,10 @@ module Gitlab
result
.
select
{
|
group
|
group
.
metrics
.
any?
}
end
def
common_query_context
(
environment
)
def
common_query_context
(
environment
,
timeframe_start:
8
.
hours
.
ago
.
to_f
,
timeframe_end:
Time
.
now
.
to_f
)
{
timeframe_start:
timeframe_start
,
timeframe_end:
timeframe_end
,
ci_environment_slug:
environment
.
slug
,
kube_namespace:
environment
.
project
.
kubernetes_service
&
.
actual_namespace
||
''
,
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment