Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
14 deletions
+8
-14
lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
...prometheus/queries/additional_metrics_deployment_query.rb
+4
-5
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
...rometheus/queries/additional_metrics_environment_query.rb
+1
-8
lib/gitlab/prometheus/queries/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
...
@@ -6,14 +6,13 @@ module Gitlab
def
query
(
deployment_id
)
def
query
(
deployment_id
)
Deployment
.
find_by
(
id:
deployment_id
).
try
do
|
deployment
|
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_start:
(
deployment
.
created_at
-
30
.
minutes
).
to_f
,
timeframe_end:
(
deployment
.
created_at
+
30
.
minutes
).
to_f
timeframe_end:
(
deployment
.
created_at
+
30
.
minutes
).
to_f
}
)
)
)
query_metrics
(
query_context
)
end
end
end
end
end
end
...
...
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
View file @
feb94e8e
...
@@ -6,14 +6,7 @@ module Gitlab
...
@@ -6,14 +6,7 @@ module Gitlab
def
query
(
environment_id
)
def
query
(
environment_id
)
Environment
.
find_by
(
id:
environment_id
).
try
do
|
environment
|
Environment
.
find_by
(
id:
environment_id
).
try
do
|
environment
|
query_context
=
common_query_context
(
environment
).
merge
(
query_metrics
(
common_query_context
(
environment
))
{
timeframe_start:
8
.
hours
.
ago
.
to_f
,
timeframe_end:
Time
.
now
.
to_f
}
)
query_metrics
(
query_context
)
end
end
end
end
end
end
...
...
lib/gitlab/prometheus/queries/query_additional_metrics.rb
View file @
feb94e8e
...
@@ -71,8 +71,10 @@ module Gitlab
...
@@ -71,8 +71,10 @@ module Gitlab
result
.
select
{
|
group
|
group
.
metrics
.
any?
}
result
.
select
{
|
group
|
group
.
metrics
.
any?
}
end
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
,
ci_environment_slug:
environment
.
slug
,
kube_namespace:
environment
.
project
.
kubernetes_service
&
.
actual_namespace
||
''
,
kube_namespace:
environment
.
project
.
kubernetes_service
&
.
actual_namespace
||
''
,
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
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