Skip to content

Commit

Permalink
P:wmcs::prometheus: fix openstack-exporter
Browse files Browse the repository at this point in the history
The openstack exporter logic was relying on the fact that the openstack.
endpoint was hosted on a cloudcontrol host. We still want to scrape it
from a single cloudcontrol, so add a hiera variable to control which one
is used.

Bug: T346439
Change-Id: I6cd147e024ddb273eee18a64f2bf2cea9a51ebe0
  • Loading branch information
supertassu committed Sep 22, 2023
1 parent bba817e commit 268e18c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
1 change: 1 addition & 0 deletions hieradata/eqiad/profile/wmcs/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
profile::wmcs::prometheus::openstack_exporter_host: cloudcontrol1006.wikimedia.org
19 changes: 5 additions & 14 deletions modules/profile/manifests/openstack/eqiad1/metrics.pp
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
class profile::openstack::eqiad1::metrics (
Stdlib::Fqdn $controller = lookup('profile::openstack::eqiad1::keystone_api_fqdn'),
Stdlib::Fqdn $active_host = lookup('profile::wmcs::prometheus::openstack_exporter_host'),
) {
$this_ip = ipresolve($::fqdn, 4)
$controller_ip = ipresolve($controller, 4)

if $this_ip == $controller_ip {
class { '::profile::prometheus::openstack_exporter':
listen_port => 12345,
cloud => 'eqiad1',
}
contain '::profile::prometheus::openstack_exporter'
} else {
class { '::profile::prometheus::openstack_exporter':
ensure => absent,
}
class { '::profile::prometheus::openstack_exporter':
ensure => ($active_host == $::facts['networking']['fqdn']).bool2str('present', 'absent'),
listen_port => 12345,
cloud => 'eqiad1',
}
}
15 changes: 8 additions & 7 deletions modules/profile/manifests/wmcs/prometheus.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class profile::wmcs::prometheus(
Stdlib::Unixpath $targets_path = '/srv/prometheus/labs/targets',
String $storage_retention = lookup('prometheus::server::storage_retention', {'default_value' => '4032h'}),
Integer $max_chunks_to_persist = lookup('prometheus::server::max_chunks_to_persist', {'default_value' => 524288}),
Integer $memory_chunks = lookup('prometheus::server::memory_chunks', {'default_value' => 1048576}),
Optional[Stdlib::Datasize] $storage_retention_size = lookup('profile::wmcs::prometheus::storage_retention_size', {default_value => undef}),
Array[Stdlib::Host] $alertmanagers = lookup('alertmanagers', {'default_value' => []}),
Stdlib::Unixpath $targets_path = '/srv/prometheus/labs/targets',
String $storage_retention = lookup('prometheus::server::storage_retention', {'default_value' => '4032h'}),
Integer $max_chunks_to_persist = lookup('prometheus::server::max_chunks_to_persist', {'default_value' => 524288}),
Integer $memory_chunks = lookup('prometheus::server::memory_chunks', {'default_value' => 1048576}),
Optional[Stdlib::Datasize] $storage_retention_size = lookup('profile::wmcs::prometheus::storage_retention_size', {default_value => undef}),
Stdlib::Fqdn $openstack_exporter_host = lookup('profile::wmcs::prometheus::openstack_exporter_host'),
Array[Stdlib::Host] $alertmanagers = lookup('alertmanagers', {'default_value' => []}),
) {
$config_extra = {
'external_labels' => {
Expand Down Expand Up @@ -181,7 +182,7 @@
'site' => 'eqiad',
},
'targets' => [
'openstack.eqiad1.wikimediacloud.org:12345',
"${openstack_exporter_host}:12345",
]
}]),
}
Expand Down

0 comments on commit 268e18c

Please sign in to comment.