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
ce83e563
Commit
ce83e563
authored
Jul 28, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add kube_namespace and standardize common variables for additional metrics queries
parent
0d52e59d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
12 deletions
+24
-12
lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
...prometheus/queries/additional_metrics_deployment_query.rb
+6
-6
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
...rometheus/queries/additional_metrics_environment_query.rb
+6
-6
lib/gitlab/prometheus/queries/query_additional_metrics.rb
lib/gitlab/prometheus/queries/query_additional_metrics.rb
+12
-0
No files found.
lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
View file @
ce83e563
...
...
@@ -6,12 +6,12 @@ module Gitlab
def
query
(
deployment_id
)
Deployment
.
find_by
(
id:
deployment_id
).
try
do
|
deployment
|
query_context
=
{
environment_slug:
deployment
.
environment
.
slug
,
environment_filter:
%{container_name!="POD",environment="#{deployment.environment.slug}"}
,
query_context
=
common_query_context
(
deployment
.
environment
).
merge
(
{
timeframe_start:
(
deployment
.
created_at
-
30
.
minutes
).
to_f
,
timeframe_end:
(
deployment
.
created_at
+
30
.
minutes
).
to_f
}
)
query_metrics
(
query_context
)
end
...
...
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
View file @
ce83e563
...
...
@@ -6,12 +6,12 @@ module Gitlab
def
query
(
environment_id
)
Environment
.
find_by
(
id:
environment_id
).
try
do
|
environment
|
query_context
=
{
environment_slug:
environment
.
slug
,
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
,
query_context
=
common_query_context
(
environment
).
merge
(
{
timeframe_start:
8
.
hours
.
ago
.
to_f
,
timeframe_end:
Time
.
now
.
to_f
}
)
query_metrics
(
query_context
)
end
...
...
lib/gitlab/prometheus/queries/query_additional_metrics.rb
View file @
ce83e563
...
...
@@ -67,6 +67,18 @@ module Gitlab
result
.
select
{
|
group
|
group
.
metrics
.
any?
}
end
def
common_query_context
(
environment
)
variables
=
{
ci_environment_slug:
environment
.
slug
,
kube_namespace:
environment
.
project
.
kubernetes_service
.
actual_namespace
,
}.
flat_map
{
|
k
,
v
|
[[
k
,
v
],
[
k
.
upcase
,
v
]]
}.
to_h
macros
=
{
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
}
variables
.
merge
(
macros
)
end
end
end
end
...
...
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