diff --git a/.gitmodules b/.gitmodules index b9a6764e..326afcaf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,4 @@ [submodule "roles/ansible-ca-store"] path = roles/ansible-ca-store url = https://github.com/lawliet89/ansible-ca-store.git -[submodule "roles/prometheus"] - path = roles/prometheus - url = https://github.com/cloudalchemy/ansible-prometheus.git + diff --git a/roles/prometheus b/roles/prometheus deleted file mode 160000 index 2201713a..00000000 --- a/roles/prometheus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2201713a60fa4b215c6b15b76c891e32d454d6e2 diff --git a/roles/prometheus/.ansible-lint b/roles/prometheus/.ansible-lint new file mode 100644 index 00000000..ad9fc9f9 --- /dev/null +++ b/roles/prometheus/.ansible-lint @@ -0,0 +1,5 @@ +--- +skip_list: +- '106' +- '204' +- '208' diff --git a/roles/prometheus/.gitignore b/roles/prometheus/.gitignore new file mode 100644 index 00000000..db70ede3 --- /dev/null +++ b/roles/prometheus/.gitignore @@ -0,0 +1,7 @@ +*.retry +*.log +.molecule +.cache +__pycache__/ +.pytest_cache +.tox diff --git a/roles/prometheus/.mergify.yml b/roles/prometheus/.mergify.yml new file mode 100644 index 00000000..877a4825 --- /dev/null +++ b/roles/prometheus/.mergify.yml @@ -0,0 +1,12 @@ +--- +pull_request_rules: + - name: automatic merge and new release from cloudalchemybot + conditions: + - "status-success=Travis CI - Pull Request" + - status-success=WIP + - head~=autoupdate|skeleton + - author=cloudalchemybot + actions: + merge: + method: squash + strict: true diff --git a/roles/prometheus/.yamllint b/roles/prometheus/.yamllint new file mode 100644 index 00000000..8f2e1fa2 --- /dev/null +++ b/roles/prometheus/.yamllint @@ -0,0 +1,14 @@ +--- +extends: default +ignore: | + .github/ + meta/ + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable diff --git a/roles/prometheus/CHANGELOG.md b/roles/prometheus/CHANGELOG.md new file mode 100644 index 00000000..e55a25b4 --- /dev/null +++ b/roles/prometheus/CHANGELOG.md @@ -0,0 +1,782 @@ +# Change Log + +## [**Next release**](https://galaxy.ansible.com/cloudalchemy/prometheus) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#318](https://github.com/cloudalchemy/ansible-prometheus/pull/318) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.16.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-11-04) +**Merged pull requests:** + +- Wait for local file systems before starting prometheus [\#317](https://github.com/cloudalchemy/ansible-prometheus/pull/317) ([bartoszcisek](https://github.com/bartoszcisek)) + +## [2.16.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-10-20) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#316](https://github.com/cloudalchemy/ansible-prometheus/pull/316) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.16.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-09-28) +**Implemented enhancements:** + +- offline support [\#296](https://github.com/cloudalchemy/ansible-prometheus/issues/296) + +**Fixed bugs:** + +- prometheus\_scrape\_configs changes line order [\#310](https://github.com/cloudalchemy/ansible-prometheus/issues/310) +- conf.d folder is provided, but there is no mechanism for using it [\#283](https://github.com/cloudalchemy/ansible-prometheus/issues/283) + +**Closed issues:** + +- You need to install \"jmespath\" prior to running json\_query filter [\#314](https://github.com/cloudalchemy/ansible-prometheus/issues/314) + +**Merged pull requests:** + +- Bump version [\#315](https://github.com/cloudalchemy/ansible-prometheus/pull/315) ([SuperQ](https://github.com/SuperQ)) +- \[REPO SYNC\] add troubleshooting doc skeleton [\#309](https://github.com/cloudalchemy/ansible-prometheus/pull/309) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#303](https://github.com/cloudalchemy/ansible-prometheus/pull/303) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Do not create unused directory conf.d [\#299](https://github.com/cloudalchemy/ansible-prometheus/pull/299) ([paulfantom](https://github.com/paulfantom)) +- New prometheus/prometheus upstream release! [\#298](https://github.com/cloudalchemy/ansible-prometheus/pull/298) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-06-09) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#293](https://github.com/cloudalchemy/ansible-prometheus/pull/293) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] Add passlib as a test requirement [\#292](https://github.com/cloudalchemy/ansible-prometheus/pull/292) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-05-09) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#290](https://github.com/cloudalchemy/ansible-prometheus/pull/290) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-05-07) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#289](https://github.com/cloudalchemy/ansible-prometheus/pull/289) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- improve path\_prefix example in defaults [\#266](https://github.com/cloudalchemy/ansible-prometheus/pull/266) ([zxyz](https://github.com/zxyz)) + +## [2.15.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-20) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#284](https://github.com/cloudalchemy/ansible-prometheus/pull/284) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-14) +**Merged pull requests:** + +- Fix version\_compare filter deprecation [\#282](https://github.com/cloudalchemy/ansible-prometheus/pull/282) ([ecksun](https://github.com/ecksun)) + +## [2.15.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-12) +**Fixed bugs:** + +- Readme variable prometheus\_binaries\_local\_dir [\#279](https://github.com/cloudalchemy/ansible-prometheus/issues/279) + +**Merged pull requests:** + +- Update Readme variable prometheus\_binary\_local\_dir [\#280](https://github.com/cloudalchemy/ansible-prometheus/pull/280) ([asatblurbs](https://github.com/asatblurbs)) +- added installation method config to skip install [\#272](https://github.com/cloudalchemy/ansible-prometheus/pull/272) ([DEvil0000](https://github.com/DEvil0000)) + +## [2.14.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-27) +**Fixed bugs:** + +- CriticalDiskSpace Alert using wrong Metrics [\#275](https://github.com/cloudalchemy/ansible-prometheus/issues/275) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#277](https://github.com/cloudalchemy/ansible-prometheus/pull/277) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- defaults: sync alerts from node-mixin project [\#276](https://github.com/cloudalchemy/ansible-prometheus/pull/276) ([paulfantom](https://github.com/paulfantom)) + +## [2.14.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-25) +**Merged pull requests:** + +- Upstream release update [\#274](https://github.com/cloudalchemy/ansible-prometheus/pull/274) ([paulfantom](https://github.com/paulfantom)) + +## [2.14.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-15) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#265](https://github.com/cloudalchemy/ansible-prometheus/pull/265) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Do not manage system directory [\#263](https://github.com/cloudalchemy/ansible-prometheus/pull/263) ([paulfantom](https://github.com/paulfantom)) +- Add binary install directory [\#259](https://github.com/cloudalchemy/ansible-prometheus/pull/259) ([guimaluf](https://github.com/guimaluf)) + +## [2.13.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-20) +**Merged pull requests:** + +- \[REPO SYNC\] Merge pull request \#4 from cloudalchemy/travis\_fix [\#260](https://github.com/cloudalchemy/ansible-prometheus/pull/260) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Improve checksum fetching [\#254](https://github.com/cloudalchemy/ansible-prometheus/pull/254) ([SuperQ](https://github.com/SuperQ)) + +## [2.13.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-11) +**Fixed bugs:** + +- prometheus\_version: latest =\> failed to get sha256sums.txt [\#230](https://github.com/cloudalchemy/ansible-prometheus/issues/230) + +**Merged pull requests:** + +- Switch user login shell to /usr/sbin/nologin [\#258](https://github.com/cloudalchemy/ansible-prometheus/pull/258) ([paulfantom](https://github.com/paulfantom)) + +## [2.13.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-08) +**Closed issues:** + +- Use python3-libselinux instead of libselinux-python on RHEL8/CentOS8 [\#244](https://github.com/cloudalchemy/ansible-prometheus/issues/244) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#256](https://github.com/cloudalchemy/ansible-prometheus/pull/256) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] use latest available python [\#255](https://github.com/cloudalchemy/ansible-prometheus/pull/255) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#253](https://github.com/cloudalchemy/ansible-prometheus/pull/253) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#252](https://github.com/cloudalchemy/ansible-prometheus/pull/252) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] remove IRC link [\#251](https://github.com/cloudalchemy/ansible-prometheus/pull/251) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Fix typo [\#249](https://github.com/cloudalchemy/ansible-prometheus/pull/249) ([Mehonoshin](https://github.com/Mehonoshin)) +- Add CentOS/CentOS-8 support [\#248](https://github.com/cloudalchemy/ansible-prometheus/pull/248) ([ggatward](https://github.com/ggatward)) +- \[REPO SYNC\] add declarative label sync; add autolabelling PRs [\#243](https://github.com/cloudalchemy/ansible-prometheus/pull/243) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] molecule: use CI images from quay.io instead of dockerhub [\#241](https://github.com/cloudalchemy/ansible-prometheus/pull/241) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- add option to propagate binaries without access to internet [\#239](https://github.com/cloudalchemy/ansible-prometheus/pull/239) ([paulfantom](https://github.com/paulfantom)) + +## [2.12.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-11-13) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#240](https://github.com/cloudalchemy/ansible-prometheus/pull/240) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] Update releaser.sh [\#236](https://github.com/cloudalchemy/ansible-prometheus/pull/236) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] add support for CentOS8 [\#233](https://github.com/cloudalchemy/ansible-prometheus/pull/233) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#232](https://github.com/cloudalchemy/ansible-prometheus/pull/232) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.11.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-10-05) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#231](https://github.com/cloudalchemy/ansible-prometheus/pull/231) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Synchronize files from cloudalchemy/skeleton [\#227](https://github.com/cloudalchemy/ansible-prometheus/pull/227) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- add RHEL8 and debian buster support; remove testing on debian jessie [\#226](https://github.com/cloudalchemy/ansible-prometheus/pull/226) ([paulfantom](https://github.com/paulfantom)) +- Some "false" were incorrectly substituted to "no" [\#225](https://github.com/cloudalchemy/ansible-prometheus/pull/225) ([wzyboy](https://github.com/wzyboy)) +- Update minimum required ansible version [\#224](https://github.com/cloudalchemy/ansible-prometheus/pull/224) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Moving to python 3 and dropping support for python 2.x \(on deployer host\) [\#223](https://github.com/cloudalchemy/ansible-prometheus/pull/223) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.10.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-08-19) +**Implemented enhancements:** + +- Support recording rules without alerts [\#192](https://github.com/cloudalchemy/ansible-prometheus/issues/192) + +**Fixed bugs:** + +- Prometheus failed to start on Ubuntu 18.04: LimitNOFILE: Operation not permitted [\#190](https://github.com/cloudalchemy/ansible-prometheus/issues/190) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#221](https://github.com/cloudalchemy/ansible-prometheus/pull/221) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Synchronize files from cloudalchemy/skeleton [\#220](https://github.com/cloudalchemy/ansible-prometheus/pull/220) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Allow specifying recording rules without alerting configuration [\#212](https://github.com/cloudalchemy/ansible-prometheus/pull/212) ([paulfantom](https://github.com/paulfantom)) + +## [2.9.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-08-14) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#219](https://github.com/cloudalchemy/ansible-prometheus/pull/219) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#217](https://github.com/cloudalchemy/ansible-prometheus/pull/217) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.9.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-07-11) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#216](https://github.com/cloudalchemy/ansible-prometheus/pull/216) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.9.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-05-27) +**Closed issues:** + +- prometheus\_alert\_rules\_files link is broken [\#207](https://github.com/cloudalchemy/ansible-prometheus/issues/207) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#209](https://github.com/cloudalchemy/ansible-prometheus/pull/209) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- add watchdog and clock skew alerts [\#206](https://github.com/cloudalchemy/ansible-prometheus/pull/206) ([paulfantom](https://github.com/paulfantom)) + +## [2.9.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-05-04) +**Fixed bugs:** + +- Default CriticalDiskSpace alert using wrong label? [\#201](https://github.com/cloudalchemy/ansible-prometheus/issues/201) + +**Merged pull requests:** + +- Synchronize files from cloudalchemy/skeleton [\#205](https://github.com/cloudalchemy/ansible-prometheus/pull/205) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Wait for network to be online [\#204](https://github.com/cloudalchemy/ansible-prometheus/pull/204) ([paulfantom](https://github.com/paulfantom)) +- New prometheus/prometheus upstream release! [\#203](https://github.com/cloudalchemy/ansible-prometheus/pull/203) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Update label for CriticalDiskSpace alert expression. [\#202](https://github.com/cloudalchemy/ansible-prometheus/pull/202) ([mjbnz](https://github.com/mjbnz)) +- New prometheus/prometheus upstream release! [\#200](https://github.com/cloudalchemy/ansible-prometheus/pull/200) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.8.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-30) +**Merged pull requests:** + +- set go\_arch as a var instead of calculating it during task execution [\#198](https://github.com/cloudalchemy/ansible-prometheus/pull/198) ([paulfantom](https://github.com/paulfantom)) +- New prometheus/prometheus upstream release! [\#197](https://github.com/cloudalchemy/ansible-prometheus/pull/197) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Synchronize files from cloudalchemy/skeleton. [\#196](https://github.com/cloudalchemy/ansible-prometheus/pull/196) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.8.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-23) +**Implemented enhancements:** + +- Get more recognition! [\#131](https://github.com/cloudalchemy/ansible-prometheus/issues/131) + +**Fixed bugs:** + +- Get more recognition! [\#131](https://github.com/cloudalchemy/ansible-prometheus/issues/131) + +**Closed issues:** + +- can't create prometheus user again [\#185](https://github.com/cloudalchemy/ansible-prometheus/issues/185) +- Implement Uninstalls based on specific variables [\#181](https://github.com/cloudalchemy/ansible-prometheus/issues/181) +- Allow Multiple blackbox exporters [\#179](https://github.com/cloudalchemy/ansible-prometheus/issues/179) +- Install prometheus using docker [\#173](https://github.com/cloudalchemy/ansible-prometheus/issues/173) + +**Merged pull requests:** + +- New prometheus upstream release! [\#193](https://github.com/cloudalchemy/ansible-prometheus/pull/193) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- prometheus.service.j2: stop using tests as filters [\#191](https://github.com/cloudalchemy/ansible-prometheus/pull/191) ([JordanP](https://github.com/JordanP)) +- Preflight checks refactor [\#189](https://github.com/cloudalchemy/ansible-prometheus/pull/189) ([paulfantom](https://github.com/paulfantom)) +- do not remove '/opt/prometheus' [\#188](https://github.com/cloudalchemy/ansible-prometheus/pull/188) ([paulfantom](https://github.com/paulfantom)) +- Parameterise custom static targets file paths [\#187](https://github.com/cloudalchemy/ansible-prometheus/pull/187) ([hamishforbes](https://github.com/hamishforbes)) +- Make prometheus user owner of prometheus folders [\#174](https://github.com/cloudalchemy/ansible-prometheus/pull/174) ([curantes](https://github.com/curantes)) + +## [2.7.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-04) +**Merged pull requests:** + +- New prometheus upstream release! [\#186](https://github.com/cloudalchemy/ansible-prometheus/pull/186) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Reworked prometheus\_alert\_rules\_files [\#183](https://github.com/cloudalchemy/ansible-prometheus/pull/183) ([eRadical](https://github.com/eRadical)) +- Separate test scenarios and run "privileged" one only on master branch [\#175](https://github.com/cloudalchemy/ansible-prometheus/pull/175) ([paulfantom](https://github.com/paulfantom)) + +## [2.6.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-02-19) +**Merged pull requests:** + +- Add support for retention by size [\#182](https://github.com/cloudalchemy/ansible-prometheus/pull/182) ([SuperQ](https://github.com/SuperQ)) + +## [2.5.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-31) +## [2.5.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-30) +**Closed issues:** + +- Allow specifying source url for Prometheus archive [\#176](https://github.com/cloudalchemy/ansible-prometheus/issues/176) + +**Merged pull requests:** + +- New prometheus upstream release! [\#178](https://github.com/cloudalchemy/ansible-prometheus/pull/178) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus upstream release! [\#172](https://github.com/cloudalchemy/ansible-prometheus/pull/172) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.5.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-13) +**Fixed bugs:** + +- Default rules not working correctly [\#157](https://github.com/cloudalchemy/ansible-prometheus/issues/157) + +**Closed issues:** + +- Executable HTML files in consoles and console\_libraries in prometheus\_config\_dir [\#168](https://github.com/cloudalchemy/ansible-prometheus/issues/168) +- Wrong home directory for the prometheus user [\#166](https://github.com/cloudalchemy/ansible-prometheus/issues/166) +- Autostart fails [\#162](https://github.com/cloudalchemy/ansible-prometheus/issues/162) +- prometheus\_alert\_rules are not copied as expected [\#148](https://github.com/cloudalchemy/ansible-prometheus/issues/148) + +**Merged pull requests:** + +- Change permissions of console templates to 0644. [\#171](https://github.com/cloudalchemy/ansible-prometheus/pull/171) ([dreig](https://github.com/dreig)) +- Reuse `prometheus\_db\_dir` as prometheus user home directory [\#170](https://github.com/cloudalchemy/ansible-prometheus/pull/170) ([paulfantom](https://github.com/paulfantom)) +- New prometheus upstream release! [\#167](https://github.com/cloudalchemy/ansible-prometheus/pull/167) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Alert expression fix [\#161](https://github.com/cloudalchemy/ansible-prometheus/pull/161) ([sjal](https://github.com/sjal)) +- Fix running Dry Mode and improved tag usage [\#160](https://github.com/cloudalchemy/ansible-prometheus/pull/160) ([krzyzakp](https://github.com/krzyzakp)) +- New prometheus upstream release! [\#159](https://github.com/cloudalchemy/ansible-prometheus/pull/159) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.4.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-29) +**Closed issues:** + +- When used on GCE with gce\_sd\_config discovery scrape config, the ProtectHome=Yes option prevents Prometheus to discover Google Cloud Instances [\#153](https://github.com/cloudalchemy/ansible-prometheus/issues/153) + +**Merged pull requests:** + +- Add clarification surrounding when the .rules file is copied & where it goes [\#156](https://github.com/cloudalchemy/ansible-prometheus/pull/156) ([wbh1](https://github.com/wbh1)) +- Resolves \#153 prometheus homedir set to /tmp [\#155](https://github.com/cloudalchemy/ansible-prometheus/pull/155) ([michalklempa](https://github.com/michalklempa)) +- Document alert relabeling in README.md [\#152](https://github.com/cloudalchemy/ansible-prometheus/pull/152) ([juliusv](https://github.com/juliusv)) + +## [2.4.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-07) +**Merged pull requests:** + +- Add support for alert relabeling [\#151](https://github.com/cloudalchemy/ansible-prometheus/pull/151) ([juliusv](https://github.com/juliusv)) + +## [2.3.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-05) +**Merged pull requests:** + +- New prometheus upstream release! [\#150](https://github.com/cloudalchemy/ansible-prometheus/pull/150) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- move to ansible 2.7 [\#149](https://github.com/cloudalchemy/ansible-prometheus/pull/149) ([paulfantom](https://github.com/paulfantom)) +- Fixed adding ansible comment in templates [\#147](https://github.com/cloudalchemy/ansible-prometheus/pull/147) ([carpenterbees](https://github.com/carpenterbees)) +- Updates to set systemd ulimit for files to infinity [\#146](https://github.com/cloudalchemy/ansible-prometheus/pull/146) ([jalev](https://github.com/jalev)) +- New prometheus upstream release! [\#145](https://github.com/cloudalchemy/ansible-prometheus/pull/145) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- update prometheus release [\#143](https://github.com/cloudalchemy/ansible-prometheus/pull/143) ([paulfantom](https://github.com/paulfantom)) +- fix test condition [\#141](https://github.com/cloudalchemy/ansible-prometheus/pull/141) ([paulfantom](https://github.com/paulfantom)) +- New prometheus upstream release! [\#140](https://github.com/cloudalchemy/ansible-prometheus/pull/140) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.3.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-09-06) +**Merged pull requests:** + +- Missing protocol causes wrong url generated [\#137](https://github.com/cloudalchemy/ansible-prometheus/pull/137) ([sparanoid](https://github.com/sparanoid)) + +## [2.3.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-08-12) +**Closed issues:** + +- \[Question\] can't specify blackbox as target [\#134](https://github.com/cloudalchemy/ansible-prometheus/issues/134) +- failed parsing YAML File [\#129](https://github.com/cloudalchemy/ansible-prometheus/issues/129) + +**Merged pull requests:** + +- New prometheus upstream release! [\#136](https://github.com/cloudalchemy/ansible-prometheus/pull/136) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- fixed typo [\#133](https://github.com/cloudalchemy/ansible-prometheus/pull/133) ([shibumi](https://github.com/shibumi)) + +## [2.3.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-07-15) +**Merged pull requests:** + +- Fix custom rule/target file copy [\#132](https://github.com/cloudalchemy/ansible-prometheus/pull/132) ([SuperQ](https://github.com/SuperQ)) + +## [2.3.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-07-01) +**Fixed bugs:** + +- Adding prometheus\_config\_flags\_extra without value [\#127](https://github.com/cloudalchemy/ansible-prometheus/issues/127) + +**Merged pull requests:** + +- use tox, ansible 2.6, and allow using remote docker host [\#130](https://github.com/cloudalchemy/ansible-prometheus/pull/130) ([paulfantom](https://github.com/paulfantom)) + +## [2.2.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-27) +**Merged pull requests:** + +- Allow empty value in config\_flags\_extra [\#128](https://github.com/cloudalchemy/ansible-prometheus/pull/128) ([Turgon37](https://github.com/Turgon37)) +- Allow role being run in check mode [\#126](https://github.com/cloudalchemy/ansible-prometheus/pull/126) ([joelpet](https://github.com/joelpet)) +- add 'tags' support [\#125](https://github.com/cloudalchemy/ansible-prometheus/pull/125) ([soloradish](https://github.com/soloradish)) + +## [2.2.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-09) +**Merged pull requests:** + +- Prometheus 2.3.0 [\#124](https://github.com/cloudalchemy/ansible-prometheus/pull/124) ([paulfantom](https://github.com/paulfantom)) +- fix prometheus\_targets default value. [\#123](https://github.com/cloudalchemy/ansible-prometheus/pull/123) ([soloradish](https://github.com/soloradish)) + +## [2.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-02) +**Merged pull requests:** + +- Let prometheus rule\_files config always be written [\#122](https://github.com/cloudalchemy/ansible-prometheus/pull/122) ([noraab](https://github.com/noraab)) +- specify file name for dest in get\_url call [\#121](https://github.com/cloudalchemy/ansible-prometheus/pull/121) ([sarphram](https://github.com/sarphram)) + +## [2.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-27) +**Fixed bugs:** + +- fix architecture var parsing [\#119](https://github.com/cloudalchemy/ansible-prometheus/pull/119) ([paulfantom](https://github.com/paulfantom)) + +**Closed issues:** + +- Rate limiter in GitHub API [\#115](https://github.com/cloudalchemy/ansible-prometheus/issues/115) + +**Merged pull requests:** + +- use cloudalchemybot when accessing github api [\#120](https://github.com/cloudalchemy/ansible-prometheus/pull/120) ([paulfantom](https://github.com/paulfantom)) + +## [2.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-25) +**Fixed bugs:** + +- Error creating systemd template [\#116](https://github.com/cloudalchemy/ansible-prometheus/issues/116) + +**Merged pull requests:** + +- Deploy console templates [\#118](https://github.com/cloudalchemy/ansible-prometheus/pull/118) ([SuperQ](https://github.com/SuperQ)) +- fix condition in systemd template [\#117](https://github.com/cloudalchemy/ansible-prometheus/pull/117) ([Morsicus](https://github.com/Morsicus)) + +## [2.0.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-17) +**Implemented enhancements:** + +- Provide checksum validation [\#104](https://github.com/cloudalchemy/ansible-prometheus/issues/104) +- Move to molecule 2.x [\#93](https://github.com/cloudalchemy/ansible-prometheus/issues/93) +- Hardening systemd unit for additional security [\#110](https://github.com/cloudalchemy/ansible-prometheus/pull/110) ([paulfantom](https://github.com/paulfantom)) + +**Fixed bugs:** + +- Role fails on RedHat if SELinux is disabled [\#111](https://github.com/cloudalchemy/ansible-prometheus/issues/111) +- Can't download release due to Github redirect the request [\#101](https://github.com/cloudalchemy/ansible-prometheus/issues/101) + +**Closed issues:** + +- Explain how `prometheus\_targets` and `prometheus\_scrape\_config` work [\#105](https://github.com/cloudalchemy/ansible-prometheus/issues/105) + +**Merged pull requests:** + +- take care of SELinux only when it is enabled [\#112](https://github.com/cloudalchemy/ansible-prometheus/pull/112) ([paulfantom](https://github.com/paulfantom)) +- add checksum verification [\#109](https://github.com/cloudalchemy/ansible-prometheus/pull/109) ([paulfantom](https://github.com/paulfantom)) +- move to molecule 2.x [\#108](https://github.com/cloudalchemy/ansible-prometheus/pull/108) ([paulfantom](https://github.com/paulfantom)) +- Offer a better IRC Web clients to users [\#107](https://github.com/cloudalchemy/ansible-prometheus/pull/107) ([Porkepix](https://github.com/Porkepix)) +- Explain how to use prometheus\_targets and prometheus\_scrape\_configs [\#114](https://github.com/cloudalchemy/ansible-prometheus/pull/114) ([paulfantom](https://github.com/paulfantom)) +- Remove prometheus 1.8 support [\#113](https://github.com/cloudalchemy/ansible-prometheus/pull/113) ([paulfantom](https://github.com/paulfantom)) + +## [1.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-20) +**Merged pull requests:** + +- Fix version\_compare warnings [\#106](https://github.com/cloudalchemy/ansible-prometheus/pull/106) ([Porkepix](https://github.com/Porkepix)) +- Separate downloading and unpacking prometheus archive [\#102](https://github.com/cloudalchemy/ansible-prometheus/pull/102) ([paulfantom](https://github.com/paulfantom)) + +## [1.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-17) +**Implemented enhancements:** + +- Allow specifying `latest` version [\#90](https://github.com/cloudalchemy/ansible-prometheus/issues/90) + +**Merged pull requests:** + +- fast-finish failed travis builds [\#100](https://github.com/cloudalchemy/ansible-prometheus/pull/100) ([paulfantom](https://github.com/paulfantom)) +- Use inline template for simpler targets population task [\#99](https://github.com/cloudalchemy/ansible-prometheus/pull/99) ([paulfantom](https://github.com/paulfantom)) + +## [1.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-13) +**Merged pull requests:** + +- allow `latest` as prometheus\_version [\#94](https://github.com/cloudalchemy/ansible-prometheus/pull/94) ([paulfantom](https://github.com/paulfantom)) +- add header for auto.sh script [\#92](https://github.com/cloudalchemy/ansible-prometheus/pull/92) ([paulfantom](https://github.com/paulfantom)) +- Add synchronization of changelog and GitHub releases [\#91](https://github.com/cloudalchemy/ansible-prometheus/pull/91) ([paulfantom](https://github.com/paulfantom)) +- CI automation scripts outsourcing [\#89](https://github.com/cloudalchemy/ansible-prometheus/pull/89) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.10](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-10) +**Merged pull requests:** + +- use new filter schema [\#88](https://github.com/cloudalchemy/ansible-prometheus/pull/88) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-07) +**Merged pull requests:** + +- Quick fix to allow multi-arch environments support [\#87](https://github.com/cloudalchemy/ansible-prometheus/pull/87) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.8](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-05) +**Merged pull requests:** + +- Retry when connecting to external services [\#86](https://github.com/cloudalchemy/ansible-prometheus/pull/86) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-03) +**Merged pull requests:** + +- test parametrization [\#85](https://github.com/cloudalchemy/ansible-prometheus/pull/85) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-26) +**Merged pull requests:** + +- Ubuntu bionic \(18.04\) support [\#82](https://github.com/cloudalchemy/ansible-prometheus/pull/82) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-24) +**Merged pull requests:** + +- ansible 2.5 [\#84](https://github.com/cloudalchemy/ansible-prometheus/pull/84) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-22) +**Merged pull requests:** + +- Modify when-statement to not include jinja2 templating delimiters [\#83](https://github.com/cloudalchemy/ansible-prometheus/pull/83) ([swesterveld](https://github.com/swesterveld)) + +## [1.0.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-15) +## [1.0.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-15) +**Merged pull requests:** + +- Describe jmespath installation to virtualenv [\#81](https://github.com/cloudalchemy/ansible-prometheus/pull/81) ([bngsudheer](https://github.com/bngsudheer)) +- SELinux support [\#79](https://github.com/cloudalchemy/ansible-prometheus/pull/79) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-09) +**Merged pull requests:** + +- bump prometheus version to 2.2 [\#80](https://github.com/cloudalchemy/ansible-prometheus/pull/80) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-25) +**Implemented enhancements:** + +- Support remote read option [\#73](https://github.com/cloudalchemy/ansible-prometheus/issues/73) +- Run Prometheus server without alertmanager option [\#18](https://github.com/cloudalchemy/ansible-prometheus/issues/18) + +**Fixed bugs:** + +- Wrong directory permissions [\#74](https://github.com/cloudalchemy/ansible-prometheus/issues/74) +- metrics\_path for local Prometheus endpoint [\#19](https://github.com/cloudalchemy/ansible-prometheus/issues/19) +- Wrong indent [\#36](https://github.com/cloudalchemy/ansible-prometheus/pull/36) ([paulfantom](https://github.com/paulfantom)) + +**Closed issues:** + +- Allow multiple targets templates files. [\#58](https://github.com/cloudalchemy/ansible-prometheus/issues/58) +- Outdated documentation [\#1](https://github.com/cloudalchemy/ansible-prometheus/issues/1) + +**Merged pull requests:** + +- Custom target and rule files [\#59](https://github.com/cloudalchemy/ansible-prometheus/pull/59) ([paulfantom](https://github.com/paulfantom)) + +## [0.12.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-14) +**Merged pull requests:** + +- Fix typo [\#78](https://github.com/cloudalchemy/ansible-prometheus/pull/78) ([swesterveld](https://github.com/swesterveld)) + +## [0.12.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-14) +**Merged pull requests:** + +- Make Prometheus daemon restart/reload with sudo privileges. [\#77](https://github.com/cloudalchemy/ansible-prometheus/pull/77) ([swesterveld](https://github.com/swesterveld)) + +## [0.12.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-11) +**Merged pull requests:** + +- add remote\_read functionality [\#76](https://github.com/cloudalchemy/ansible-prometheus/pull/76) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-10) +**Fixed bugs:** + +- change file permissions and ditch prometheus\_root\_dir [\#75](https://github.com/cloudalchemy/ansible-prometheus/pull/75) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-10) +**Merged pull requests:** + +- specify which tasks should use superuser permissions [\#72](https://github.com/cloudalchemy/ansible-prometheus/pull/72) ([paulfantom](https://github.com/paulfantom)) +- adapt prometheus binary placement to hier\(7\) [\#71](https://github.com/cloudalchemy/ansible-prometheus/pull/71) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-07) +**Closed issues:** + +- File copy globbing [\#57](https://github.com/cloudalchemy/ansible-prometheus/issues/57) + +**Merged pull requests:** + +- Enable check mode in ansible [\#70](https://github.com/cloudalchemy/ansible-prometheus/pull/70) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-06) +## [0.11.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-03) +**Merged pull requests:** + +- Add support for remote write [\#69](https://github.com/cloudalchemy/ansible-prometheus/pull/69) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-03) +**Merged pull requests:** + +- Update ansible versions in tests [\#68](https://github.com/cloudalchemy/ansible-prometheus/pull/68) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-22) +**Merged pull requests:** + +- Set global values to prometheus defaults [\#67](https://github.com/cloudalchemy/ansible-prometheus/pull/67) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-20) +**Implemented enhancements:** + +- Add default CriticalRAMLoad alert rules [\#63](https://github.com/cloudalchemy/ansible-prometheus/issues/63) + +**Merged pull requests:** + +- Prometheus 2.1 [\#66](https://github.com/cloudalchemy/ansible-prometheus/pull/66) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-17) +**Merged pull requests:** + +- added CriticalRAMLoad [\#65](https://github.com/cloudalchemy/ansible-prometheus/pull/65) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.10.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-17) +**Merged pull requests:** + +- a little bit of python3 support [\#64](https://github.com/cloudalchemy/ansible-prometheus/pull/64) ([aeber](https://github.com/aeber)) + +## [0.10.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-16) +**Closed issues:** + +- More preflight checks? [\#16](https://github.com/cloudalchemy/ansible-prometheus/issues/16) + +**Merged pull requests:** + +- validate prometheus\_config\_flags\_extra [\#62](https://github.com/cloudalchemy/ansible-prometheus/pull/62) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-15) +**Implemented enhancements:** + +- Support more operating systems in CI pipeline and meta/main.yml [\#42](https://github.com/cloudalchemy/ansible-prometheus/issues/42) + +**Merged pull requests:** + +- \[ci skip\] author info [\#61](https://github.com/cloudalchemy/ansible-prometheus/pull/61) ([paulfantom](https://github.com/paulfantom)) +- multiple target files loaded with file\_sd [\#60](https://github.com/cloudalchemy/ansible-prometheus/pull/60) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-13) +**Merged pull requests:** + +- use custom docker images in CI pipeline [\#43](https://github.com/cloudalchemy/ansible-prometheus/pull/43) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-11) +**Merged pull requests:** + +- cleaner tests [\#55](https://github.com/cloudalchemy/ansible-prometheus/pull/55) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-07) +**Closed issues:** + +- Convert scrape\_configs to simple attribute tree [\#45](https://github.com/cloudalchemy/ansible-prometheus/issues/45) + +**Merged pull requests:** + +- added i386 arch [\#54](https://github.com/cloudalchemy/ansible-prometheus/pull/54) ([rdemachkovych](https://github.com/rdemachkovych)) +- Update README.md [\#53](https://github.com/cloudalchemy/ansible-prometheus/pull/53) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-03) +**Closed issues:** + +- What version of molecule are the tests written for? [\#44](https://github.com/cloudalchemy/ansible-prometheus/issues/44) + +**Merged pull requests:** + +- Update generatetag.sh [\#52](https://github.com/cloudalchemy/ansible-prometheus/pull/52) ([paulfantom](https://github.com/paulfantom)) +- Simplify scrape configs [\#50](https://github.com/cloudalchemy/ansible-prometheus/pull/50) ([SuperQ](https://github.com/SuperQ)) + +## [0.9.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-02) +**Merged pull requests:** + +- Docs [\#51](https://github.com/cloudalchemy/ansible-prometheus/pull/51) ([paulfantom](https://github.com/paulfantom)) + +## [0.8.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-02) +**Merged pull requests:** + +- Update generatetag.sh [\#49](https://github.com/cloudalchemy/ansible-prometheus/pull/49) ([paulfantom](https://github.com/paulfantom)) +- support older raspberry pi [\#48](https://github.com/cloudalchemy/ansible-prometheus/pull/48) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.14](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-31) +**Merged pull requests:** + +- Add link to demo site [\#47](https://github.com/cloudalchemy/ansible-prometheus/pull/47) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.13](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-30) +**Merged pull requests:** + +- Clean scrape config [\#46](https://github.com/cloudalchemy/ansible-prometheus/pull/46) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.12](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-27) +**Merged pull requests:** + +- armv7l ansible arch translates to armv7 go arch [\#41](https://github.com/cloudalchemy/ansible-prometheus/pull/41) ([anisse](https://github.com/anisse)) + +## [0.7.11](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-27) +**Merged pull requests:** + +- storage retention [\#40](https://github.com/cloudalchemy/ansible-prometheus/pull/40) ([paulfantom](https://github.com/paulfantom)) +- change alert rules name; take rules from wildcard [\#38](https://github.com/cloudalchemy/ansible-prometheus/pull/38) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.10](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-22) +**Merged pull requests:** + +- Update README.md [\#39](https://github.com/cloudalchemy/ansible-prometheus/pull/39) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-18) +**Implemented enhancements:** + +- metrics\_path for local Prometheus endpoint [\#27](https://github.com/cloudalchemy/ansible-prometheus/issues/27) + +**Merged pull requests:** + +- Fix default port for alertmanager [\#37](https://github.com/cloudalchemy/ansible-prometheus/pull/37) ([paulfantom](https://github.com/paulfantom)) +- do not copy alert rules when there are none [\#35](https://github.com/cloudalchemy/ansible-prometheus/pull/35) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.8](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) +**Merged pull requests:** + +- Issue27 [\#32](https://github.com/cloudalchemy/ansible-prometheus/pull/32) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) +**Merged pull requests:** + +- add disk usage alert and reboot alert [\#31](https://github.com/cloudalchemy/ansible-prometheus/pull/31) ([paulfantom](https://github.com/paulfantom)) +- add comments; clear README [\#30](https://github.com/cloudalchemy/ansible-prometheus/pull/30) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) +**Merged pull requests:** + +- CI fix [\#29](https://github.com/cloudalchemy/ansible-prometheus/pull/29) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) +**Merged pull requests:** + +- leave empty prometheus\_web\_external\_url for default [\#28](https://github.com/cloudalchemy/ansible-prometheus/pull/28) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.7.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) +**Merged pull requests:** + +- metrics path [\#24](https://github.com/cloudalchemy/ansible-prometheus/pull/24) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) +**Closed issues:** + +- Use systemd for service control [\#25](https://github.com/cloudalchemy/ansible-prometheus/issues/25) + +**Merged pull requests:** + +- fully switch to systemd module [\#26](https://github.com/cloudalchemy/ansible-prometheus/pull/26) ([paulfantom](https://github.com/paulfantom)) +- auto set go architecture [\#23](https://github.com/cloudalchemy/ansible-prometheus/pull/23) ([paulfantom](https://github.com/paulfantom)) +- simplify setting custom configuration file [\#21](https://github.com/cloudalchemy/ansible-prometheus/pull/21) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-08) +**Merged pull requests:** + +- Add newline before \[Unit\] section in service file [\#20](https://github.com/cloudalchemy/ansible-prometheus/pull/20) ([ecksun](https://github.com/ecksun)) + +## [0.7.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-06) +**Closed issues:** + +- Debian support [\#3](https://github.com/cloudalchemy/ansible-prometheus/issues/3) +- Better handling of alerting rules [\#2](https://github.com/cloudalchemy/ansible-prometheus/issues/2) + +**Merged pull requests:** + +- Update README.md [\#17](https://github.com/cloudalchemy/ansible-prometheus/pull/17) ([paulfantom](https://github.com/paulfantom)) +- Typo [\#14](https://github.com/cloudalchemy/ansible-prometheus/pull/14) ([paulfantom](https://github.com/paulfantom)) +- Stop pipeline on any error [\#13](https://github.com/cloudalchemy/ansible-prometheus/pull/13) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-01) +**Merged pull requests:** + +- Alert rules and debian support [\#11](https://github.com/cloudalchemy/ansible-prometheus/pull/11) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.12](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-01) +**Merged pull requests:** + +- Fix tagging [\#12](https://github.com/cloudalchemy/ansible-prometheus/pull/12) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.11](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-30) +**Merged pull requests:** + +- Prometheus job [\#10](https://github.com/cloudalchemy/ansible-prometheus/pull/10) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.6.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) +**Closed issues:** + +- Parallel CI build [\#4](https://github.com/cloudalchemy/ansible-prometheus/issues/4) + +**Merged pull requests:** + +- Update main.yml [\#9](https://github.com/cloudalchemy/ansible-prometheus/pull/9) ([paulfantom](https://github.com/paulfantom)) +- prometheus\_external\_labels variable assignment dynamically [\#6](https://github.com/cloudalchemy/ansible-prometheus/pull/6) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.6.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) +**Merged pull requests:** + +- Update generatetag.sh [\#8](https://github.com/cloudalchemy/ansible-prometheus/pull/8) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) +**Merged pull requests:** + +- Update generatetag.sh [\#7](https://github.com/cloudalchemy/ansible-prometheus/pull/7) ([paulfantom](https://github.com/paulfantom)) +- test different ansible versions [\#5](https://github.com/cloudalchemy/ansible-prometheus/pull/5) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-23) +## [0.6.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-23) +## [0.6.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) +## [0.6.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) +## [0.6.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) +## [0.5.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-13) +## [0.5.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-13) +## [0.5.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-07) +## [0.5.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-22) +## [0.5.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-17) +## [0.5.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-16) +## [0.4.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-05) +## [0.4.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-09-27) +## [0.3.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-08-21) +## [0.3.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-08-21) +## [0.3.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-21) +## [0.2.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-21) +## [0.1.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) +## [0.1.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) +## [0.1.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) +## [0.1.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-10) +## [0.1.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-20) +## [0.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-14) +## [0.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-13) +## [0.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-06) +## [0.0.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-23) +## [0.0.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-23) +## [0.0.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-15) +## [0.0.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-09) +## [0.0.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-09) +## [0.0.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-04-27) + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/roles/prometheus/CONTRIBUTING.md b/roles/prometheus/CONTRIBUTING.md new file mode 100644 index 00000000..897372dd --- /dev/null +++ b/roles/prometheus/CONTRIBUTING.md @@ -0,0 +1,97 @@ +# Contributor Guideline + +This document provides an overview of how you can participate in improving this project or extending it. We are +grateful for all your help: bug reports and fixes, code contributions, documentation or ideas. Feel free to join, we +appreciate your support!! + +## Communication + +### GitHub repositories + +Much of the issues, goals and ideas are tracked in the respective projects in GitHub. Please use this channel to report +bugs, ask questions, and request new features . + +## git and GitHub + +In order to contribute code please: + +1. Fork the project on GitHub +2. Clone the project +3. Add changes (and tests) +4. Commit and push +5. Create a merge-request + +To have your code merged, see the expectations listed below. + +You can find a well-written guide [here](https://help.github.com/articles/fork-a-repo). + +Please follow common commit best-practices. Be explicit, have a short summary, a well-written description and +references. This is especially important for the merge-request. + +Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCommitMessages) and +[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message). + +## Releases + +We try to stick to semantic versioning and our releases are automated. Release is created by assigning a keyword (in a +way similar to travis [`[ci skip]`](https://docs.travis-ci.com/user/customizing-the-build#Skipping-a-build)) to a +commit with merge request. Available keywords are (square brackets are important!): + +* `[patch]`, `[fix]` - for PATCH version release +* `[minor]`, `[feature]`, `[feat]` - for MINOR version release +* `[major]`, `[breaking change]` - for MAJOR version release + +## Changelog + +Changelog is generateg automatically on every merged Pull Request and all information is taken from github issues, PRs +and labels. + +## Expectations + +### Keep it simple + +We try to provide production ready ansible roles which should be as much zero-conf as possible but this doesn't mean to +overcomplicate things. Just follow [KISS](https://en.wikipedia.org/wiki/KISS_principle). + +### Be explicit + +* Please avoid using nonsensical property and variable names. +* Use self-describing attribute names for user configuration. +* In case of failures, communicate what happened and why a failure occurs to the user. Make it easy to track the code +or action that produced the error. Try to catch and handle errors if possible to provide improved failure messages. + + +### Add tests + +We are striving to use at least two test scenarios located in [/molecule](molecule) directory. First one +([default](molecule/default)) is testing default configuration without any additional variables, second one +([alternative](molecule/alternative)) is testing what happens when many variables from +[/defaults/main.yml](defaults/main.yml) are changed. When adding new functionalities please add tests to proper +scenarios. Tests are written in testinfra framework and are located in `/tests` subdirectory of scenario directory +(for example default tests are in [/molecule/default/tests](molecule/default/tests)). +More information about: + - [testinfra](http://testinfra.readthedocs.io/en/latest/index.html) + - [molecule](https://molecule.readthedocs.io/en/latest/index.html) + +### Follow best practices + +Please follow [ansible best practices](http://docs.ansible.com/ansible/latest/playbooks_best_practices.html) and +especially provide meaningful names to tasks and even comments where needed. + +Our test framework automatically lints code with [`yamllint`](https://yamllint.readthedocs.io) and +[`ansible-lint`](https://github.com/willthames/ansible-lint) programs so be sure to follow their rules. + +Remember: Code is generally read much more often than written. + +### Use Markdown + +Wherever possible, please refrain from any other formats and stick to simple markdown. + +## Requirements regarding roles design + +We are trying to create the best and most secure installation method for non-containerized prometheus stack components. +To accomplish this all roles need to support: + +- current and at least one previous ansible version (wherever possible we try to support 2 previous ansible versions) +- systemd as the only available process manager +- at least latest debian and CentOS distributions diff --git a/roles/prometheus/LICENSE b/roles/prometheus/LICENSE new file mode 100644 index 00000000..353992c6 --- /dev/null +++ b/roles/prometheus/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017-2018 Pawel Krupa, Roman Demachkovych + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/roles/prometheus/README.md b/roles/prometheus/README.md new file mode 100644 index 00000000..b3279d36 --- /dev/null +++ b/roles/prometheus/README.md @@ -0,0 +1,156 @@ +

prometheus logo

+ +# Ansible Role: prometheus + +[![Build Status](https://travis-ci.org/cloudalchemy/ansible-prometheus.svg?branch=master)](https://travis-ci.org/cloudalchemy/ansible-prometheus) +[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT) +[![Ansible Role](https://img.shields.io/badge/ansible%20role-cloudalchemy.prometheus-blue.svg)](https://galaxy.ansible.com/cloudalchemy/prometheus/) +[![GitHub tag](https://img.shields.io/github/tag/cloudalchemy/ansible-prometheus.svg)](https://github.com/cloudalchemy/ansible-prometheus/tags) + +## Description + +Deploy [Prometheus](https://github.com/prometheus/prometheus) monitoring system using ansible. + +### Upgradability notice + +When upgrading from <= 2.4.0 version of this role to >= 2.4.1 please turn off your prometheus instance. More in [2.4.1 release notes](https://github.com/cloudalchemy/ansible-prometheus/releases/tag/2.4.1) + +## Requirements + +- Ansible >= 2.7 (It might work on previous versions, but we cannot guarantee it) +- jmespath on deployer machine. If you are using Ansible from a Python virtualenv, install *jmespath* to the same virtualenv via pip. +- gnu-tar on Mac deployer host (`brew install gnu-tar`) + +## Role Variables + +All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below. + +| Name | Default Value | Description | +| -------------- | ------------- | -----------------------------------| +| `prometheus_version` | 2.24.1 | Prometheus package version. Also accepts `latest` as parameter. Only prometheus 2.x is supported | +| `prometheus_skip_install` | false | Prometheus installation tasks gets skipped when set to true. | +| `prometheus_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `prometheus` AND `promtool` binaries are stored on host on which ansible is ran. This overrides `prometheus_version` parameter | +| `prometheus_config_dir` | /etc/prometheus | Path to directory with prometheus configuration | +| `prometheus_db_dir` | /var/lib/prometheus | Path to directory with prometheus database | +| `prometheus_web_listen_address` | "0.0.0.0:9090" | Address on which prometheus will be listening | +| `prometheus_web_external_url` | "" | External address on which prometheus is available. Useful when behind reverse proxy. Ex. `http://example.org/prometheus` | +| `prometheus_storage_retention` | "30d" | Data retention period | +| `prometheus_storage_retention_size` | "0" | Data retention period by size | +| `prometheus_config_flags_extra` | {} | Additional configuration flags passed to prometheus binary at startup | +| `prometheus_alertmanager_config` | [] | Configuration responsible for pointing where alertmanagers are. This should be specified as list in yaml format. It is compatible with official [](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alertmanager_config) | +| `prometheus_alert_relabel_configs` | [] | Alert relabeling rules. This should be specified as list in yaml format. It is compatible with the official [](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alert_relabel_configs) | +| `prometheus_global` | { scrape_interval: 60s, scrape_timeout: 15s, evaluation_interval: 15s } | Prometheus global config. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#configuration-file) | +| `prometheus_remote_write` | [] | Remote write. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) | +| `prometheus_remote_read` | [] | Remote read. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) | +| `prometheus_external_labels` | environment: "{{ ansible_fqdn \| default(ansible_host) \| default(inventory_hostname) }}" | Provide map of additional labels which will be added to any time series or alerts when communicating with external systems | +| `prometheus_targets` | {} | Targets which will be scraped. Better example is provided in our [demo site](https://github.com/cloudalchemy/demo-site/blob/2a8a56fc10ce613d8b08dc8623230dace6704f9a/group_vars/all/vars#L8) | +| `prometheus_scrape_configs` | [defaults/main.yml#L58](https://github.com/cloudalchemy/ansible-prometheus/blob/ff7830d06ba57be1177f2b6fca33a4dd2d97dc20/defaults/main.yml#L47) | Prometheus scrape jobs provided in same format as in [official docs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) | +| `prometheus_config_file` | "prometheus.yml.j2" | Variable used to provide custom prometheus configuration file in form of ansible template | +| `prometheus_alert_rules` | [defaults/main.yml#L81](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L85) | Full list of alerting rules which will be copied to `{{ prometheus_config_dir }}/rules/ansible_managed.rules`. Alerting rules can be also provided by other files located in `{{ prometheus_config_dir }}/rules/` which have `*.rules` extension | +| `prometheus_alert_rules_files` | [defaults/main.yml#L78](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L78) | List of folders where ansible will look for files containing alerting rules which will be copied to `{{ prometheus_config_dir }}/rules/`. Files must have `*.rules` extension | +| `prometheus_static_targets_files` | [defaults/main.yml#L78](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L81) | List of folders where ansible will look for files containing custom static target configuration files which will be copied to `{{ prometheus_config_dir }}/file_sd/`. | + + +### Relation between `prometheus_scrape_configs` and `prometheus_targets` + +#### Short version + +`prometheus_targets` is just a map used to create multiple files located in "{{ prometheus_config_dir }}/file_sd" directory. Where file names are composed from top-level keys in that map with `.yml` suffix. Those files store [file_sd scrape targets data](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#file_sd_config) and they need to be read in `prometheus_scrape_configs`. + +#### Long version + +A part of *prometheus.yml* configuration file which describes what is scraped by prometheus is stored in `prometheus_scrape_configs`. For this variable same configuration options as described in [prometheus docs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) are used. + +Meanwhile `prometheus_targets` is our way of adopting [prometheus scrape type `file_sd`](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#). It defines a map of files with their content. A top-level keys are base names of files which need to have their own scrape job in `prometheus_scrape_configs` and values are a content of those files. + +All this mean that you CAN use custom `prometheus_scrape_configs` with `prometheus_targets` set to `{}`. However when you set anything in `prometheus_targets` it needs to be mapped to `prometheus_scrape_configs`. If it isn't you'll get an error in preflight checks. + +#### Example + +Lets look at our default configuration, which shows all features. By default we have this `prometheus_targets`: +``` +prometheus_targets: + node: # This is a base file name. File is located in "{{ prometheus_config_dir }}/file_sd/<>.yml" + - targets: # + - localhost:9100 # All this is a targets section in file_sd format + labels: # + env: test # +``` +Such config will result in creating one file named `node.yml` in `{{ prometheus_config_dir }}/file_sd` directory. + +Next this file needs to be loaded into scrape config. Here is modified version of our default `prometheus_scrape_configs`: +``` +prometheus_scrape_configs: + - job_name: "prometheus" # Custom scrape job, here using `static_config` + metrics_path: "/metrics" + static_configs: + - targets: + - "localhost:9090" + - job_name: "example-node-file-servicediscovery" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/node.yml" # This line loads file created from `prometheus_targets` +``` + +## Example + +### Playbook + +```yaml +--- +- hosts: all + roles: + - cloudalchemy.prometheus + vars: + prometheus_targets: + node: + - targets: + - localhost:9100 + - demo.cloudalchemy.org:9100 + labels: + env: demosite +``` + +### Demo site + +Prometheus organization provide a demo site for full monitoring solution based on prometheus and grafana. Repository with code and links to running instances is [available on github](https://github.com/prometheus/demo-site). + +### Defining alerting rules files + +Alerting rules are defined in `prometheus_alert_rules` variable. Format is almost identical to one defined in[ Prometheus 2.0 documentation](https://prometheus.io/docs/prometheus/latest/configuration/template_examples/). +Due to similarities in templating engines, every templates should be wrapped in `{% raw %}` and `{% endraw %}` statements. Example is provided in [defaults/main.yml](defaults/main.yml) file. + +## Local Testing + +The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v2.x). You will have to install Docker on your system. See "Get started" for a Docker package suitable to for your system. +We are using tox to simplify process of testing on multiple ansible versions. To install tox execute: +```sh +pip3 install tox +``` +To run tests on all ansible versions (WARNING: this can take some time) +```sh +tox +``` +To run a custom molecule command on custom environment with only default test scenario: +```sh +tox -e py35-ansible28 -- molecule test -s default +``` +For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/). + +If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests. + +## Travis CI + +Combining molecule and travis CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix which will take more time than local testing, so please be patient. + +## Contributing + +See [contributor guideline](CONTRIBUTING.md). + +## Troubleshooting + +See [troubleshooting](TROUBLESHOOTING.md). + +## License + +This project is licensed under MIT License. See [LICENSE](/LICENSE) for more details. diff --git a/roles/prometheus/TROUBLESHOOTING.md b/roles/prometheus/TROUBLESHOOTING.md new file mode 100644 index 00000000..748f6a5f --- /dev/null +++ b/roles/prometheus/TROUBLESHOOTING.md @@ -0,0 +1,3 @@ +# Troubleshooting + + diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml new file mode 100644 index 00000000..dc8a19f1 --- /dev/null +++ b/roles/prometheus/defaults/main.yml @@ -0,0 +1,213 @@ +--- +prometheus_version: 2.24.1 +prometheus_binary_local_dir: '' +prometheus_skip_install: false + +prometheus_config_dir: /etc/prometheus +prometheus_db_dir: /var/lib/prometheus + +prometheus_web_listen_address: "0.0.0.0:9090" +prometheus_web_external_url: '' + +prometheus_storage_retention: "30d" +# Available since Prometheus 2.7.0 +# [EXPERIMENTAL] Maximum number of bytes that can be stored for blocks. Units +# supported: KB, MB, GB, TB, PB. +prometheus_storage_retention_size: "0" + +prometheus_config_flags_extra: {} +# prometheus_config_flags_extra: +# storage.tsdb.retention: 15d +# alertmanager.timeout: 10s + +prometheus_alertmanager_config: [] +# prometheus_alertmanager_config: +# - scheme: https +# path_prefix: alertmanager/ +# basic_auth: +# username: user +# password: pass +# static_configs: +# - targets: ["127.0.0.1:9093"] +# proxy_url: "127.0.0.2" + +prometheus_alert_relabel_configs: [] +# prometheus_alert_relabel_configs: +# - action: labeldrop +# regex: replica + +prometheus_global: + scrape_interval: 15s + scrape_timeout: 10s + evaluation_interval: 15s + +prometheus_remote_write: [] +# prometheus_remote_write: +# - url: https://dev.kausal.co/prom/push +# basic_auth: +# password: FOO + +prometheus_remote_read: [] +# prometheus_remote_read: +# - url: https://demo.cloudalchemy.org:9201/read +# basic_auth: +# password: FOO + +prometheus_external_labels: + environment: "{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}" + +prometheus_targets: {} +# node: +# - targets: +# - localhost:9100 +# labels: +# env: test + +prometheus_scrape_configs: + - job_name: "prometheus" + metrics_path: "{{ prometheus_metrics_path }}" + static_configs: + - targets: + - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" + - job_name: "node" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/node.yml" + +# Alternative config file name, searched in ansible templates path. +prometheus_config_file: 'prometheus.yml.j2' + +prometheus_alert_rules_files: + - prometheus/rules/*.rules + +prometheus_static_targets_files: + - prometheus/targets/*.yml + - prometheus/targets/*.json + +prometheus_alert_rules: + - alert: Watchdog + expr: vector(1) + for: 10m + labels: + severity: warning + annotations: + description: "This is an alert meant to ensure that the entire alerting pipeline is functional.\nThis alert is always firing, therefore it should always be firing in Alertmanager\nand always fire against a receiver. There are integrations with various notification\nmechanisms that send a notification when this alert is not firing. For example the\n\"DeadMansSnitch\" integration in PagerDuty." + summary: 'Ensure entire alerting pipeline is functional' + - alert: InstanceDown + expr: 'up == 0' + for: 5m + labels: + severity: critical + annotations: + description: '{% raw %}{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.{% endraw %}' + summary: '{% raw %}Instance {{ $labels.instance }} down{% endraw %}' + - alert: RebootRequired + expr: 'node_reboot_required > 0' + labels: + severity: warning + annotations: + description: '{% raw %}{{ $labels.instance }} requires a reboot.{% endraw %}' + summary: '{% raw %}Instance {{ $labels.instance }} - reboot required{% endraw %}' + - alert: NodeFilesystemSpaceFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up.{% endraw %}' + summary: 'Filesystem is predicted to run out of space within the next 24 hours.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 40\nand\n predict_linear(node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"}[6h], 24*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemSpaceFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up fast.{% endraw %}' + summary: 'Filesystem is predicted to run out of space within the next 4 hours.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 20\nand\n predict_linear(node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"}[6h], 4*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeFilesystemAlmostOutOfSpace + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.{% endraw %}' + summary: 'Filesystem has less than 5% space left.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 5\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemAlmostOutOfSpace + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.{% endraw %}' + summary: 'Filesystem has less than 3% space left.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 3\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeFilesystemFilesFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up.{% endraw %}' + summary: 'Filesystem is predicted to run out of inodes within the next 24 hours.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 40\nand\n predict_linear(node_filesystem_files_free{job=\"node\",fstype!=\"\"}[6h], 24*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemFilesFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up fast.{% endraw %}' + summary: 'Filesystem is predicted to run out of inodes within the next 4 hours.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 20\nand\n predict_linear(node_filesystem_files_free{job=\"node\",fstype!=\"\"}[6h], 4*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeFilesystemAlmostOutOfFiles + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.{% endraw %}' + summary: 'Filesystem has less than 5% inodes left.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 5\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemAlmostOutOfFiles + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.{% endraw %}' + summary: 'Filesystem has less than 3% inodes left.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 3\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeNetworkReceiveErrs + annotations: + description: '{% raw %}{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} receive errors in the last two minutes.{% endraw %}' + summary: 'Network interface is reporting many receive errors.' + expr: "increase(node_network_receive_errs_total[2m]) > 10\n" + for: 1h + labels: + severity: warning + - alert: NodeNetworkTransmitErrs + annotations: + description: '{% raw %}{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} transmit errors in the last two minutes.{% endraw %}' + summary: 'Network interface is reporting many transmit errors.' + expr: "increase(node_network_transmit_errs_total[2m]) > 10\n" + for: 1h + labels: + severity: warning + - alert: NodeHighNumberConntrackEntriesUsed + annotations: + description: '{% raw %}{{ $value | humanizePercentage }} of conntrack entries are used{% endraw %}' + summary: 'Number of conntrack are getting close to the limit' + expr: "(node_nf_conntrack_entries / node_nf_conntrack_entries_limit) > 0.75\n" + labels: + severity: warning + - alert: NodeClockSkewDetected + annotations: + message: '{% raw %}Clock on {{ $labels.instance }} is out of sync by more than 300s. Ensure NTP is configured correctly on this host.{% endraw %}' + summary: 'Clock skew detected.' + expr: "(\n node_timex_offset_seconds > 0.05\nand\n deriv(node_timex_offset_seconds[5m]) >= 0\n)\nor\n(\n node_timex_offset_seconds < -0.05\nand\n deriv(node_timex_offset_seconds[5m]) <= 0\n)\n" + for: 10m + labels: + severity: warning + - alert: NodeClockNotSynchronising + annotations: + message: '{% raw %}Clock on {{ $labels.instance }} is not synchronising. Ensure NTP is configured on this host.{% endraw %}' + summary: 'Clock not synchronising.' + expr: "min_over_time(node_timex_sync_status[5m]) == 0\n" + for: 10m + labels: + severity: warning diff --git a/roles/prometheus/handlers/main.yml b/roles/prometheus/handlers/main.yml new file mode 100644 index 00000000..aba85189 --- /dev/null +++ b/roles/prometheus/handlers/main.yml @@ -0,0 +1,13 @@ +--- +- name: restart prometheus + become: true + systemd: + daemon_reload: true + name: prometheus + state: restarted + +- name: reload prometheus + become: true + systemd: + name: prometheus + state: reloaded diff --git a/roles/prometheus/meta/main.yml b/roles/prometheus/meta/main.yml new file mode 100644 index 00000000..0fb2b817 --- /dev/null +++ b/roles/prometheus/meta/main.yml @@ -0,0 +1,34 @@ +--- +galaxy_info: + author: Roman Demachkovych, Pawel Krupa + description: Prometheus monitoring system configuration and management + license: MIT + company: none + min_ansible_version: 2.7 + platforms: + - name: Ubuntu + versions: + - bionic + - xenial + - name: Debian + versions: + - stretch + - buster + - name: EL + versions: + - 7 + - 8 + - name: Fedora + versions: + - 30 + - 31 + galaxy_tags: + - monitoring + - prometheus + - metrics + - alerts + - alerting + - molecule + - cloud + +dependencies: [] diff --git a/roles/prometheus/molecule/alternative/molecule.yml b/roles/prometheus/molecule/alternative/molecule.yml new file mode 100644 index 00000000..c03bcf2a --- /dev/null +++ b/roles/prometheus/molecule/alternative/molecule.yml @@ -0,0 +1,70 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: bionic + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: xenial + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: stretch + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-9 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: buster + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-10 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos7 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-7 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos8 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-8 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 + - name: fedora + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:fedora-30 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: playbook.yml + inventory: + group_vars: + python3: + ansible_python_interpreter: /usr/bin/python3 +verifier: + name: testinfra diff --git a/roles/prometheus/molecule/alternative/playbook.yml b/roles/prometheus/molecule/alternative/playbook.yml new file mode 100644 index 00000000..68c46b93 --- /dev/null +++ b/roles/prometheus/molecule/alternative/playbook.yml @@ -0,0 +1,84 @@ +--- +- name: Run role + hosts: all + any_errors_fatal: true + roles: + - ansible-prometheus + vars: + prometheus_binary_local_dir: '/tmp/prometheus-linux-amd64' + prometheus_config_dir: /opt/prom/etc + prometheus_db_dir: /opt/prom/lib + prometheus_web_listen_address: "127.0.0.1:9090" + prometheus_web_external_url: "http://127.0.0.1:9090/prometheus" + prometheus_storage_retention: "60d" + prometheus_storage_retention_size: "1GB" + prometheus_config_flags_extra: + alertmanager.timeout: 10s + web.enable-admin-api: + prometheus_alertmanager_config: + - scheme: https + path_prefix: /alertmanager + basic_auth: + username: user + password: pass + static_configs: + - targets: ["127.0.0.1:9090"] + proxy_url: "127.0.0.2" + prometheus_alert_relabel_configs: + - action: labeldrop + regex: replica + prometheus_global: + scrape_interval: 3s + scrape_timeout: 2s + evaluation_interval: 10s + prometheus_remote_write: + - url: http://influx.cloudalchemy.org:8086/api/v1/prom/write?db=test + basic_auth: + username: prometheus + password: SuperSecret + prometheus_remote_read: + - url: http://influx.cloudalchemy.org:8086/api/v1/prom/read?db=cloudalchemy + prometheus_external_labels: + environment: "alternative" + prometheus_targets: + node: + - targets: + - demo.cloudalchemy.org:9100 + - influx.cloudalchemy.org:9100 + labels: + env: cloudalchemy + docker: + - targets: + - demo.cloudalchemy.org:8080 + - influx.cloudalchemy.org:8080 + labels: + env: cloudalchemy + prometheus_scrape_configs: + - job_name: "prometheus" + metrics_path: "{{ prometheus_metrics_path }}" + static_configs: + - targets: + - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" + - job_name: "node" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/node.yml" + - job_name: "docker" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/docker.yml" + - job_name: 'blackbox' + metrics_path: /probe + params: + module: [http_2xx] + static_configs: + - targets: + - http://demo.cloudalchemy.org:9100 + - http://influx.cloudalchemy.org:9100 + relabel_configs: + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: instance + - target_label: __address__ + replacement: 127.0.0.1:9115 # Blackbox exporter. diff --git a/roles/prometheus/molecule/alternative/prepare.yml b/roles/prometheus/molecule/alternative/prepare.yml new file mode 100644 index 00000000..41962804 --- /dev/null +++ b/roles/prometheus/molecule/alternative/prepare.yml @@ -0,0 +1,37 @@ +--- +- name: Prepare + hosts: localhost + gather_facts: false + vars: + # Version seeds to be specified here as molecule doesn't have access to ansible_version at this stage + version: 2.14.0 + tasks: + - name: download prometheus binary to local folder + become: false + get_url: + url: "https://github.com/prometheus/prometheus/releases/download/v{{ version }}/prometheus-{{ version }}.linux-amd64.tar.gz" + dest: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz" + register: _download_archive + until: _download_archive is succeeded + retries: 5 + delay: 2 + run_once: true + check_mode: false + + - name: unpack prometheus binaries + become: false + unarchive: + src: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz" + dest: "/tmp" + creates: "/tmp/prometheus-{{ version }}.linux-amd64/prometheus" + run_once: true + check_mode: false + + - name: link to prometheus binaries directory + become: false + file: + src: "/tmp/prometheus-{{ version }}.linux-amd64" + dest: "/tmp/prometheus-linux-amd64" + state: link + run_once: true + check_mode: false diff --git a/roles/prometheus/molecule/alternative/tests/test_alternative.py b/roles/prometheus/molecule/alternative/tests/test_alternative.py new file mode 100644 index 00000000..8ef6d2ad --- /dev/null +++ b/roles/prometheus/molecule/alternative/tests/test_alternative.py @@ -0,0 +1,44 @@ +import pytest +import os +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.mark.parametrize("dirs", [ + "/opt/prom/etc", + "/opt/prom/etc/rules", + "/opt/prom/etc/file_sd", + "/opt/prom/lib" +]) +def test_directories(host, dirs): + d = host.file(dirs) + assert d.is_directory + assert d.exists + + +@pytest.mark.parametrize("files", [ + "/opt/prom/etc/prometheus.yml", + "/opt/prom/etc/rules/ansible_managed.rules", + "/opt/prom/etc/file_sd/node.yml", + "/opt/prom/etc/file_sd/docker.yml", + "/etc/systemd/system/prometheus.service", + "/usr/local/bin/prometheus", + "/usr/local/bin/promtool" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +def test_service(host): + s = host.service("prometheus") + # assert s.is_enabled + assert s.is_running + + +def test_socket(host): + s = host.socket("tcp://127.0.0.1:9090") + assert s.is_listening diff --git a/roles/prometheus/molecule/default/molecule.yml b/roles/prometheus/molecule/default/molecule.yml new file mode 100644 index 00000000..8937ee83 --- /dev/null +++ b/roles/prometheus/molecule/default/molecule.yml @@ -0,0 +1,75 @@ +--- +dependency: + name: galaxy +driver: + name: docker +# lint: | +# set -e +# yamllint . +# ansible-lint +# flake8 +platforms: + - name: bionic + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: xenial + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: stretch + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-9 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: buster + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-10 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos7 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-7 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos8 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-8 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 + - name: fedora + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:fedora-30 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: playbook.yml + inventory: + group_vars: + python3: + ansible_python_interpreter: /usr/bin/python3 +verifier: + name: testinfra diff --git a/roles/prometheus/molecule/default/playbook.yml b/roles/prometheus/molecule/default/playbook.yml new file mode 100644 index 00000000..688fb1dc --- /dev/null +++ b/roles/prometheus/molecule/default/playbook.yml @@ -0,0 +1,6 @@ +--- +- name: Run role + hosts: all + any_errors_fatal: true + roles: + - ansible-prometheus diff --git a/roles/prometheus/molecule/default/prepare.yml b/roles/prometheus/molecule/default/prepare.yml new file mode 100644 index 00000000..5358b3bd --- /dev/null +++ b/roles/prometheus/molecule/default/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: [] diff --git a/roles/prometheus/molecule/default/tests/test_default.py b/roles/prometheus/molecule/default/tests/test_default.py new file mode 100644 index 00000000..318d4fd7 --- /dev/null +++ b/roles/prometheus/molecule/default/tests/test_default.py @@ -0,0 +1,71 @@ +import pytest +import os +import yaml +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.fixture() +def AnsibleDefaults(): + with open("defaults/main.yml", 'r') as stream: + return yaml.load(stream) + + +@pytest.mark.parametrize("dirs", [ + "/etc/prometheus", + "/etc/prometheus/console_libraries", + "/etc/prometheus/consoles", + "/etc/prometheus/rules", + "/etc/prometheus/file_sd", + "/var/lib/prometheus" +]) +def test_directories(host, dirs): + d = host.file(dirs) + assert d.is_directory + assert d.exists + + +@pytest.mark.parametrize("files", [ + "/etc/prometheus/prometheus.yml", + "/etc/prometheus/console_libraries/prom.lib", + "/etc/prometheus/consoles/prometheus.html", + "/etc/systemd/system/prometheus.service", + "/usr/local/bin/prometheus", + "/usr/local/bin/promtool" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +@pytest.mark.parametrize("files", [ + "/etc/prometheus/rules/ansible_managed.rules" +]) +def test_absent(host, files): + f = host.file(files) + assert f.exists + + +def test_user(host): + assert host.group("prometheus").exists + assert host.user("prometheus").exists + + +def test_service(host): + s = host.service("prometheus") + # assert s.is_enabled + assert s.is_running + + +def test_socket(host): + s = host.socket("tcp://0.0.0.0:9090") + assert s.is_listening + + +def test_version(host, AnsibleDefaults): + version = os.getenv('PROMETHEUS', AnsibleDefaults['prometheus_version']) + out = host.run("/usr/local/bin/prometheus --version").stderr + assert "prometheus, version " + version in out diff --git a/roles/prometheus/molecule/latest/molecule.yml b/roles/prometheus/molecule/latest/molecule.yml new file mode 100644 index 00000000..a5a9cebb --- /dev/null +++ b/roles/prometheus/molecule/latest/molecule.yml @@ -0,0 +1,35 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: buster + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-10 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: fedora + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:fedora-30 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 +provisioner: + name: ansible + playbooks: + create: ../default/create.yml + prepare: ../default/prepare.yml + converge: playbook.yml + destroy: ../default/destroy.yml + inventory: + group_vars: + python3: + ansible_python_interpreter: /usr/bin/python3 +verifier: + name: testinfra diff --git a/roles/prometheus/molecule/latest/playbook.yml b/roles/prometheus/molecule/latest/playbook.yml new file mode 100644 index 00000000..9a7cc711 --- /dev/null +++ b/roles/prometheus/molecule/latest/playbook.yml @@ -0,0 +1,8 @@ +--- +- name: Run role + hosts: all + any_errors_fatal: true + roles: + - ansible-prometheus + vars: + prometheus_version: latest diff --git a/roles/prometheus/molecule/latest/tests/test_alternative.py b/roles/prometheus/molecule/latest/tests/test_alternative.py new file mode 100644 index 00000000..cbefab91 --- /dev/null +++ b/roles/prometheus/molecule/latest/tests/test_alternative.py @@ -0,0 +1,28 @@ +import pytest +import os +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.mark.parametrize("files", [ + "/etc/systemd/system/prometheus.service", + "/usr/local/bin/prometheus", + "/usr/local/bin/promtool" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +def test_service(host): + s = host.service("prometheus") + # assert s.is_enabled + assert s.is_running + + +def test_socket(host): + s = host.socket("tcp://0.0.0.0:9090") + assert s.is_listening diff --git a/roles/prometheus/tasks/configure.yml b/roles/prometheus/tasks/configure.yml new file mode 100644 index 00000000..8c76d332 --- /dev/null +++ b/roles/prometheus/tasks/configure.yml @@ -0,0 +1,60 @@ +--- +- name: alerting rules file + template: + src: "alert.rules.j2" + dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules" + owner: root + group: prometheus + mode: 0640 + validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s" + when: + - prometheus_alert_rules != [] + notify: + - reload prometheus + +- name: copy custom alerting rule files + copy: + src: "{{ item }}" + dest: "{{ prometheus_config_dir }}/rules/" + owner: root + group: prometheus + mode: 0640 + validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s" + with_fileglob: "{{ prometheus_alert_rules_files }}" + notify: + - reload prometheus + +- name: configure prometheus + template: + src: "{{ prometheus_config_file }}" + dest: "{{ prometheus_config_dir }}/prometheus.yml" + force: true + owner: root + group: prometheus + mode: 0640 + validate: "{{ _prometheus_binary_install_dir }}/promtool check config %s" + notify: + - reload prometheus + +- name: configure prometheus static targets + copy: + content: | + #jinja2: lstrip_blocks: True + {{ item.value | to_nice_yaml(indent=2) }} + dest: "{{ prometheus_config_dir }}/file_sd/{{ item.key }}.yml" + force: true + owner: root + group: prometheus + mode: 0640 + with_dict: "{{ prometheus_targets }}" + when: prometheus_targets != {} + +- name: copy prometheus custom static targets + copy: + src: "{{ item }}" + dest: "{{ prometheus_config_dir }}/file_sd/" + force: true + owner: root + group: prometheus + mode: 0640 + with_fileglob: "{{ prometheus_static_targets_files }}" diff --git a/roles/prometheus/tasks/install.yml b/roles/prometheus/tasks/install.yml new file mode 100644 index 00000000..e473d848 --- /dev/null +++ b/roles/prometheus/tasks/install.yml @@ -0,0 +1,137 @@ +--- +- name: create prometheus system group + group: + name: prometheus + system: true + state: present + +- name: create prometheus system user + user: + name: prometheus + system: true + shell: "/usr/sbin/nologin" + group: prometheus + createhome: false + home: "{{ prometheus_db_dir }}" + +- name: create prometheus data directory + file: + path: "{{ prometheus_db_dir }}" + state: directory + owner: prometheus + group: prometheus + mode: 0755 + +- name: create prometheus configuration directories + file: + path: "{{ item }}" + state: directory + owner: root + group: prometheus + mode: 0770 + with_items: + - "{{ prometheus_config_dir }}" + - "{{ prometheus_config_dir }}/rules" + - "{{ prometheus_config_dir }}/file_sd" + +- block: + - name: download prometheus binary to local folder + become: false + get_url: + url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" + dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" + checksum: "sha256:{{ __prometheus_checksum }}" + register: _download_archive + until: _download_archive is succeeded + retries: 5 + delay: 2 + # run_once: true # <-- this cannot be set due to multi-arch support + delegate_to: localhost + check_mode: false + + - name: unpack prometheus binaries + become: false + unarchive: + src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" + dest: "/tmp" + creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/prometheus" + delegate_to: localhost + check_mode: false + + - name: propagate official prometheus and promtool binaries + copy: + src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}" + dest: "{{ _prometheus_binary_install_dir }}/{{ item }}" + mode: 0755 + owner: root + group: root + with_items: + - prometheus + - promtool + notify: + - restart prometheus + + - name: propagate official console templates + copy: + src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}/" + dest: "{{ prometheus_config_dir }}/{{ item }}/" + mode: 0644 + owner: root + group: root + with_items: + - console_libraries + - consoles + notify: + - restart prometheus + when: + - prometheus_binary_local_dir | length == 0 + - not prometheus_skip_install + +- name: propagate locally distributed prometheus and promtool binaries + copy: + src: "{{ prometheus_binary_local_dir }}/{{ item }}" + dest: "{{ _prometheus_binary_install_dir }}/{{ item }}" + mode: 0755 + owner: root + group: root + with_items: + - prometheus + - promtool + when: + - prometheus_binary_local_dir | length > 0 + - not prometheus_skip_install + notify: + - restart prometheus + +- name: create systemd service unit + template: + src: prometheus.service.j2 + dest: /etc/systemd/system/prometheus.service + owner: root + group: root + mode: 0644 + notify: + - restart prometheus + +- name: Install SELinux dependencies + package: + name: "{{ item }}" + state: present + with_items: "{{ prometheus_selinux_packages }}" + register: _install_packages + until: _install_packages is succeeded + retries: 5 + delay: 2 + when: + - ansible_version.full is version('2.4', '>=') + - ansible_selinux.status == "enabled" + +- name: Allow prometheus to bind to port in SELinux + seport: + ports: "{{ prometheus_web_listen_address.split(':')[1] }}" + proto: tcp + setype: http_port_t + state: present + when: + - ansible_version.full is version('2.4', '>=') + - ansible_selinux.status == "enabled" diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml new file mode 100644 index 00000000..ec32a72c --- /dev/null +++ b/roles/prometheus/tasks/main.yml @@ -0,0 +1,37 @@ +--- +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - prometheus_configure + - prometheus_install + - prometheus_run + +- include: preflight.yml + tags: + - prometheus_configure + - prometheus_install + - prometheus_run + +- include: install.yml + become: true + tags: + - prometheus_install + +- include: configure.yml + become: true + tags: + - prometheus_configure + +- name: ensure prometheus service is started and enabled + become: true + systemd: + daemon_reload: true + name: prometheus + state: started + enabled: true + tags: + - prometheus_run diff --git a/roles/prometheus/tasks/preflight.yml b/roles/prometheus/tasks/preflight.yml new file mode 100644 index 00000000..1582f8ac --- /dev/null +++ b/roles/prometheus/tasks/preflight.yml @@ -0,0 +1,114 @@ +--- +- name: Assert usage of systemd as an init system + assert: + that: ansible_service_mgr == 'systemd' + msg: "This module only works with systemd" + +- name: Get systemd version + command: systemctl --version + changed_when: false + check_mode: false + register: __systemd_version + tags: + - skip_ansible_lint + +- name: Set systemd version fact + set_fact: + prometheus_systemd_version: "{{ __systemd_version.stdout_lines[0].split(' ')[-1] }}" + +- name: Assert no duplicate config flags + assert: + that: + - prometheus_config_flags_extra['config.file'] is not defined + - prometheus_config_flags_extra['storage.tsdb.path'] is not defined + - prometheus_config_flags_extra['storage.local.path'] is not defined + - prometheus_config_flags_extra['web.listen-address'] is not defined + - prometheus_config_flags_extra['web.external-url'] is not defined + msg: "Detected duplicate configuration entry. Please check your ansible variables and role README.md." + +- name: Assert external_labels aren't configured twice + assert: + that: prometheus_global.external_labels is not defined + msg: "Use prometheus_external_labels to define external labels" + +- name: Set prometheus external metrics path + set_fact: + prometheus_metrics_path: "/{{ ( prometheus_web_external_url + '/metrics' ) | regex_replace('^(.*://)?(.*?)/') }}" + +- name: Fail when prometheus_config_flags_extra duplicates parameters set by other variables + fail: + msg: > + Whooops. You are duplicating configuration. Please look at your prometheus_config_flags_extra + and check against other variables in defaults/main.yml + with_items: + - 'storage.tsdb.retention' + - 'storage.tsdb.path' + - 'storage.local.retention' + - 'storage.local.path' + - 'config.file' + - 'web.listen-address' + - 'web.external-url' + when: item in prometheus_config_flags_extra.keys() + +- name: Get all file_sd files from scrape_configs + set_fact: + file_sd_files: "{{ prometheus_scrape_configs | json_query('[*][].file_sd_configs[*][].files[]') }}" + +- name: Fail when file_sd targets are not defined in scrape_configs + fail: + msg: > + Oh, snap! `{{ item.key }}` couldn't be found in your scrape configs. Please ensure you provided + all targets from prometheus_targets in prometheus_scrape_configs + when: not prometheus_config_dir + "/file_sd/" + item.key + ".yml" in file_sd_files + # when: not item | basename | splitext | difference(['.yml']) | join('') in prometheus_targets.keys() + with_dict: "{{ prometheus_targets }}" + +- name: Alert when prometheus_alertmanager_config is empty, but prometheus_alert_rules is specified + debug: + msg: > + No alertmanager configuration was specified. If you want your alerts to be sent make sure to + specify a prometheus_alertmanager_config in defaults/main.yml. + when: + - prometheus_alertmanager_config == [] + - prometheus_alert_rules != [] + +- block: + - name: Get latest release + uri: + url: "https://api.github.com/repos/prometheus/prometheus/releases/latest" + method: GET + return_content: true + status_code: 200 + body_format: json + validate_certs: false + user: "{{ lookup('env', 'GH_USER') | default(omit) }}" + password: "{{ lookup('env', 'GH_TOKEN') | default(omit) }}" + no_log: "{{ not lookup('env', 'ANSIBLE_DEBUG') | bool }}" + register: _latest_release + until: _latest_release.status == 200 + retries: 5 + + - name: "Set prometheus version to {{ _latest_release.json.tag_name[1:] }}" + set_fact: + prometheus_version: "{{ _latest_release.json.tag_name[1:] }}" + when: + - prometheus_version == "latest" + - prometheus_binary_local_dir | length == 0 + - not prometheus_skip_install + +- block: + - name: "Get checksum list" + set_fact: + __prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt', wantlist=True) | list }}" + run_once: true + + - name: "Get checksum for {{ go_arch }} architecture" + set_fact: + __prometheus_checksum: "{{ item.split(' ')[0] }}" + with_items: "{{ __prometheus_checksums }}" + when: + - "('linux-' + go_arch + '.tar.gz') in item" + delegate_to: localhost + when: + - prometheus_binary_local_dir | length == 0 + - not prometheus_skip_install diff --git a/roles/prometheus/templates/alert.rules.j2 b/roles/prometheus/templates/alert.rules.j2 new file mode 100644 index 00000000..8498cf85 --- /dev/null +++ b/roles/prometheus/templates/alert.rules.j2 @@ -0,0 +1,6 @@ +{{ ansible_managed | comment }} + +groups: +- name: ansible managed alert rules + rules: + {{ prometheus_alert_rules | to_nice_yaml(indent=2) | indent(2,False) }} diff --git a/roles/prometheus/templates/prometheus.service.j2 b/roles/prometheus/templates/prometheus.service.j2 new file mode 100644 index 00000000..0348b9fe --- /dev/null +++ b/roles/prometheus/templates/prometheus.service.j2 @@ -0,0 +1,66 @@ +{{ ansible_managed | comment }} + +[Unit] +Description=Prometheus +After=network-online.target +Requires=local-fs.target +After=local-fs.target + +[Service] +Type=simple +Environment="GOMAXPROCS={{ ansible_processor_vcpus|default(ansible_processor_count) }}" +User=prometheus +Group=prometheus +ExecReload=/bin/kill -HUP $MAINPID +ExecStart={{ _prometheus_binary_install_dir }}/prometheus \ + --config.file={{ prometheus_config_dir }}/prometheus.yml \ + --storage.tsdb.path={{ prometheus_db_dir }} \ +{% if prometheus_version is version('2.7.0', '>=') %} + --storage.tsdb.retention.time={{ prometheus_storage_retention }} \ + --storage.tsdb.retention.size={{ prometheus_storage_retention_size }} \ +{% else %} + --storage.tsdb.retention={{ prometheus_storage_retention }} \ +{% endif %} + --web.console.libraries={{ prometheus_config_dir }}/console_libraries \ + --web.console.templates={{ prometheus_config_dir }}/consoles \ + --web.listen-address={{ prometheus_web_listen_address }} \ + --web.external-url={{ prometheus_web_external_url }}{% for flag, flag_value in prometheus_config_flags_extra.items() %}\ + --{{ flag }}{% if flag_value %}={{ flag_value }}{% endif %} {% endfor %} + +CapabilityBoundingSet=CAP_SET_UID +LimitNOFILE=65000 +LockPersonality=true +NoNewPrivileges=true +MemoryDenyWriteExecute=true +PrivateDevices=true +PrivateTmp=true +ProtectHome=true +RemoveIPC=true +RestrictSUIDSGID=true +#SystemCallFilter=@signal @timer + +{% if prometheus_systemd_version | int >= 231 %} +ReadWritePaths={{ prometheus_db_dir }} +{% else %} +ReadWriteDirectories={{ prometheus_db_dir }} +{% endif %} + +{% if prometheus_systemd_version | int >= 232 %} +PrivateUsers=true +ProtectControlGroups=true +ProtectKernelModules=true +ProtectKernelTunables=true +ProtectSystem=strict +{% else %} +ProtectSystem=full +{% endif %} + +{% if http_proxy is defined %} +Environment="HTTP_PROXY={{ http_proxy }}"{% if https_proxy is defined %} "HTTPS_PROXY={{ https_proxy }}{% endif %}" +{% endif %} + +SyslogIdentifier=prometheus +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 new file mode 100644 index 00000000..d16a1843 --- /dev/null +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -0,0 +1,34 @@ +#jinja2: trim_blocks: True, lstrip_blocks: True +{{ ansible_managed | comment }} +# http://prometheus.io/docs/operating/configuration/ + +global: + {{ prometheus_global | to_nice_yaml(indent=2) | indent(2, False) }} + external_labels: + {{ prometheus_external_labels | to_nice_yaml(indent=2) | indent(4, False) }} + +{% if prometheus_remote_write != [] %} +remote_write: + {{ prometheus_remote_write | to_nice_yaml(indent=2) | indent(2, False) }} +{% endif %} + +{% if prometheus_remote_read != [] %} +remote_read: + {{ prometheus_remote_read | to_nice_yaml(indent=2) | indent(2, False) }} +{% endif %} + +rule_files: + - {{ prometheus_config_dir }}/rules/*.rules + +{% if prometheus_alertmanager_config | length > 0 %} +alerting: + alertmanagers: + {{ prometheus_alertmanager_config | to_nice_yaml(indent=2) | indent(2,False) }} + {% if prometheus_alert_relabel_configs | length > 0 %} + alert_relabel_configs: + {{ prometheus_alert_relabel_configs | to_nice_yaml(indent=2) | indent(2,False) }} + {% endif %} +{% endif %} + +scrape_configs: + {{ prometheus_scrape_configs | to_nice_yaml(indent=2) | indent(2,False) }} diff --git a/roles/prometheus/test-requirements.txt b/roles/prometheus/test-requirements.txt new file mode 100644 index 00000000..1b6e9a96 --- /dev/null +++ b/roles/prometheus/test-requirements.txt @@ -0,0 +1,8 @@ +molecule>=3.0.0 +molecule-docker +docker +ansible-lint>=3.4.0 +testinfra>=1.7.0 +jmespath +selinux +passlib diff --git a/roles/prometheus/vars/centos-8.yml b/roles/prometheus/vars/centos-8.yml new file mode 100644 index 00000000..3fc18d81 --- /dev/null +++ b/roles/prometheus/vars/centos-8.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python3-libselinux + - python3-policycoreutils diff --git a/roles/prometheus/vars/centos.yml b/roles/prometheus/vars/centos.yml new file mode 100644 index 00000000..ea3dea19 --- /dev/null +++ b/roles/prometheus/vars/centos.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - libselinux-python + - policycoreutils-python diff --git a/roles/prometheus/vars/debian.yml b/roles/prometheus/vars/debian.yml new file mode 100644 index 00000000..d109c39f --- /dev/null +++ b/roles/prometheus/vars/debian.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python-selinux + - policycoreutils diff --git a/roles/prometheus/vars/fedora.yml b/roles/prometheus/vars/fedora.yml new file mode 100644 index 00000000..3fc18d81 --- /dev/null +++ b/roles/prometheus/vars/fedora.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python3-libselinux + - python3-policycoreutils diff --git a/roles/prometheus/vars/main.yml b/roles/prometheus/vars/main.yml new file mode 100644 index 00000000..091379fd --- /dev/null +++ b/roles/prometheus/vars/main.yml @@ -0,0 +1,10 @@ +--- +go_arch_map: + i386: '386' + x86_64: 'amd64' + aarch64: 'arm64' + armv7l: 'armv7' + armv6l: 'armv6' + +go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}" +_prometheus_binary_install_dir: '/usr/local/bin' diff --git a/roles/prometheus/vars/redhat-8.yml b/roles/prometheus/vars/redhat-8.yml new file mode 100644 index 00000000..3fc18d81 --- /dev/null +++ b/roles/prometheus/vars/redhat-8.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python3-libselinux + - python3-policycoreutils diff --git a/roles/prometheus/vars/redhat.yml b/roles/prometheus/vars/redhat.yml new file mode 100644 index 00000000..ea3dea19 --- /dev/null +++ b/roles/prometheus/vars/redhat.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - libselinux-python + - policycoreutils-python