-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add monitor.pl metrics exporters to web servers #672
Draft
daaang
wants to merge
1
commit into
production
Choose a base branch
from
prometheus-web-exporter
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::base ( | ||
Hash[String, Hash[String, String]] $mariadb_connect = {}, | ||
Hash[String, Array[String]] $nfs_mounts = {}, | ||
Hash[String, Array[String]] $solr_instances = {}, | ||
Hash[String, Boolean] $check_shibd = {}, | ||
String $target, | ||
) { | ||
include stdlib | ||
$target_mariadb = pick_default($mariadb_connect[$target], {}) | ||
$target_nfs = pick_default($nfs_mounts[$target], []) | ||
$target_solr = pick_default($solr_instances[$target], []) | ||
$target_shibd = pick_default($check_shibd[$target], false) | ||
|
||
file { "/usr/local/lib/prom_web_exporter/metrics": | ||
mode => "0755", | ||
content => template("nebula/profile/prometheus/exporter/webserver/metrics.sh.erb"), | ||
require => File["/usr/local/lib/prom_web_exporter"], | ||
} | ||
|
||
file { "/usr/local/lib/prom_web_exporter": | ||
ensure => "directory", | ||
} | ||
|
||
if $target_mariadb != {} { | ||
package { "mariadb-client": } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::fulcrum { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "fulcrum" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
manifests/profile/prometheus/exporter/webserver/hathitrust.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::hathitrust { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "hathitrust" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::quod { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "quod" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::vhost ( | ||
Boolean $testing = false | ||
) { | ||
if $testing { | ||
include apache | ||
} | ||
|
||
apache::vhost { "prometheus-webserver-exporter": | ||
port => "9180", | ||
docroot => "/usr/local/lib/prom_web_exporter", | ||
aliases => [{ scriptalias => "/", path => "/usr/local/lib/prom_web_exporter/" }], | ||
rewrites => [{ rewrite_rule => ["^/$ /metrics [last,redirect=permanent]"]}], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::www_lib { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "www_lib" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
spec/classes/profile/prometheus/exporter/webserver/base_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::base' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.not_to compile } | ||
|
||
context "with target set to abcd" do | ||
let(:params) { { target: "abcd" } } | ||
|
||
def have_script | ||
contain_file("/usr/local/lib/prom_web_exporter/metrics") | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.not_to contain_package("mariadb-client") } | ||
it { is_expected.to contain_file("/usr/local/lib/prom_web_exporter").with_ensure("directory") } | ||
it { is_expected.to have_script.with_mode("0755") } | ||
it { is_expected.to have_script.with_content(/^#!\/usr\/bin\/env bash$/) } | ||
it { is_expected.to have_script.with_content(/^ENABLE_MARIADB_CHECK="false"$/) } | ||
it { is_expected.to have_script.with_content(/^NFS_MOUNTS=\(\)$/) } | ||
it { is_expected.to have_script.with_content(/^SOLR_INSTANCES=\(\)$/) } | ||
it { is_expected.to have_script.with_content(/^ENABLE_SHIBD_CHECK="false"$/) } | ||
|
||
context "with mariadb credentials set" do | ||
let(:params) do | ||
super().merge({ mariadb_connect: { "abcd" => { | ||
"hostname" => "abcd-db-host", | ||
"database" => "abcd-database", | ||
"username" => "abcd-db-monitor", | ||
"password" => "random-password", | ||
}}}) | ||
end | ||
|
||
it { is_expected.to contain_package("mariadb-client") } | ||
it { is_expected.to have_script.with_content(/^ENABLE_MARIADB_CHECK="true"$/) } | ||
end | ||
|
||
context "with nfs mounts set" do | ||
let(:params) do | ||
super().merge({ nfs_mounts: { "abcd" => %w[/abc /def /ghi] } }) | ||
end | ||
|
||
it { is_expected.to have_script.with_content(/^NFS_MOUNTS=\("\/abc" "\/def" "\/ghi"\)$/) } | ||
end | ||
|
||
context "with solr instances set" do | ||
let(:params) do | ||
super().merge({ solr_instances: { "abcd" => ["http://solr/solr/core"] } }) | ||
end | ||
|
||
it { is_expected.to have_script.with_content(/^SOLR_INSTANCES=\("http:\/\/solr\/solr\/core"\)$/) } | ||
end | ||
|
||
context "with shibd check enabled" do | ||
let(:params) do | ||
super().merge({ check_shibd: { "abcd" => true } }) | ||
end | ||
|
||
it { is_expected.to have_script.with_content(/^ENABLE_SHIBD_CHECK="true"$/) } | ||
end | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/fulcrum_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::fulcrum' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("fulcrum") } | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/hathitrust_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::hathitrust' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("hathitrust") } | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/quod_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::quod' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("quod") } | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
spec/classes/profile/prometheus/exporter/webserver/vhost_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::vhost' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.not_to compile } | ||
|
||
context "with apache configured for testing" do | ||
let(:params) { { testing: true } } | ||
|
||
def have_vhost | ||
contain_apache__vhost("prometheus-webserver-exporter") | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to have_vhost.with_port(9180) } | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/www_lib_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::www_lib' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("www_lib") } | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you can override the default Options for the doc root, but if you can this vhost can function with None.