Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
bf8706a62c87
Commit
feb94e8e
authored
Aug 01, 2017
by
Pawel Chojnacki
Browse files
Move timeframe_start and timeframe_end to common query context
parent
cceec81bd44f
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
View file @
bf8706a6
...
...
@@ -6,14 +6,13 @@ class AdditionalMetricsDeploymentQuery < BaseQuery
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 @
bf8706a6
...
...
@@ -6,14 +6,7 @@ class AdditionalMetricsEnvironmentQuery < BaseQuery
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 @
bf8706a6
...
...
@@ -71,8 +71,10 @@ def matched_metrics
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