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
Boxiang Sun
gitlab-ce
Commits
b47a3a40
Commit
b47a3a40
authored
Nov 16, 2018
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract query variables into own module
parent
fbbe5ccd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
5 deletions
+55
-5
changelogs/unreleased/7527-ci-variables-are-not-parameterized-for-alerting-rules-ce.yml
...variables-are-not-parameterized-for-alerting-rules-ce.yml
+5
-0
lib/gitlab/prometheus/queries/query_additional_metrics.rb
lib/gitlab/prometheus/queries/query_additional_metrics.rb
+2
-5
lib/gitlab/prometheus/query_variables.rb
lib/gitlab/prometheus/query_variables.rb
+15
-0
spec/lib/gitlab/prometheus/query_variables_spec.rb
spec/lib/gitlab/prometheus/query_variables_spec.rb
+33
-0
No files found.
changelogs/unreleased/7527-ci-variables-are-not-parameterized-for-alerting-rules-ce.yml
0 → 100644
View file @
b47a3a40
---
title
:
Extract into Gitlab::Prometheus::QueryVariables
merge_request
:
23335
author
:
type
:
other
lib/gitlab/prometheus/queries/query_additional_metrics.rb
View file @
b47a3a40
...
@@ -83,11 +83,8 @@ module Gitlab
...
@@ -83,11 +83,8 @@ module Gitlab
end
end
def
common_query_context
(
environment
,
timeframe_start
:,
timeframe_end
:)
def
common_query_context
(
environment
,
timeframe_start
:,
timeframe_end
:)
base_query_context
(
timeframe_start
,
timeframe_end
).
merge
({
base_query_context
(
timeframe_start
,
timeframe_end
)
ci_environment_slug:
environment
.
slug
,
.
merge
(
QueryVariables
.
call
(
environment
))
kube_namespace:
environment
.
deployment_platform
&
.
actual_namespace
||
''
,
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
})
end
end
def
base_query_context
(
timeframe_start
,
timeframe_end
)
def
base_query_context
(
timeframe_start
,
timeframe_end
)
...
...
lib/gitlab/prometheus/query_variables.rb
0 → 100644
View file @
b47a3a40
# frozen_string_literal: true
module
Gitlab
module
Prometheus
module
QueryVariables
def
self
.
call
(
environment
)
{
ci_environment_slug:
environment
.
slug
,
kube_namespace:
environment
.
deployment_platform
&
.
actual_namespace
||
''
,
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
}
end
end
end
end
spec/lib/gitlab/prometheus/query_variables_spec.rb
0 → 100644
View file @
b47a3a40
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Prometheus
::
QueryVariables
do
describe
'.call'
do
set
(
:environment
)
{
create
(
:environment
)
}
let
(
:slug
)
{
environment
.
slug
}
subject
{
described_class
.
call
(
environment
)
}
it
{
is_expected
.
to
include
(
ci_environment_slug:
slug
)
}
it
do
is_expected
.
to
include
(
environment_filter:
%{container_name!="POD",environment="#{slug}"}
)
end
context
'without deployment platform'
do
it
{
is_expected
.
to
include
(
kube_namespace:
''
)
}
end
context
'with deplyoment platform'
do
let
(
:kube_namespace
)
{
environment
.
deployment_platform
.
actual_namespace
}
before
do
create
(
:cluster
,
:provided_by_user
,
projects:
[
environment
.
project
])
end
it
{
is_expected
.
to
include
(
kube_namespace:
kube_namespace
)
}
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