From a21b7ffc96d246842d543f772b82255bcbc22545 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Fri, 17 Nov 2023 22:59:26 +1100 Subject: [PATCH] feat: setup metrics agents - set puppet::puppetdb_api class to export puppetdb - set infra::dns::server class to export bind - set all to export node and systemd metrics --- Puppetfile | 1 + hieradata/common.yaml | 3 +++ hieradata/roles/infra/dns.yaml | 2 ++ site/profiles/manifests/base.pp | 1 + site/profiles/manifests/dns/server.pp | 10 +++++++--- site/profiles/manifests/metrics/default.pp | 11 +++++++++++ site/profiles/manifests/puppet/puppetdb_api.pp | 5 +++++ 7 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 hieradata/roles/infra/dns.yaml create mode 100644 site/profiles/manifests/metrics/default.pp diff --git a/Puppetfile b/Puppetfile index fda7e8a..94859aa 100644 --- a/Puppetfile +++ b/Puppetfile @@ -23,6 +23,7 @@ mod 'puppet-chrony', '2.6.0' mod 'puppet-puppetboard', '9.0.0' mod 'puppet-nginx', '5.0.0' mod 'puppet-selinux', '4.1.0' +mod 'puppet-prometheus', '13.4.0' # other mod 'ghoneycutt-puppet', '3.3.0' diff --git a/hieradata/common.yaml b/hieradata/common.yaml index dce34c8..5a2cb4a 100644 --- a/hieradata/common.yaml +++ b/hieradata/common.yaml @@ -35,6 +35,9 @@ profiles::puppet::client::runtimeout: 3600 profiles::puppet::client::show_diff: true profiles::puppet::client::usecacheonfailure: false +prometheus::node_exporter::export_scrape_job: true +prometheus::systemd_exporter::export_scrape_job: true + profiles::accounts::sysadmin::sshkeys: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDZ8SRLlPiDylBpdWR9LpvPg4fDVD+DZst4yRPFwMMhta4mnB1H9XuvZkptDhXywWQ7QIcqa2WbhCen0OQJCtwn3s7EYtacmF5MxmwBYocPoK2AArGuh6NA9rwTdLrPdzhZ+gwe88PAzRLNzjm0ZBR+mA9saMbPJdqpKp0AWeAM8QofRQAWuCzQg9i0Pn1KDMvVDRHCZof4pVlHSTyHNektq4ifovn0zhKC8jD/cYu95mc5ftBbORexpGiQWwQ3HZw1IBe0ZETB1qPIPwsoJpt3suvMrL6T2//fcIIUE3TcyJKb/yhztja4TZs5jT8370G/vhlT70He0YPxqHub8ZfBv0khlkY93VBWYpNGJwM1fVqlw7XbfBNdOuJivJac8eW317ZdiDnKkBTxapThpPG3et9ib1HoPGKRsd/fICzNz16h2R3tddSdihTFL+bmTCa6Lo+5t5uRuFjQvhSLSgO2/gRAprc3scYOB4pY/lxOFfq3pU2VvSJtRgLNEYMUYKk= ben@unkin.net diff --git a/hieradata/roles/infra/dns.yaml b/hieradata/roles/infra/dns.yaml new file mode 100644 index 0000000..e31b12e --- /dev/null +++ b/hieradata/roles/infra/dns.yaml @@ -0,0 +1,2 @@ +--- +prometheus::bind_exporter::export_scrape_job: true diff --git a/site/profiles/manifests/base.pp b/site/profiles/manifests/base.pp index 1182097..8130ec2 100644 --- a/site/profiles/manifests/base.pp +++ b/site/profiles/manifests/base.pp @@ -29,6 +29,7 @@ class profiles::base ( include profiles::base::hosts include profiles::accounts::sysadmin include profiles::ntp::client + include profiles::metrics::default # configure dns records for client profiles::dns::client {"${facts['networking']['fqdn']}-default":} diff --git a/site/profiles/manifests/dns/server.pp b/site/profiles/manifests/dns/server.pp index be403fa..0835cd5 100644 --- a/site/profiles/manifests/dns/server.pp +++ b/site/profiles/manifests/dns/server.pp @@ -17,11 +17,15 @@ class profiles::dns::server ( # setup base bind server class { 'bind': - forwarders => $use_forwarders, - dnssec => $dnssec, - version => 'Controlled by Puppet', + forwarders => $use_forwarders, + dnssec => $dnssec, + version => 'Controlled by Puppet', + statistics_port => '8053', } + # setup bind_exporter + include prometheus::bind_exporter + # if keys, import them $keys.each | $name, $data | { bind::key { $name: diff --git a/site/profiles/manifests/metrics/default.pp b/site/profiles/manifests/metrics/default.pp new file mode 100644 index 0000000..4aa086b --- /dev/null +++ b/site/profiles/manifests/metrics/default.pp @@ -0,0 +1,11 @@ +# profiles::metrics::default +# +# these exporters will be setup on all nodes +class profiles::metrics::default ( + Boolean $node_exporter = true, + Boolean $systemd_exporter = true, +) { + + include prometheus::node_exporter + include prometheus::systemd_exporter +} diff --git a/site/profiles/manifests/puppet/puppetdb_api.pp b/site/profiles/manifests/puppet/puppetdb_api.pp index fb1be2e..fa51753 100644 --- a/site/profiles/manifests/puppet/puppetdb_api.pp +++ b/site/profiles/manifests/puppet/puppetdb_api.pp @@ -13,4 +13,9 @@ class profiles::puppet::puppetdb_api ( contain ::puppetdb::server + class { 'prometheus::puppetdb_exporter': + puppetdb_url => "http://${listen_address}:8080/pdb/query", + export_scrape_job => true, + } + }