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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7bb093d9
Commit
7bb093d9
authored
Jan 05, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
54420c4f
8b4c43c0
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
88 additions
and
85 deletions
+88
-85
changelogs/unreleased/deprecate-prometheus-listen-address.yml
...gelogs/unreleased/deprecate-prometheus-listen-address.yml
+5
-0
config/gitlab.yml.example
config/gitlab.yml.example
+3
-6
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+12
-0
lib/gitlab/danger/commit_linter.rb
lib/gitlab/danger/commit_linter.rb
+9
-3
lib/gitlab/danger/merge_request_linter.rb
lib/gitlab/danger/merge_request_linter.rb
+7
-1
lib/gitlab/database_importers/self_monitoring/project/create_service.rb
...abase_importers/self_monitoring/project/create_service.rb
+6
-6
lib/gitlab/prometheus/internal.rb
lib/gitlab/prometheus/internal.rb
+12
-16
lib/gitlab/utils/usage_data.rb
lib/gitlab/utils/usage_data.rb
+2
-1
spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb
..._importers/self_monitoring/project/create_service_spec.rb
+15
-15
spec/lib/gitlab/prometheus/internal_spec.rb
spec/lib/gitlab/prometheus/internal_spec.rb
+14
-34
spec/lib/gitlab/utils/usage_data_spec.rb
spec/lib/gitlab/utils/usage_data_spec.rb
+1
-1
spec/models/project_services/prometheus_service_spec.rb
spec/models/project_services/prometheus_service_spec.rb
+2
-2
No files found.
changelogs/unreleased/deprecate-prometheus-listen-address.yml
0 → 100644
View file @
7bb093d9
---
title
:
Deprecate prometheus.listen_address and prometheus.enable
merge_request
:
50500
author
:
type
:
deprecated
config/gitlab.yml.example
View file @
7bb093d9
...
@@ -1207,10 +1207,7 @@ production: &base
...
@@ -1207,10 +1207,7 @@ production: &base
# yourself, and then update the values here.
# yourself, and then update the values here.
# https://docs.gitlab.com/ee/administration/monitoring/prometheus/
# https://docs.gitlab.com/ee/administration/monitoring/prometheus/
prometheus:
prometheus:
# Do not use `enable` and `listen_address` in any new code, as they are deprecated. Use `server_address` instead.
# enabled: true
# https://gitlab.com/gitlab-org/gitlab/-/issues/227111
# enable: true
# listen_address: 'localhost:9090'
# server_address: 'localhost:9090'
# server_address: 'localhost:9090'
## Consul settings
## Consul settings
...
@@ -1499,8 +1496,8 @@ test:
...
@@ -1499,8 +1496,8 @@ test:
group_base: 'ou=groups,dc=example,dc=com'
group_base: 'ou=groups,dc=example,dc=com'
admin_group: ''
admin_group: ''
prometheus:
prometheus:
enable: true
enable
d
: true
listen
_address: 'localhost:9090'
server
_address: 'localhost:9090'
staging:
staging:
<<: *base
<<: *base
config/initializers/1_settings.rb
View file @
7bb093d9
...
@@ -851,6 +851,18 @@ Settings.monitoring.web_exporter['enabled'] ||= false
...
@@ -851,6 +851,18 @@ Settings.monitoring.web_exporter['enabled'] ||= false
Settings
.
monitoring
.
web_exporter
[
'address'
]
||=
'localhost'
Settings
.
monitoring
.
web_exporter
[
'address'
]
||=
'localhost'
Settings
.
monitoring
.
web_exporter
[
'port'
]
||=
8083
Settings
.
monitoring
.
web_exporter
[
'port'
]
||=
8083
#
# Prometheus settings
#
Settings
[
'prometheus'
]
||=
Settingslogic
.
new
({})
# TODO: Remove listen_address and enable in GitLab 14.0 and set default value
# of server_address to be nil and enabled to be false -
# https://gitlab.com/gitlab-org/gitlab/-/issues/296022
Settings
.
prometheus
[
'enable'
]
||=
false
Settings
.
prometheus
[
'listen_address'
]
||=
nil
Settings
.
prometheus
[
'enabled'
]
=
Settings
.
prometheus
[
'enable'
]
if
Settings
.
prometheus
[
'enabled'
].
nil?
Settings
.
prometheus
[
'server_address'
]
||=
Settings
.
prometheus
[
'listen_address'
]
#
#
# Shutdown settings
# Shutdown settings
#
#
...
...
lib/gitlab/danger/commit_linter.rb
View file @
7bb093d9
# frozen_string_literal: true
# frozen_string_literal: true
require_relative
'base_linter'
emoji_checker_path
=
File
.
expand_path
(
'emoji_checker'
,
__dir__
)
emoji_checker_path
=
File
.
expand_path
(
'emoji_checker'
,
__dir__
)
defined?
(
Rails
)
?
require_dependency
(
emoji_checker_path
)
:
require_relative
(
emoji_checker_path
)
base_linter_path
=
File
.
expand_path
(
'base_linter'
,
__dir__
)
if
defined?
(
Rails
)
require_dependency
(
base_linter_path
)
require_dependency
(
emoji_checker_path
)
else
require_relative
(
base_linter_path
)
require_relative
(
emoji_checker_path
)
end
module
Gitlab
module
Gitlab
module
Danger
module
Danger
...
...
lib/gitlab/danger/merge_request_linter.rb
View file @
7bb093d9
# frozen_string_literal: true
# frozen_string_literal: true
require_relative
'base_linter'
base_linter_path
=
File
.
expand_path
(
'base_linter'
,
__dir__
)
if
defined?
(
Rails
)
require_dependency
(
base_linter_path
)
else
require_relative
(
base_linter_path
)
end
module
Gitlab
module
Gitlab
module
Danger
module
Danger
...
...
lib/gitlab/database_importers/self_monitoring/project/create_service.rb
View file @
7bb093d9
...
@@ -75,7 +75,7 @@ module Gitlab
...
@@ -75,7 +75,7 @@ module Gitlab
if
response
if
response
# In the add_prometheus_manual_configuration method, the Prometheus
# In the add_prometheus_manual_configuration method, the Prometheus
#
listen
_address config is saved as an api_url in the PrometheusService
#
server
_address config is saved as an api_url in the PrometheusService
# model. There are validates hooks in the PrometheusService model that
# model. There are validates hooks in the PrometheusService model that
# check if the project associated with the PrometheusService is the
# check if the project associated with the PrometheusService is the
# self_monitoring project. It checks
# self_monitoring project. It checks
...
@@ -105,7 +105,7 @@ module Gitlab
...
@@ -105,7 +105,7 @@ module Gitlab
def
add_prometheus_manual_configuration
(
result
)
def
add_prometheus_manual_configuration
(
result
)
return
success
(
result
)
unless
prometheus_enabled?
return
success
(
result
)
unless
prometheus_enabled?
return
success
(
result
)
unless
prometheus_
listen
_address
.
present?
return
success
(
result
)
unless
prometheus_
server
_address
.
present?
service
=
result
[
:project
].
find_or_initialize_service
(
'prometheus'
)
service
=
result
[
:project
].
find_or_initialize_service
(
'prometheus'
)
...
@@ -132,8 +132,8 @@ module Gitlab
...
@@ -132,8 +132,8 @@ module Gitlab
::
Gitlab
::
Prometheus
::
Internal
.
prometheus_enabled?
::
Gitlab
::
Prometheus
::
Internal
.
prometheus_enabled?
end
end
def
prometheus_
listen
_address
def
prometheus_
server
_address
::
Gitlab
::
Prometheus
::
Internal
.
listen
_address
::
Gitlab
::
Prometheus
::
Internal
.
server
_address
end
end
def
docs_path
def
docs_path
...
@@ -152,13 +152,13 @@ module Gitlab
...
@@ -152,13 +152,13 @@ module Gitlab
}
}
end
end
def
internal_prometheus_
listen
_address_uri
def
internal_prometheus_
server
_address_uri
::
Gitlab
::
Prometheus
::
Internal
.
uri
::
Gitlab
::
Prometheus
::
Internal
.
uri
end
end
def
prometheus_service_attributes
def
prometheus_service_attributes
{
{
api_url:
internal_prometheus_
listen
_address_uri
,
api_url:
internal_prometheus_
server
_address_uri
,
manual_configuration:
true
,
manual_configuration:
true
,
active:
true
active:
true
}
}
...
...
lib/gitlab/prometheus/internal.rb
View file @
7bb093d9
...
@@ -4,43 +4,39 @@ module Gitlab
...
@@ -4,43 +4,39 @@ module Gitlab
module
Prometheus
module
Prometheus
class
Internal
class
Internal
def
self
.
uri
def
self
.
uri
return
if
listen
_address
.
blank?
return
if
server
_address
.
blank?
if
listen
_address
.
starts_with?
(
'0.0.0.0:'
)
if
server
_address
.
starts_with?
(
'0.0.0.0:'
)
# 0.0.0.0:9090
# 0.0.0.0:9090
port
=
':'
+
listen
_address
.
split
(
':'
).
second
port
=
':'
+
server
_address
.
split
(
':'
).
second
'http://localhost'
+
port
'http://localhost'
+
port
elsif
listen
_address
.
starts_with?
(
':'
)
elsif
server
_address
.
starts_with?
(
':'
)
# :9090
# :9090
'http://localhost'
+
listen
_address
'http://localhost'
+
server
_address
elsif
listen
_address
.
starts_with?
(
'http'
)
elsif
server
_address
.
starts_with?
(
'http'
)
# https://localhost:9090
# https://localhost:9090
listen
_address
server
_address
else
else
# localhost:9090
# localhost:9090
'http://'
+
listen
_address
'http://'
+
server
_address
end
end
end
end
def
self
.
server_address
def
self
.
server_address
uri
&
.
strip
&
.
sub
(
/^http[s]?:\/\//
,
''
)
Gitlab
.
config
.
prometheus
.
server_address
.
to_s
if
Gitlab
.
config
.
prometheus
end
def
self
.
listen_address
Gitlab
.
config
.
prometheus
.
listen_address
.
to_s
if
Gitlab
.
config
.
prometheus
rescue
Settingslogic
::
MissingSetting
rescue
Settingslogic
::
MissingSetting
Gitlab
::
AppLogger
.
error
(
'Prometheus
listen
_address is not present in config/gitlab.yml'
)
Gitlab
::
AppLogger
.
error
(
'Prometheus
server
_address is not present in config/gitlab.yml'
)
nil
nil
end
end
def
self
.
prometheus_enabled?
def
self
.
prometheus_enabled?
Gitlab
.
config
.
prometheus
.
enable
if
Gitlab
.
config
.
prometheus
Gitlab
.
config
.
prometheus
.
enable
d
if
Gitlab
.
config
.
prometheus
rescue
Settingslogic
::
MissingSetting
rescue
Settingslogic
::
MissingSetting
Gitlab
::
AppLogger
.
error
(
'prometheus.enable is not present in config/gitlab.yml'
)
Gitlab
::
AppLogger
.
error
(
'prometheus.enable
d
is not present in config/gitlab.yml'
)
false
false
end
end
...
...
lib/gitlab/utils/usage_data.rb
View file @
7bb093d9
...
@@ -145,7 +145,8 @@ module Gitlab
...
@@ -145,7 +145,8 @@ module Gitlab
def
prometheus_server_address
def
prometheus_server_address
if
Gitlab
::
Prometheus
::
Internal
.
prometheus_enabled?
if
Gitlab
::
Prometheus
::
Internal
.
prometheus_enabled?
Gitlab
::
Prometheus
::
Internal
.
server_address
# Stripping protocol from URI
Gitlab
::
Prometheus
::
Internal
.
uri
&
.
strip
&
.
sub
(
%r{^https?://}
,
''
)
elsif
Gitlab
::
Consul
::
Internal
.
api_url
elsif
Gitlab
::
Consul
::
Internal
.
api_url
Gitlab
::
Consul
::
Internal
.
discover_prometheus_server_address
Gitlab
::
Consul
::
Internal
.
discover_prometheus_server_address
end
end
...
...
spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb
View file @
7bb093d9
...
@@ -8,8 +8,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
...
@@ -8,8 +8,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
let
(
:prometheus_settings
)
do
let
(
:prometheus_settings
)
do
{
{
enable:
true
,
enable
d
:
true
,
listen
_address:
'localhost:9090'
server
_address:
'localhost:9090'
}
}
end
end
...
@@ -63,13 +63,13 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
...
@@ -63,13 +63,13 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
application_setting
.
update
(
allow_local_requests_from_web_hooks_and_services:
true
)
application_setting
.
update
(
allow_local_requests_from_web_hooks_and_services:
true
)
end
end
shared_examples
'has prometheus service'
do
|
listen
_address
|
shared_examples
'has prometheus service'
do
|
server
_address
|
it
do
it
do
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
result
[
:status
]).
to
eq
(
:success
)
prometheus
=
project
.
prometheus_service
prometheus
=
project
.
prometheus_service
expect
(
prometheus
).
not_to
eq
(
nil
)
expect
(
prometheus
).
not_to
eq
(
nil
)
expect
(
prometheus
.
api_url
).
to
eq
(
listen
_address
)
expect
(
prometheus
.
api_url
).
to
eq
(
server
_address
)
expect
(
prometheus
.
active
).
to
eq
(
true
)
expect
(
prometheus
.
active
).
to
eq
(
true
)
expect
(
prometheus
.
manual_configuration
).
to
eq
(
true
)
expect
(
prometheus
.
manual_configuration
).
to
eq
(
true
)
end
end
...
@@ -202,25 +202,25 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
...
@@ -202,25 +202,25 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
end
end
context
'with non default prometheus address'
do
context
'with non default prometheus address'
do
let
(
:
listen
_address
)
{
'https://localhost:9090'
}
let
(
:
server
_address
)
{
'https://localhost:9090'
}
let
(
:prometheus_settings
)
do
let
(
:prometheus_settings
)
do
{
{
enable:
true
,
enable
d
:
true
,
listen_address:
listen
_address
server_address:
server
_address
}
}
end
end
it_behaves_like
'has prometheus service'
,
'https://localhost:9090'
it_behaves_like
'has prometheus service'
,
'https://localhost:9090'
context
'with :9090 symbol'
do
context
'with :9090 symbol'
do
let
(
:
listen
_address
)
{
:':9090'
}
let
(
:
server
_address
)
{
:':9090'
}
it_behaves_like
'has prometheus service'
,
'http://localhost:9090'
it_behaves_like
'has prometheus service'
,
'http://localhost:9090'
end
end
context
'with 0.0.0.0:9090'
do
context
'with 0.0.0.0:9090'
do
let
(
:
listen
_address
)
{
'0.0.0.0:9090'
}
let
(
:
server
_address
)
{
'0.0.0.0:9090'
}
it_behaves_like
'has prometheus service'
,
'http://localhost:9090'
it_behaves_like
'has prometheus service'
,
'http://localhost:9090'
end
end
...
@@ -251,8 +251,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
...
@@ -251,8 +251,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
context
'when prometheus setting is disabled in gitlab.yml'
do
context
'when prometheus setting is disabled in gitlab.yml'
do
let
(
:prometheus_settings
)
do
let
(
:prometheus_settings
)
do
{
{
enable:
false
,
enable
d
:
false
,
listen
_address:
'http://localhost:9090'
server
_address:
'http://localhost:9090'
}
}
end
end
...
@@ -262,8 +262,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
...
@@ -262,8 +262,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
end
end
end
end
context
'when prometheus
listen
address is blank in gitlab.yml'
do
context
'when prometheus
server
address is blank in gitlab.yml'
do
let
(
:prometheus_settings
)
{
{
enable
:
true
,
listen
_address:
''
}
}
let
(
:prometheus_settings
)
{
{
enable
d:
true
,
server
_address:
''
}
}
it
'does not configure prometheus'
do
it
'does not configure prometheus'
do
expect
(
result
).
to
include
(
status: :success
)
expect
(
result
).
to
include
(
status: :success
)
...
@@ -296,8 +296,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
...
@@ -296,8 +296,8 @@ RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService
context
'when prometheus manual configuration cannot be saved'
do
context
'when prometheus manual configuration cannot be saved'
do
let
(
:prometheus_settings
)
do
let
(
:prometheus_settings
)
do
{
{
enable:
true
,
enable
d
:
true
,
listen
_address:
'httpinvalid://localhost:9090'
server
_address:
'httpinvalid://localhost:9090'
}
}
end
end
...
...
spec/lib/gitlab/prometheus/internal_spec.rb
View file @
7bb093d9
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Prometheus
::
Internal
do
RSpec
.
describe
Gitlab
::
Prometheus
::
Internal
do
let
(
:
listen
_address
)
{
'localhost:9090'
}
let
(
:
server
_address
)
{
'localhost:9090'
}
let
(
:prometheus_settings
)
do
let
(
:prometheus_settings
)
do
{
{
enable:
true
,
enable
d
:
true
,
listen_address:
listen
_address
server_address:
server
_address
}
}
end
end
...
@@ -27,25 +27,25 @@ RSpec.describe Gitlab::Prometheus::Internal do
...
@@ -27,25 +27,25 @@ RSpec.describe Gitlab::Prometheus::Internal do
it_behaves_like
'returns valid uri'
,
'http://localhost:9090'
it_behaves_like
'returns valid uri'
,
'http://localhost:9090'
context
'with non default prometheus address'
do
context
'with non default prometheus address'
do
let
(
:
listen
_address
)
{
'https://localhost:9090'
}
let
(
:
server
_address
)
{
'https://localhost:9090'
}
it_behaves_like
'returns valid uri'
,
'https://localhost:9090'
it_behaves_like
'returns valid uri'
,
'https://localhost:9090'
context
'with :9090 symbol'
do
context
'with :9090 symbol'
do
let
(
:
listen
_address
)
{
:':9090'
}
let
(
:
server
_address
)
{
:':9090'
}
it_behaves_like
'returns valid uri'
,
'http://localhost:9090'
it_behaves_like
'returns valid uri'
,
'http://localhost:9090'
end
end
context
'with 0.0.0.0:9090'
do
context
'with 0.0.0.0:9090'
do
let
(
:
listen
_address
)
{
'0.0.0.0:9090'
}
let
(
:
server
_address
)
{
'0.0.0.0:9090'
}
it_behaves_like
'returns valid uri'
,
'http://localhost:9090'
it_behaves_like
'returns valid uri'
,
'http://localhost:9090'
end
end
end
end
context
'when
listen
_address is nil'
do
context
'when
server
_address is nil'
do
let
(
:
listen
_address
)
{
nil
}
let
(
:
server
_address
)
{
nil
}
it
'does not fail'
do
it
'does not fail'
do
expect
(
described_class
.
uri
).
to
be_nil
expect
(
described_class
.
uri
).
to
be_nil
...
@@ -53,7 +53,7 @@ RSpec.describe Gitlab::Prometheus::Internal do
...
@@ -53,7 +53,7 @@ RSpec.describe Gitlab::Prometheus::Internal do
end
end
context
'when prometheus listen address is blank in gitlab.yml'
do
context
'when prometheus listen address is blank in gitlab.yml'
do
let
(
:
listen
_address
)
{
''
}
let
(
:
server
_address
)
{
''
}
it
'does not configure prometheus'
do
it
'does not configure prometheus'
do
expect
(
described_class
.
uri
).
to
be_nil
expect
(
described_class
.
uri
).
to
be_nil
...
@@ -61,26 +61,6 @@ RSpec.describe Gitlab::Prometheus::Internal do
...
@@ -61,26 +61,6 @@ RSpec.describe Gitlab::Prometheus::Internal do
end
end
end
end
describe
'.server_address'
do
context
'self.uri returns valid uri'
do
[
'http://localhost:9090'
,
'https://localhost:9090 '
].
each
do
|
valid_uri
|
it
'returns correct server address'
do
expect
(
described_class
).
to
receive
(
:uri
).
and_return
(
valid_uri
)
expect
(
described_class
.
server_address
).
to
eq
(
'localhost:9090'
)
end
end
end
context
'self.uri returns nil'
do
it
'returns nil'
do
expect
(
described_class
).
to
receive
(
:uri
).
and_return
(
nil
)
expect
(
described_class
.
server_address
).
to
be_nil
end
end
end
describe
'.prometheus_enabled?'
do
describe
'.prometheus_enabled?'
do
it
'returns correct value'
do
it
'returns correct value'
do
expect
(
described_class
.
prometheus_enabled?
).
to
eq
(
true
)
expect
(
described_class
.
prometheus_enabled?
).
to
eq
(
true
)
...
@@ -89,8 +69,8 @@ RSpec.describe Gitlab::Prometheus::Internal do
...
@@ -89,8 +69,8 @@ RSpec.describe Gitlab::Prometheus::Internal do
context
'when prometheus setting is disabled in gitlab.yml'
do
context
'when prometheus setting is disabled in gitlab.yml'
do
let
(
:prometheus_settings
)
do
let
(
:prometheus_settings
)
do
{
{
enable:
false
,
enable
d
:
false
,
listen_address:
listen
_address
server_address:
server
_address
}
}
end
end
...
@@ -110,9 +90,9 @@ RSpec.describe Gitlab::Prometheus::Internal do
...
@@ -110,9 +90,9 @@ RSpec.describe Gitlab::Prometheus::Internal do
end
end
end
end
describe
'.
listen
_address'
do
describe
'.
server
_address'
do
it
'returns correct value'
do
it
'returns correct value'
do
expect
(
described_class
.
listen_address
).
to
eq
(
listen
_address
)
expect
(
described_class
.
server_address
).
to
eq
(
server
_address
)
end
end
context
'when prometheus setting is not present in gitlab.yml'
do
context
'when prometheus setting is not present in gitlab.yml'
do
...
@@ -121,7 +101,7 @@ RSpec.describe Gitlab::Prometheus::Internal do
...
@@ -121,7 +101,7 @@ RSpec.describe Gitlab::Prometheus::Internal do
end
end
it
'does not fail'
do
it
'does not fail'
do
expect
(
described_class
.
listen
_address
).
to
be_nil
expect
(
described_class
.
server
_address
).
to
be_nil
end
end
end
end
end
end
...
...
spec/lib/gitlab/utils/usage_data_spec.rb
View file @
7bb093d9
...
@@ -284,7 +284,7 @@ RSpec.describe Gitlab::Utils::UsageData do
...
@@ -284,7 +284,7 @@ RSpec.describe Gitlab::Utils::UsageData do
context
'when Prometheus server address is available from settings'
do
context
'when Prometheus server address is available from settings'
do
before
do
before
do
expect
(
Gitlab
::
Prometheus
::
Internal
).
to
receive
(
:prometheus_enabled?
).
and_return
(
true
)
expect
(
Gitlab
::
Prometheus
::
Internal
).
to
receive
(
:prometheus_enabled?
).
and_return
(
true
)
expect
(
Gitlab
::
Prometheus
::
Internal
).
to
receive
(
:
server_address
).
and_return
(
'
prom:9090'
)
expect
(
Gitlab
::
Prometheus
::
Internal
).
to
receive
(
:
uri
).
and_return
(
'http://
prom:9090'
)
end
end
it_behaves_like
'try to query Prometheus with given address'
it_behaves_like
'try to query Prometheus with given address'
...
...
spec/models/project_services/prometheus_service_spec.rb
View file @
7bb093d9
...
@@ -95,7 +95,7 @@ RSpec.describe PrometheusService, :use_clean_rails_memory_store_caching, :snowpl
...
@@ -95,7 +95,7 @@ RSpec.describe PrometheusService, :use_clean_rails_memory_store_caching, :snowpl
service
.
api_url
=
'http://localhost:9090'
service
.
api_url
=
'http://localhost:9090'
stub_application_setting
(
self_monitoring_project_id:
project
.
id
)
stub_application_setting
(
self_monitoring_project_id:
project
.
id
)
stub_config
(
prometheus:
{
enable:
true
,
listen
_address:
'localhost:9090'
})
stub_config
(
prometheus:
{
enable:
true
,
server
_address:
'localhost:9090'
})
end
end
it
'allows self-monitoring project to connect to internal Prometheus'
do
it
'allows self-monitoring project to connect to internal Prometheus'
do
...
@@ -242,7 +242,7 @@ RSpec.describe PrometheusService, :use_clean_rails_memory_store_caching, :snowpl
...
@@ -242,7 +242,7 @@ RSpec.describe PrometheusService, :use_clean_rails_memory_store_caching, :snowpl
stub_config
(
prometheus:
{
stub_config
(
prometheus:
{
enable:
true
,
enable:
true
,
listen
_address:
api_url
server
_address:
api_url
})
})
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