├── .github
└── workflows
│ └── commitlint.yml
├── .gitignore
├── .gitlab-ci.yml
├── .pre-commit-config.yaml
├── .rstcheck.cfg
├── .rubocop.yml
├── .salt-lint
├── .travis.yml
├── .yamllint
├── AUTHORS.md
├── CHANGELOG.md
├── CODEOWNERS
├── FORMULA
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── bin
├── install-hooks
└── kitchen
├── commitlint.config.js
├── docs
├── AUTHORS.rst
├── CHANGELOG.rst
├── README.rst
├── TOFS_pattern.rst
└── _static
│ └── css
│ └── custom.css
├── kitchen.yml
├── pillar.example
├── pre-commit_semantic-release.sh
├── prometheus
├── _mapdata
│ ├── _mapdata.jinja
│ └── init.sls
├── archive
│ ├── alternatives
│ │ ├── clean.sls
│ │ ├── init.sls
│ │ └── install.sls
│ ├── clean.sls
│ ├── init.sls
│ └── install.sls
├── clean.sls
├── clientlibs
│ ├── clean.sls
│ ├── init.sls
│ └── install.sls
├── config
│ ├── clean.sls
│ ├── environ.sls
│ ├── file.sls
│ ├── init.sls
│ ├── storage.sls
│ └── users.sls
├── cpuarchmap.yaml
├── defaults.yaml
├── exporters
│ ├── clean.sls
│ ├── init.sls
│ └── node_exporter
│ │ ├── clean.sls
│ │ ├── init.sls
│ │ └── textfile_collectors
│ │ ├── clean.sls
│ │ ├── files
│ │ ├── ipmitool
│ │ └── smartmon.sh.jinja
│ │ ├── init.sls
│ │ ├── ipmitool
│ │ ├── clean.sls
│ │ ├── init.sls
│ │ └── install.sls
│ │ └── smartmon
│ │ ├── clean.sls
│ │ ├── init.sls
│ │ └── install.sls
├── files
│ ├── default
│ │ ├── config.yml.jinja
│ │ ├── environ.sh.jinja
│ │ └── systemd.ini.jinja
│ └── macros.jinja
├── init.sls
├── libtofs.jinja
├── map.jinja
├── osarchmap.yaml
├── osfamilymap.yaml
├── package
│ ├── clean.sls
│ ├── init.sls
│ ├── install.sls
│ └── repo
│ │ ├── clean.sls
│ │ ├── init.sls
│ │ └── install.sls
└── service
│ ├── args
│ ├── clean.sls
│ ├── init.sls
│ └── install.sls
│ ├── clean.sls
│ ├── init.sls
│ └── running.sls
├── release-rules.js
├── release.config.js
└── test
├── integration
├── default
│ ├── README.md
│ ├── controls
│ │ ├── archive_spec.rb
│ │ ├── config_spec.rb
│ │ └── service_spec.rb
│ └── inspec.yml
├── repo
│ ├── README.md
│ ├── controls
│ │ ├── packages_spec.rb
│ │ ├── repositories_spec.rb
│ │ └── service_spec.rb
│ └── inspec.yml
└── share
│ ├── README.md
│ ├── inspec.yml
│ └── libraries
│ └── system.rb
└── salt
└── pillar
├── default.sls
└── repo.sls
/.github/workflows/commitlint.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | name: Commitlint
5 | 'on': [pull_request]
6 |
7 | jobs:
8 | lint:
9 | runs-on: ubuntu-latest
10 | env:
11 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 | steps:
13 | - uses: actions/checkout@v2
14 | with:
15 | fetch-depth: 0
16 | - uses: wagoid/commitlint-github-action@v1
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a packager
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 | .kitchen
49 | .kitchen.local.yml
50 | kitchen.local.yml
51 | junit-*.xml
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 |
61 | # Flask stuff:
62 | instance/
63 | .webassets-cache
64 |
65 | # Scrapy stuff:
66 | .scrapy
67 |
68 | # Sphinx documentation
69 | docs/_build/
70 |
71 | # PyBuilder
72 | target/
73 |
74 | # Jupyter Notebook
75 | .ipynb_checkpoints
76 |
77 | # pyenv
78 | .python-version
79 |
80 | # celery beat schedule file
81 | celerybeat-schedule
82 |
83 | # SageMath parsed files
84 | *.sage.py
85 |
86 | # dotenv
87 | .env
88 |
89 | # virtualenv
90 | .venv
91 | venv/
92 | ENV/
93 |
94 | # visual studio
95 | .vs/
96 |
97 | # Spyder project settings
98 | .spyderproject
99 | .spyproject
100 |
101 | # Rope project settings
102 | .ropeproject
103 |
104 | # mkdocs documentation
105 | /site
106 |
107 | # mypy
108 | .mypy_cache/
109 |
110 | # Bundler
111 | .bundle/
112 |
113 | # copied `.md` files used for conversion to `.rst` using `m2r`
114 | docs/*.md
115 |
116 | # Vim
117 | *.sw?
118 |
119 | ## Collected when centralising formulas (check and sort)
120 | # `collectd-formula`
121 | .pytest_cache/
122 | /.idea/
123 | Dockerfile.*_*
124 | ignore/
125 | tmp/
126 |
127 | # `salt-formula` -- Vagrant Specific files
128 | .vagrant
129 | top.sls
130 | !test/salt/pillar/top.sls
131 |
132 | # `suricata-formula` -- Platform binaries
133 | *.rpm
134 | *.deb
135 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | ###############################################################################
5 | # Define all YAML node anchors
6 | ###############################################################################
7 | .node_anchors:
8 | # `only` (also used for `except` where applicable)
9 | only_branch_master_parent_repo: &only_branch_master_parent_repo
10 | - 'master@saltstack-formulas/prometheus-formula'
11 | # `stage`
12 | stage_lint: &stage_lint 'lint'
13 | stage_release: &stage_release 'release'
14 | stage_test: &stage_test 'test'
15 | # `image`
16 | image_commitlint: &image_commitlint 'myii/ssf-commitlint:11'
17 | image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3'
18 | image_precommit: &image_precommit
19 | name: 'myii/ssf-pre-commit:2.9.2'
20 | entrypoint: ['/bin/bash', '-c']
21 | image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest'
22 | image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14'
23 | # `services`
24 | services_docker_dind: &services_docker_dind
25 | - 'docker:dind'
26 | # `variables`
27 | # https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3
28 | # https://bundler.io/v1.16/bundle_config.html
29 | variables_bundler: &variables_bundler
30 | BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler'
31 | BUNDLE_WITHOUT: 'production'
32 | # `cache`
33 | cache_bundler: &cache_bundler
34 | key: '${CI_JOB_STAGE}'
35 | paths:
36 | - '${BUNDLE_CACHE_PATH}'
37 |
38 | ###############################################################################
39 | # Define stages and global variables
40 | ###############################################################################
41 | stages:
42 | - *stage_lint
43 | - *stage_test
44 | - *stage_release
45 | variables:
46 | DOCKER_DRIVER: 'overlay2'
47 |
48 | ###############################################################################
49 | # `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed)
50 | ###############################################################################
51 | commitlint:
52 | stage: *stage_lint
53 | image: *image_commitlint
54 | script:
55 | # Add `upstream` remote to get access to `upstream/master`
56 | - 'git remote add upstream
57 | https://gitlab.com/saltstack-formulas/prometheus-formula.git'
58 | - 'git fetch --all'
59 | # Set default commit hashes for `--from` and `--to`
60 | - 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
61 | - 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
62 | # `coqbot` adds a merge commit to test PRs on top of the latest commit in
63 | # the repo; amend this merge commit message to avoid failure
64 | - |
65 | if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \
66 | && [ "${CI_COMMIT_BRANCH}" != "master" ]; then
67 | git commit --amend -m \
68 | 'chore: reword coqbot merge commit message for commitlint'
69 | export COMMITLINT_TO=HEAD
70 | fi
71 | # Run `commitlint`
72 | - 'commitlint --from "${COMMITLINT_FROM}"
73 | --to "${COMMITLINT_TO}"
74 | --verbose'
75 |
76 | pre-commit:
77 | stage: *stage_lint
78 | image: *image_precommit
79 | # https://pre-commit.com/#gitlab-ci-example
80 | variables:
81 | PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
82 | cache:
83 | key: '${CI_JOB_NAME}'
84 | paths:
85 | - '${PRE_COMMIT_HOME}'
86 | script:
87 | - 'pre-commit run --all-files --color always --verbose'
88 |
89 | # Use a separate job for `rubocop` other than the one potentially run by `pre-commit`
90 | # - The `pre-commit` check will only be available for formulas that pass the default
91 | # `rubocop` check -- and must continue to do so
92 | # - This job is allowed to fail, so can be used for all formulas
93 | # - Furthermore, this job uses all of the latest `rubocop` features & cops,
94 | # which will help when upgrading the `rubocop` linter used in `pre-commit`
95 | rubocop:
96 | allow_failure: true
97 | stage: *stage_lint
98 | image: *image_rubocop
99 | script:
100 | - 'rubocop -d -P -S --enable-pending-cops'
101 |
102 | ###############################################################################
103 | # Define `test` template
104 | ###############################################################################
105 | .test_instance: &test_instance
106 | stage: *stage_test
107 | image: *image_dindruby
108 | services: *services_docker_dind
109 | variables: *variables_bundler
110 | cache: *cache_bundler
111 | before_script:
112 | # TODO: This should work from the env vars above automatically
113 | - 'bundle config set path "${BUNDLE_CACHE_PATH}"'
114 | - 'bundle config set without "${BUNDLE_WITHOUT}"'
115 | - 'bundle install'
116 | script:
117 | # Alternative value to consider: `${CI_JOB_NAME}`
118 | - 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"'
119 |
120 | ###############################################################################
121 | # Define `test` template (`allow_failure: true`)
122 | ###############################################################################
123 | .test_instance_failure_permitted:
124 | <<: *test_instance
125 | allow_failure: true
126 |
127 | ###############################################################################
128 | # `test` stage: each instance below uses the `test` template above
129 | ###############################################################################
130 | ## Define the rest of the matrix based on Kitchen testing
131 | # Make sure the instances listed below match up with
132 | # the `platforms` defined in `kitchen.yml`
133 | # yamllint disable rule:line-length
134 | # default-debian-11-tiamat-py3: {extends: '.test_instance'}
135 | # default-debian-10-tiamat-py3: {extends: '.test_instance'}
136 | # default-debian-9-tiamat-py3: {extends: '.test_instance'}
137 | # default-ubuntu-2204-tiamat-py3: {extends: '.test_instance_failure_permitted'}
138 | # default-ubuntu-2004-tiamat-py3: {extends: '.test_instance'}
139 | # default-ubuntu-1804-tiamat-py3: {extends: '.test_instance'}
140 | # default-centos-stream8-tiamat-py3: {extends: '.test_instance_failure_permitted'}
141 | # default-centos-7-tiamat-py3: {extends: '.test_instance'}
142 | # default-amazonlinux-2-tiamat-py3: {extends: '.test_instance'}
143 | # default-oraclelinux-8-tiamat-py3: {extends: '.test_instance'}
144 | # default-oraclelinux-7-tiamat-py3: {extends: '.test_instance'}
145 | # default-almalinux-8-tiamat-py3: {extends: '.test_instance'}
146 | # default-rockylinux-8-tiamat-py3: {extends: '.test_instance'}
147 | # default-debian-11-master-py3: {extends: '.test_instance'}
148 | # repo-debian-11-master-py3: {extends: '.test_instance'}
149 | debian-11-master-py3: {extends: '.test_instance'}
150 | # default-debian-10-master-py3: {extends: '.test_instance'}
151 | # repo-debian-10-master-py3: {extends: '.test_instance'}
152 | debian-10-master-py3: {extends: '.test_instance'}
153 | # default-debian-9-master-py3: {extends: '.test_instance'}
154 | # repo-debian-9-master-py3: {extends: '.test_instance'}
155 | debian-9-master-py3: {extends: '.test_instance'}
156 | # default-ubuntu-2204-master-py3: {extends: '.test_instance_failure_permitted'}
157 | # repo-ubuntu-2204-master-py3: {extends: '.test_instance_failure_permitted'}
158 | ubuntu-2204-master-py3: {extends: '.test_instance_failure_permitted'}
159 | # default-ubuntu-2004-master-py3: {extends: '.test_instance'}
160 | # repo-ubuntu-2004-master-py3: {extends: '.test_instance'}
161 | ubuntu-2004-master-py3: {extends: '.test_instance'}
162 | # default-ubuntu-1804-master-py3: {extends: '.test_instance'}
163 | # repo-ubuntu-1804-master-py3: {extends: '.test_instance'}
164 | ubuntu-1804-master-py3: {extends: '.test_instance'}
165 | # default-centos-stream8-master-py3: {extends: '.test_instance_failure_permitted'}
166 | # repo-centos-stream8-master-py3: {extends: '.test_instance_failure_permitted'}
167 | centos-stream8-master-py3: {extends: '.test_instance_failure_permitted'}
168 | # default-centos-7-master-py3: {extends: '.test_instance'}
169 | # repo-centos-7-master-py3: {extends: '.test_instance'}
170 | centos-7-master-py3: {extends: '.test_instance'}
171 | default-fedora-36-master-py3: {extends: '.test_instance_failure_permitted'}
172 | # repo-fedora-36-master-py3: {extends: '.test_instance_failure_permitted'}
173 | # fedora-36-master-py3: {extends: '.test_instance_failure_permitted'}
174 | default-fedora-35-master-py3: {extends: '.test_instance'}
175 | # repo-fedora-35-master-py3: {extends: '.test_instance'}
176 | # fedora-35-master-py3: {extends: '.test_instance'}
177 | default-opensuse-leap-153-master-py3: {extends: '.test_instance'}
178 | # repo-opensuse-leap-153-master-py3: {extends: '.test_instance'}
179 | # opensuse-leap-153-master-py3: {extends: '.test_instance'}
180 | default-opensuse-tmbl-latest-master-py3: {extends: '.test_instance_failure_permitted'}
181 | # repo-opensuse-tmbl-latest-master-py3: {extends: '.test_instance_failure_permitted'}
182 | # opensuse-tmbl-latest-master-py3: {extends: '.test_instance_failure_permitted'}
183 | # default-amazonlinux-2-master-py3: {extends: '.test_instance'}
184 | # repo-amazonlinux-2-master-py3: {extends: '.test_instance'}
185 | amazonlinux-2-master-py3: {extends: '.test_instance'}
186 | # default-oraclelinux-8-master-py3: {extends: '.test_instance'}
187 | # repo-oraclelinux-8-master-py3: {extends: '.test_instance'}
188 | oraclelinux-8-master-py3: {extends: '.test_instance'}
189 | # default-oraclelinux-7-master-py3: {extends: '.test_instance'}
190 | # repo-oraclelinux-7-master-py3: {extends: '.test_instance'}
191 | oraclelinux-7-master-py3: {extends: '.test_instance'}
192 | default-arch-base-latest-master-py3: {extends: '.test_instance'}
193 | # repo-arch-base-latest-master-py3: {extends: '.test_instance'}
194 | # arch-base-latest-master-py3: {extends: '.test_instance'}
195 | # default-gentoo-stage3-latest-master-py3: {extends: '.test_instance'}
196 | # repo-gentoo-stage3-latest-master-py3: {extends: '.test_instance'}
197 | # gentoo-stage3-latest-master-py3: {extends: '.test_instance'}
198 | # default-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'}
199 | # repo-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'}
200 | # gentoo-stage3-systemd-master-py3: {extends: '.test_instance'}
201 | # default-almalinux-8-master-py3: {extends: '.test_instance'}
202 | # repo-almalinux-8-master-py3: {extends: '.test_instance'}
203 | almalinux-8-master-py3: {extends: '.test_instance'}
204 | # default-rockylinux-8-master-py3: {extends: '.test_instance'}
205 | # repo-rockylinux-8-master-py3: {extends: '.test_instance'}
206 | rockylinux-8-master-py3: {extends: '.test_instance'}
207 | # default-debian-11-3004-1-py3: {extends: '.test_instance'}
208 | # default-debian-10-3004-1-py3: {extends: '.test_instance'}
209 | # default-debian-9-3004-1-py3: {extends: '.test_instance'}
210 | # default-ubuntu-2204-3004-1-py3: {extends: '.test_instance_failure_permitted'}
211 | # default-ubuntu-2004-3004-1-py3: {extends: '.test_instance'}
212 | # default-ubuntu-1804-3004-1-py3: {extends: '.test_instance'}
213 | # default-centos-stream8-3004-1-py3: {extends: '.test_instance_failure_permitted'}
214 | # default-centos-7-3004-1-py3: {extends: '.test_instance'}
215 | # default-fedora-36-3004-1-py3: {extends: '.test_instance_failure_permitted'}
216 | # default-fedora-35-3004-1-py3: {extends: '.test_instance'}
217 | # default-amazonlinux-2-3004-1-py3: {extends: '.test_instance'}
218 | # default-oraclelinux-8-3004-1-py3: {extends: '.test_instance'}
219 | # default-oraclelinux-7-3004-1-py3: {extends: '.test_instance'}
220 | # default-arch-base-latest-3004-1-py3: {extends: '.test_instance'}
221 | # default-gentoo-stage3-latest-3004-1-py3: {extends: '.test_instance'}
222 | # default-gentoo-stage3-systemd-3004-1-py3: {extends: '.test_instance'}
223 | # default-almalinux-8-3004-1-py3: {extends: '.test_instance'}
224 | # default-rockylinux-8-3004-1-py3: {extends: '.test_instance'}
225 | # default-opensuse-leap-153-3004-0-py3: {extends: '.test_instance'}
226 | # default-opensuse-tmbl-latest-3004-0-py3: {extends: '.test_instance_failure_permitted'}
227 | # default-debian-10-3003-4-py3: {extends: '.test_instance'}
228 | # default-debian-9-3003-4-py3: {extends: '.test_instance'}
229 | # default-ubuntu-2004-3003-4-py3: {extends: '.test_instance'}
230 | # default-ubuntu-1804-3003-4-py3: {extends: '.test_instance'}
231 | # default-centos-stream8-3003-4-py3: {extends: '.test_instance_failure_permitted'}
232 | # default-centos-7-3003-4-py3: {extends: '.test_instance'}
233 | # default-amazonlinux-2-3003-4-py3: {extends: '.test_instance'}
234 | # default-oraclelinux-8-3003-4-py3: {extends: '.test_instance'}
235 | # default-oraclelinux-7-3003-4-py3: {extends: '.test_instance'}
236 | # default-almalinux-8-3003-4-py3: {extends: '.test_instance'}
237 | # yamllint enable rule:line-length
238 |
239 | ###############################################################################
240 | # `release` stage: `semantic-release`
241 | ###############################################################################
242 | semantic-release:
243 | only: *only_branch_master_parent_repo
244 | stage: *stage_release
245 | image: *image_semanticrelease
246 | variables:
247 | MAINTAINER_TOKEN: '${GH_TOKEN}'
248 | script:
249 | # Update `AUTHORS.md`
250 | - '${HOME}/go/bin/maintainer contributor'
251 | # Run `semantic-release`
252 | - 'semantic-release'
253 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | # See https://pre-commit.com for more information
5 | # See https://pre-commit.com/hooks.html for more hooks
6 | ci:
7 | autofix_commit_msg: |
8 | ci(pre-commit.ci): apply auto fixes from pre-commit.com hooks
9 |
10 | For more information, see https://pre-commit.ci
11 | autofix_prs: true
12 | autoupdate_branch: ''
13 | autoupdate_commit_msg: |
14 | ci(pre-commit.ci): perform `pre-commit` autoupdate
15 | autoupdate_schedule: quarterly
16 | skip: []
17 | submodules: false
18 | default_stages: [commit]
19 | repos:
20 | - repo: https://github.com/dafyddj/commitlint-pre-commit-hook
21 | rev: v2.3.0
22 | hooks:
23 | - id: commitlint
24 | name: Check commit message using commitlint
25 | description: Lint commit message against @commitlint/config-conventional rules
26 | stages: [commit-msg]
27 | additional_dependencies: ['@commitlint/config-conventional@8.3.4']
28 | - id: commitlint-travis
29 | stages: [manual]
30 | additional_dependencies: ['@commitlint/config-conventional@8.3.4']
31 | always_run: true
32 | - repo: https://github.com/rubocop-hq/rubocop
33 | rev: v1.30.1
34 | hooks:
35 | - id: rubocop
36 | name: Check Ruby files with rubocop
37 | args: [--debug]
38 | always_run: true
39 | pass_filenames: false
40 | - repo: https://github.com/shellcheck-py/shellcheck-py
41 | rev: v0.8.0.4
42 | hooks:
43 | - id: shellcheck
44 | name: Check shell scripts with shellcheck
45 | files: ^.*\.(sh|bash|ksh)$
46 | types: []
47 | - repo: https://github.com/adrienverge/yamllint
48 | rev: v1.26.3
49 | hooks:
50 | - id: yamllint
51 | name: Check YAML syntax with yamllint
52 | args: [--strict, '.']
53 | always_run: true
54 | pass_filenames: false
55 | - repo: https://github.com/warpnet/salt-lint
56 | rev: v0.8.0
57 | hooks:
58 | - id: salt-lint
59 | name: Check Salt files using salt-lint
60 | files: ^.*\.(sls|jinja|j2|tmpl|tst)$
61 | - repo: https://github.com/myint/rstcheck
62 | rev: 3f929574
63 | hooks:
64 | - id: rstcheck
65 | name: Check reST files using rstcheck
66 | exclude: 'docs/CHANGELOG.rst'
67 | - repo: https://github.com/saltstack-formulas/mirrors-rst-lint
68 | rev: v1.3.2
69 | hooks:
70 | - id: rst-lint
71 | name: Check reST files using rst-lint
72 | exclude: |
73 | (?x)^(
74 | docs/CHANGELOG.rst|
75 | docs/TOFS_pattern.rst|
76 | )$
77 | additional_dependencies: [pygments==2.9.0]
78 |
--------------------------------------------------------------------------------
/.rstcheck.cfg:
--------------------------------------------------------------------------------
1 | [rstcheck]
2 | report=info
3 | ignore_language=rst
4 | ignore_messages=(Duplicate (ex|im)plicit target.*|Hyperlink target ".*" is not referenced\.$)
5 |
--------------------------------------------------------------------------------
/.rubocop.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | # General overrides used across formulas in the org
5 | Layout/LineLength:
6 | # Increase from default of `80`
7 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
8 | Max: 88
9 | Metrics/BlockLength:
10 | IgnoredMethods:
11 | - control
12 | - describe
13 | # Increase from default of `25`
14 | Max: 30
15 | Security/YAMLLoad:
16 | Exclude:
17 | - test/integration/**/_mapdata.rb
18 |
19 | # General settings across all cops in this formula
20 | AllCops:
21 | NewCops: enable
22 |
23 | # Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
24 |
--------------------------------------------------------------------------------
/.salt-lint:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | exclude_paths: []
5 | rules: {}
6 | skip_list:
7 | # Using `salt-lint` for linting other files as well, such as Jinja macros/templates
8 | - 205 # Use ".sls" as a Salt State file extension
9 | # Skipping `207` and `208` because `210` is sufficient, at least for the time-being
10 | # I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755`
11 | - 207 # File modes should always be encapsulated in quotation marks
12 | - 208 # File modes should always contain a leading zero
13 | tags: []
14 | verbosity: 1
15 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | ################################################################################
5 | # NOTE: This file is UNMAINTAINED; it is provided for references purposes only.
6 | # No guarantees are tendered that this structure will work after 2020.
7 | ################################################################################
8 | # * https://en.wikipedia.org/wiki/Travis_CI:
9 | # - "... free open-source plans were removed in [sic] the end of 2020"
10 | # - https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
11 | # - https://ropensci.org/technotes/2020/11/19/moving-away-travis/
12 | ################################################################################
13 | ## Machine config
14 | os: 'linux'
15 | arch: 'amd64'
16 | dist: 'bionic'
17 | version: '~> 1.0'
18 |
19 | ## Language and cache config
20 | language: 'ruby'
21 | cache: 'bundler'
22 |
23 | ## Services config
24 | services:
25 | - docker
26 |
27 | ## Script to run for the test stage
28 | script:
29 | - bin/kitchen verify "${INSTANCE}"
30 |
31 | ## Stages and jobs matrix
32 | stages:
33 | - test
34 | # # As part of the switch away from Travis CI, ensure that the `release` stage
35 | # # is not run inadvertently
36 | # - name: 'release'
37 | # if: 'branch = master AND type != pull_request'
38 | jobs:
39 | include:
40 | ## Define the test stage that runs the linters (and testing matrix, if applicable)
41 |
42 | # Run all of the linters in a single job
43 | - language: 'node_js'
44 | node_js: 'lts/*'
45 | env: 'Lint'
46 | name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint'
47 | before_install: 'skip'
48 | script:
49 | # Install and run `salt-lint`
50 | - pip install --user salt-lint
51 | - git ls-files -- '*.sls' '*.jinja' '*.j2' '*.tmpl' '*.tst'
52 | | xargs salt-lint
53 | # Install and run `yamllint`
54 | # Need at least `v1.17.0` for the `yaml-files` setting
55 | - pip install --user yamllint>=1.17.0
56 | - yamllint -s .
57 | # Install and run `rubocop`
58 | - gem install rubocop
59 | - rubocop -d
60 | # Run `shellcheck` (already pre-installed in Travis)
61 | - shellcheck --version
62 | - git ls-files -- '*.sh' '*.bash' '*.ksh'
63 | | xargs shellcheck
64 | # Install and run `commitlint`
65 | - npm i -D @commitlint/config-conventional
66 | @commitlint/travis-cli
67 | - commitlint-travis
68 |
69 | # Run `pre-commit` linters in a single job
70 | - language: 'python'
71 | env: 'Lint_pre-commit'
72 | name: 'Lint: pre-commit'
73 | before_install: 'skip'
74 | cache:
75 | directories:
76 | - $HOME/.cache/pre-commit
77 | script:
78 | # Install and run `pre-commit`
79 | - pip install pre-commit==2.7.1
80 | - pre-commit run --all-files --color always --verbose
81 | - pre-commit run --color always --hook-stage manual --verbose commitlint-travis
82 |
83 | ## Define the rest of the matrix based on Kitchen testing
84 | # Make sure the instances listed below match up with
85 | # the `platforms` defined in `kitchen.yml`
86 | # - env: INSTANCE=default-debian-11-tiamat-py3
87 | # - env: INSTANCE=default-debian-10-tiamat-py3
88 | # - env: INSTANCE=default-debian-9-tiamat-py3
89 | # - env: INSTANCE=default-ubuntu-2204-tiamat-py3
90 | # - env: INSTANCE=default-ubuntu-2004-tiamat-py3
91 | # - env: INSTANCE=default-ubuntu-1804-tiamat-py3
92 | # - env: INSTANCE=default-centos-stream8-tiamat-py3
93 | # - env: INSTANCE=default-centos-7-tiamat-py3
94 | # - env: INSTANCE=default-amazonlinux-2-tiamat-py3
95 | # - env: INSTANCE=default-oraclelinux-8-tiamat-py3
96 | # - env: INSTANCE=default-oraclelinux-7-tiamat-py3
97 | # - env: INSTANCE=default-almalinux-8-tiamat-py3
98 | # - env: INSTANCE=default-rockylinux-8-tiamat-py3
99 | # - env: INSTANCE=default-debian-11-master-py3
100 | # - env: INSTANCE=repo-debian-11-master-py3
101 | - env: INSTANCE=debian-11-master-py3
102 | # - env: INSTANCE=default-debian-10-master-py3
103 | # - env: INSTANCE=repo-debian-10-master-py3
104 | - env: INSTANCE=debian-10-master-py3
105 | # - env: INSTANCE=default-debian-9-master-py3
106 | # - env: INSTANCE=repo-debian-9-master-py3
107 | - env: INSTANCE=debian-9-master-py3
108 | # - env: INSTANCE=default-ubuntu-2204-master-py3
109 | # - env: INSTANCE=repo-ubuntu-2204-master-py3
110 | - env: INSTANCE=ubuntu-2204-master-py3
111 | # - env: INSTANCE=default-ubuntu-2004-master-py3
112 | # - env: INSTANCE=repo-ubuntu-2004-master-py3
113 | - env: INSTANCE=ubuntu-2004-master-py3
114 | # - env: INSTANCE=default-ubuntu-1804-master-py3
115 | # - env: INSTANCE=repo-ubuntu-1804-master-py3
116 | - env: INSTANCE=ubuntu-1804-master-py3
117 | # - env: INSTANCE=default-centos-stream8-master-py3
118 | # - env: INSTANCE=repo-centos-stream8-master-py3
119 | - env: INSTANCE=centos-stream8-master-py3
120 | # - env: INSTANCE=default-centos-7-master-py3
121 | # - env: INSTANCE=repo-centos-7-master-py3
122 | - env: INSTANCE=centos-7-master-py3
123 | - env: INSTANCE=default-fedora-36-master-py3
124 | # - env: INSTANCE=repo-fedora-36-master-py3
125 | # - env: INSTANCE=fedora-36-master-py3
126 | - env: INSTANCE=default-fedora-35-master-py3
127 | # - env: INSTANCE=repo-fedora-35-master-py3
128 | # - env: INSTANCE=fedora-35-master-py3
129 | - env: INSTANCE=default-opensuse-leap-153-master-py3
130 | # - env: INSTANCE=repo-opensuse-leap-153-master-py3
131 | # - env: INSTANCE=opensuse-leap-153-master-py3
132 | - env: INSTANCE=default-opensuse-tmbl-latest-master-py3
133 | # - env: INSTANCE=repo-opensuse-tmbl-latest-master-py3
134 | # - env: INSTANCE=opensuse-tmbl-latest-master-py3
135 | # - env: INSTANCE=default-amazonlinux-2-master-py3
136 | # - env: INSTANCE=repo-amazonlinux-2-master-py3
137 | - env: INSTANCE=amazonlinux-2-master-py3
138 | # - env: INSTANCE=default-oraclelinux-8-master-py3
139 | # - env: INSTANCE=repo-oraclelinux-8-master-py3
140 | - env: INSTANCE=oraclelinux-8-master-py3
141 | # - env: INSTANCE=default-oraclelinux-7-master-py3
142 | # - env: INSTANCE=repo-oraclelinux-7-master-py3
143 | - env: INSTANCE=oraclelinux-7-master-py3
144 | - env: INSTANCE=default-arch-base-latest-master-py3
145 | # - env: INSTANCE=repo-arch-base-latest-master-py3
146 | # - env: INSTANCE=arch-base-latest-master-py3
147 | # - env: INSTANCE=default-gentoo-stage3-latest-master-py3
148 | # - env: INSTANCE=repo-gentoo-stage3-latest-master-py3
149 | # - env: INSTANCE=gentoo-stage3-latest-master-py3
150 | # - env: INSTANCE=default-gentoo-stage3-systemd-master-py3
151 | # - env: INSTANCE=repo-gentoo-stage3-systemd-master-py3
152 | # - env: INSTANCE=gentoo-stage3-systemd-master-py3
153 | # - env: INSTANCE=default-almalinux-8-master-py3
154 | # - env: INSTANCE=repo-almalinux-8-master-py3
155 | - env: INSTANCE=almalinux-8-master-py3
156 | # - env: INSTANCE=default-rockylinux-8-master-py3
157 | # - env: INSTANCE=repo-rockylinux-8-master-py3
158 | - env: INSTANCE=rockylinux-8-master-py3
159 | # - env: INSTANCE=default-debian-11-3004-1-py3
160 | # - env: INSTANCE=default-debian-10-3004-1-py3
161 | # - env: INSTANCE=default-debian-9-3004-1-py3
162 | # - env: INSTANCE=default-ubuntu-2204-3004-1-py3
163 | # - env: INSTANCE=default-ubuntu-2004-3004-1-py3
164 | # - env: INSTANCE=default-ubuntu-1804-3004-1-py3
165 | # - env: INSTANCE=default-centos-stream8-3004-1-py3
166 | # - env: INSTANCE=default-centos-7-3004-1-py3
167 | # - env: INSTANCE=default-fedora-36-3004-1-py3
168 | # - env: INSTANCE=default-fedora-35-3004-1-py3
169 | # - env: INSTANCE=default-amazonlinux-2-3004-1-py3
170 | # - env: INSTANCE=default-oraclelinux-8-3004-1-py3
171 | # - env: INSTANCE=default-oraclelinux-7-3004-1-py3
172 | # - env: INSTANCE=default-arch-base-latest-3004-1-py3
173 | # - env: INSTANCE=default-gentoo-stage3-latest-3004-1-py3
174 | # - env: INSTANCE=default-gentoo-stage3-systemd-3004-1-py3
175 | # - env: INSTANCE=default-almalinux-8-3004-1-py3
176 | # - env: INSTANCE=default-rockylinux-8-3004-1-py3
177 | # - env: INSTANCE=default-opensuse-leap-153-3004-0-py3
178 | # - env: INSTANCE=default-opensuse-tmbl-latest-3004-0-py3
179 | # - env: INSTANCE=default-debian-10-3003-4-py3
180 | # - env: INSTANCE=default-debian-9-3003-4-py3
181 | # - env: INSTANCE=default-ubuntu-2004-3003-4-py3
182 | # - env: INSTANCE=default-ubuntu-1804-3003-4-py3
183 | # - env: INSTANCE=default-centos-stream8-3003-4-py3
184 | # - env: INSTANCE=default-centos-7-3003-4-py3
185 | # - env: INSTANCE=default-amazonlinux-2-3003-4-py3
186 | # - env: INSTANCE=default-oraclelinux-8-3003-4-py3
187 | # - env: INSTANCE=default-oraclelinux-7-3003-4-py3
188 | # - env: INSTANCE=default-almalinux-8-3003-4-py3
189 |
190 | ## Define the release stage that runs `semantic-release`
191 | - stage: 'release'
192 | language: 'node_js'
193 | node_js: 'lts/*'
194 | env: 'Release'
195 | name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA'
196 | before_install: 'skip'
197 | script:
198 | # Update `AUTHORS.md`
199 | - export MAINTAINER_TOKEN=${GH_TOKEN}
200 | - go get github.com/myii/maintainer
201 | - maintainer contributor
202 |
203 | # Install all dependencies required for `semantic-release`
204 | - npm i -D @semantic-release/changelog@3
205 | @semantic-release/exec@3
206 | @semantic-release/git@7
207 | deploy:
208 | provider: 'script'
209 | # Opt-in to `dpl v2` to complete the Travis build config validation (beta)
210 | # * https://docs.travis-ci.com/user/build-config-validation
211 | # Deprecated `skip_cleanup` can now be avoided, `cleanup: false` is by default
212 | edge: true
213 | # Run `semantic-release`
214 | script: 'npx semantic-release@15.14'
215 |
216 | # Notification options: `always`, `never` or `change`
217 | notifications:
218 | webhooks:
219 | if: 'repo = saltstack-formulas/prometheus-formula'
220 | urls:
221 | - https://saltstack-formulas.zulipchat.com/api/v1/external/travis?api_key=HsIq3o5QmLxdnVCKF9is0FUIpkpAY79P&stream=CI&topic=saltstack-formulas%2Fprometheus-formula&ignore_pull_requests=true
222 | on_success: always # default: always
223 | on_failure: always # default: always
224 | on_start: always # default: never
225 | on_cancel: always # default: always
226 | on_error: always # default: always
227 |
--------------------------------------------------------------------------------
/.yamllint:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | # Extend the `default` configuration provided by `yamllint`
5 | extends: 'default'
6 |
7 | # Files to ignore completely
8 | # 1. All YAML files under directory `.bundle/`, introduced if gems are installed locally
9 | # 2. All YAML files under directory `.cache/`, introduced during the CI run
10 | # 3. All YAML files under directory `.git/`
11 | # 4. All YAML files under directory `node_modules/`, introduced during the CI run
12 | # 5. Any SLS files under directory `test/`, which are actually state files
13 | # 6. Any YAML files under directory `.kitchen/`, introduced during local testing
14 | # 7. `kitchen.vagrant.yml`, which contains Embedded Ruby (ERB) template syntax
15 | ignore: |
16 | .bundle/
17 | .cache/
18 | .git/
19 | node_modules/
20 | test/**/states/**/*.sls
21 | .kitchen/
22 | kitchen.vagrant.yml
23 | prometheus/osfamilymap.yaml
24 | test/salt/pillar/repo.sls
25 |
26 | yaml-files:
27 | # Default settings
28 | - '*.yaml'
29 | - '*.yml'
30 | - .salt-lint
31 | - .yamllint
32 | # SaltStack Formulas additional settings
33 | - '*.example'
34 | - test/**/*.sls
35 |
36 | rules:
37 | empty-values:
38 | forbid-in-block-mappings: true
39 | forbid-in-flow-mappings: true
40 | line-length:
41 | # Increase from default of `80`
42 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
43 | max: 88
44 | octal-values:
45 | forbid-implicit-octal: true
46 | forbid-explicit-octal: true
47 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | # Authors
2 |
3 | This list is sorted by the number of commits per contributor in _descending_ order.
4 |
5 | Avatar|Contributor|Contributions
6 | :-:|---|:-:
7 |
|[@myii](https://github.com/myii)|151
8 |
|[@noelmcloughlin](https://github.com/noelmcloughlin)|57
9 |
|[@alxwr](https://github.com/alxwr)|17
10 |
|[@javierbertoli](https://github.com/javierbertoli)|15
11 |
|[@n-rodriguez](https://github.com/n-rodriguez)|11
12 |
|[@lagooj](https://github.com/lagooj)|9
13 |
|[@mdschmitt](https://github.com/mdschmitt)|8
14 |
|[@aboe76](https://github.com/aboe76)|6
15 |
|[@dafyddj](https://github.com/dafyddj)|3
16 |
|[@mgomersbach](https://github.com/mgomersbach)|2
17 |
|[@baby-gnu](https://github.com/baby-gnu)|2
18 |
|[@Ahummeling](https://github.com/Ahummeling)|1
19 |
20 | ---
21 |
22 | Auto-generated by a [forked version](https://github.com/myii/maintainer) of [gaocegege/maintainer](https://github.com/gaocegege/maintainer) on 2022-07-11.
23 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
2 |
3 | # SECTION: Owner(s) for everything in the repo, unless a later match takes precedence
4 | # FILE PATTERN OWNER(S)
5 | * @alxwr @noelmcloughlin
6 |
7 | # SECTION: Owner(s) for specific directories
8 | # FILE PATTERN OWNER(S)
9 |
10 | # SECTION: Owner(s) for files/directories related to `semantic-release`
11 | # FILE PATTERN OWNER(S)
12 | /.github/workflows/ @saltstack-formulas/ssf
13 | /bin/install-hooks @saltstack-formulas/ssf
14 | /bin/kitchen @saltstack-formulas/ssf
15 | /docs/AUTHORS.rst @saltstack-formulas/ssf
16 | /docs/CHANGELOG.rst @saltstack-formulas/ssf
17 | /docs/TOFS_pattern.rst @saltstack-formulas/ssf
18 | /*/_mapdata/ @saltstack-formulas/ssf
19 | /*/libsaltcli.jinja @saltstack-formulas/ssf
20 | /*/libtofs.jinja @saltstack-formulas/ssf
21 | /test/integration/**/_mapdata.rb @saltstack-formulas/ssf
22 | /test/integration/**/libraries/system.rb @saltstack-formulas/ssf
23 | /test/integration/**/inspec.yml @saltstack-formulas/ssf
24 | /test/integration/**/README.md @saltstack-formulas/ssf
25 | /test/salt/pillar/top.sls @saltstack-formulas/ssf
26 | /.gitignore @saltstack-formulas/ssf
27 | /.cirrus.yml @saltstack-formulas/ssf
28 | /.gitlab-ci.yml @saltstack-formulas/ssf
29 | /.pre-commit-config.yaml @saltstack-formulas/ssf
30 | /.rstcheck.cfg @saltstack-formulas/ssf
31 | /.rubocop.yml @saltstack-formulas/ssf
32 | /.salt-lint @saltstack-formulas/ssf
33 | /.travis.yml @saltstack-formulas/ssf
34 | /.yamllint @saltstack-formulas/ssf
35 | /AUTHORS.md @saltstack-formulas/ssf
36 | /CHANGELOG.md @saltstack-formulas/ssf
37 | /CODEOWNERS @saltstack-formulas/ssf
38 | /commitlint.config.js @saltstack-formulas/ssf
39 | /FORMULA @saltstack-formulas/ssf
40 | /Gemfile @saltstack-formulas/ssf
41 | /Gemfile.lock @saltstack-formulas/ssf
42 | /kitchen.yml @saltstack-formulas/ssf
43 | /kitchen.vagrant.yml @saltstack-formulas/ssf
44 | /kitchen.windows.yml @saltstack-formulas/ssf
45 | /pre-commit_semantic-release.sh @saltstack-formulas/ssf
46 | /release-rules.js @saltstack-formulas/ssf
47 | /release.config.js @saltstack-formulas/ssf
48 |
49 | # SECTION: Owner(s) for specific files
50 | # FILE PATTERN OWNER(S)
51 |
--------------------------------------------------------------------------------
/FORMULA:
--------------------------------------------------------------------------------
1 | name: prometheus
2 | os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Amazon, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS
3 | os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS
4 | version: 5.6.5
5 | release: 1
6 | minimum_version: 2019.2
7 | summary: prometheus formula
8 | description: Formula to install prometheus and configure it
9 | top_level_dir: prometheus
10 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | source ENV.fetch('PROXY_RUBYGEMSORG', 'https://rubygems.org')
4 |
5 | # Install the `inspec` gem using `git` because versions after `4.22.22`
6 | # suppress diff output; this version fixes this for our uses.
7 | # rubocop:disable Layout/LineLength
8 | gem 'inspec', git: 'https://gitlab.com/saltstack-formulas/infrastructure/inspec', branch: 'ssf'
9 | # rubocop:enable Layout/LineLength
10 |
11 | # Install the `kitchen-docker` gem using `git` in order to gain a performance
12 | # improvement: avoid package installations which are already covered by the
13 | # `salt-image-builder` (i.e. the pre-salted images that we're using)
14 | # rubocop:disable Layout/LineLength
15 | gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure/kitchen-docker', branch: 'ssf'
16 | # rubocop:enable Layout/LineLength
17 |
18 | gem 'kitchen-inspec', '>= 2.5.0'
19 | gem 'kitchen-salt', '>= 0.7.2'
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 Salt Stack Formulas
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/bin/install-hooks:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | set -o nounset # Treat unset variables as an error and immediately exit
3 | set -o errexit # If a command fails exit the whole script
4 |
5 | if [ "${DEBUG:-false}" = "true" ]; then
6 | set -x # Run the entire script in debug mode
7 | fi
8 |
9 | if ! command -v pre-commit >/dev/null 2>&1; then
10 | echo "pre-commit not found: please install or check your PATH" >&2
11 | echo "See https://pre-commit.com/#installation" >&2
12 | exit 1
13 | fi
14 |
15 | pre-commit install --install-hooks
16 | pre-commit install --hook-type commit-msg --install-hooks
17 |
--------------------------------------------------------------------------------
/bin/kitchen:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'kitchen' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require 'pathname'
12 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13 | Pathname.new(__FILE__).realpath)
14 |
15 | bundle_binstub = File.expand_path('bundle', __dir__)
16 |
17 | if File.file?(bundle_binstub)
18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19 | load(bundle_binstub)
20 | else
21 | abort(
22 | 'Your `bin/bundle` was not generated by Bundler, ' \
23 | 'so this binstub cannot run. Replace `bin/bundle` by running ' \
24 | '`bundle binstubs bundler --force`, then run this command again.'
25 | )
26 | end
27 | end
28 |
29 | require 'rubygems'
30 | require 'bundler/setup'
31 |
32 | load Gem.bin_path('test-kitchen', 'kitchen')
33 |
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['@commitlint/config-conventional'],
3 | rules: {
4 | 'body-max-line-length': [2, 'always', 120],
5 | 'footer-max-line-length': [2, 'always', 120],
6 | 'header-max-length': [2, 'always', 72],
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/docs/AUTHORS.rst:
--------------------------------------------------------------------------------
1 | .. role:: raw-html-m2r(raw)
2 | :format: html
3 |
4 |
5 | Authors
6 | =======
7 |
8 | This list is sorted by the number of commits per contributor in *descending* order.
9 |
10 | .. list-table::
11 | :header-rows: 1
12 |
13 | * - Avatar
14 | - Contributor
15 | - Contributions
16 | * - :raw-html-m2r:`
`
17 | - `@myii `_
18 | - 132
19 | * - :raw-html-m2r:`
`
20 | - `@noelmcloughlin `_
21 | - 57
22 | * - :raw-html-m2r:`
`
23 | - `@alxwr `_
24 | - 17
25 | * - :raw-html-m2r:`
`
26 | - `@javierbertoli `_
27 | - 14
28 | * - :raw-html-m2r:`
`
29 | - `@n-rodriguez `_
30 | - 11
31 | * - :raw-html-m2r:`
`
32 | - `@lagooj `_
33 | - 9
34 | * - :raw-html-m2r:`
`
35 | - `@mdschmitt `_
36 | - 7
37 | * - :raw-html-m2r:`
`
38 | - `@aboe76 `_
39 | - 6
40 | * - :raw-html-m2r:`
`
41 | - `@dafyddj `_
42 | - 3
43 | * - :raw-html-m2r:`
`
44 | - `@mgomersbach `_
45 | - 2
46 | * - :raw-html-m2r:`
`
47 | - `@baby-gnu `_
48 | - 2
49 | * - :raw-html-m2r:`
`
50 | - `@Ahummeling `_
51 | - 1
52 |
53 |
54 | ----
55 |
56 | Auto-generated by a `forked version `_ of `gaocegege/maintainer `_ on 2022-02-26.
57 |
--------------------------------------------------------------------------------
/docs/README.rst:
--------------------------------------------------------------------------------
1 | prometheus-formula
2 | ==================
3 |
4 | Formula to manage Prometheus on GNU/Linux and MacOS.
5 |
6 | |img_travis| |img_sr|
7 |
8 | .. |img_travis| image:: https://travis-ci.com/saltstack-formulas/prometheus-formula.svg?branch=master
9 | :alt: Travis CI Build Status
10 | :scale: 100%
11 | :target: https://travis-ci.com/saltstack-formulas/prometheus-formula
12 | .. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
13 | :alt: Semantic Release
14 | :scale: 100%
15 | :target: https://github.com/semantic-release/semantic-release
16 |
17 |
18 | .. contents:: **Table of Contents**
19 | :depth: 1
20 |
21 | General notes
22 | -------------
23 |
24 | See the full `SaltStack Formulas installation and usage instructions
25 | `_. If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section
26 | `_. If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``, which contains the currently released version. This formula is versioned according to `Semantic Versioning `_. See `Formula Versioning Section `_ for more details.
27 |
28 | Special notes
29 | -------------
30 |
31 | None.
32 |
33 | Contributing to this repo
34 | -------------------------
35 |
36 | **Commit message formatting is significant!!**
37 |
38 | Please see `How to contribute `_ for more details.
39 |
40 | Available metastates
41 | --------------------
42 |
43 | .. contents::
44 | :local:
45 |
46 | ``prometheus``
47 | ^^^^^^^^^^^^^^
48 |
49 | *Meta-state (This is a state that includes other states)*.
50 |
51 | This installs from prometheus solution.
52 |
53 |
54 | ``prometheus.archive``
55 | ^^^^^^^^^^^^^^^^^^^^^^
56 |
57 | This state will install prometheus components on MacOS and GNU/Linux from archive.
58 |
59 | ``prometheus.clientlibs``
60 | ^^^^^^^^^^^^^^^^^^^^^^^^^
61 |
62 | This state will install prometheus client libraries on MacOS and GNU/Linux from archive.
63 |
64 | ``prometheus.package``
65 | ^^^^^^^^^^^^^^^^^^^^^^
66 |
67 | This state will install prometheus component packages from GNU/Linux.
68 |
69 | ``prometheus.config``
70 | ^^^^^^^^^^^^^^^^^^^^^
71 |
72 | This state will apply prometheus service configuration (files).
73 |
74 | ``prometheus.service``
75 | ^^^^^^^^^^^^^^^^^^^^^^
76 |
77 | This state will start prometheus component services.
78 |
79 | ``prometheus.exporters``
80 | ^^^^^^^^^^^^^^^^^^^^^^^^
81 |
82 | This state will apply prometheus exporters configuration.
83 |
84 | ``prometheus.exporters.clean``
85 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86 |
87 | This state will remove prometheus exporters configuration.
88 |
89 | ``prometheus.service.clean``
90 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91 |
92 | This state will stop prometheus component services.
93 |
94 | ``prometheus.config.clean``
95 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
96 |
97 | This state will remove prometheus service configuration (files).
98 |
99 | ``prometheus.package.clean``
100 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
101 |
102 | This state will uninstall prometheus component packages from GNU/Linux.
103 |
104 | ``prometheus.clientlibs.clean``
105 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106 |
107 | This state will uninstall prometheus client libraries.
108 |
109 | ``prometheus.archive.clean``
110 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111 |
112 | This state will remove prometheus component archive (directories).
113 |
114 |
115 | Testing
116 | -------
117 |
118 | Linux testing is done with ``kitchen-salt``.
119 |
120 | Requirements
121 | ^^^^^^^^^^^^
122 |
123 | * Ruby
124 | * Docker
125 |
126 | .. code-block:: bash
127 |
128 | $ gem install bundler
129 | $ bundle install
130 | $ bin/kitchen test [platform]
131 |
132 | Where ``[platform]`` is the platform name defined in ``kitchen.yml``,
133 | e.g. ``debian-9-2019-2-py3``.
134 |
135 | ``bin/kitchen converge``
136 | ^^^^^^^^^^^^^^^^^^^^^^^^
137 |
138 | Creates the docker instance and runs the ``prometheus`` main state, ready for testing.
139 |
140 | ``bin/kitchen verify``
141 | ^^^^^^^^^^^^^^^^^^^^^^
142 |
143 | Runs the ``inspec`` tests on the actual instance.
144 |
145 | ``bin/kitchen destroy``
146 | ^^^^^^^^^^^^^^^^^^^^^^^
147 |
148 | Removes the docker instance.
149 |
150 | ``bin/kitchen test``
151 | ^^^^^^^^^^^^^^^^^^^^
152 |
153 | Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.
154 |
155 | ``bin/kitchen login``
156 | ^^^^^^^^^^^^^^^^^^^^^
157 |
158 | Gives you SSH access to the instance for manual testing.
159 |
160 |
--------------------------------------------------------------------------------
/docs/_static/css/custom.css:
--------------------------------------------------------------------------------
1 | /*
2 | Override styles for in-use Sphinx theme
3 | */
4 |
5 | /* The next two `.wy`-based rules are specifically needed for the dealing with */
6 | /* the `sphinx_rtd_theme` bug where long lines do not wrap in tables */
7 |
8 | /* override table width restrictions */
9 | .wy-table-responsive table th
10 | , .wy-table-responsive table td
11 | {
12 | /* !important prevents the common CSS stylesheets from
13 | overriding this as on RTD they are loaded after this stylesheet */
14 | white-space: normal !important;
15 | }
16 |
17 | .wy-table-responsive
18 | {
19 | overflow: visible !important;
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/kitchen.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | # For help on this file's format, see https://kitchen.ci/
5 | driver:
6 | name: docker
7 | use_sudo: false
8 | privileged: true
9 | run_command: /usr/lib/systemd/systemd
10 |
11 | provisioner:
12 | name: salt_solo
13 | log_level: debug
14 | salt_install: none
15 | require_chef: false
16 | formula: prometheus
17 | salt_copy_filter:
18 | - .kitchen
19 | - .git
20 |
21 | platforms:
22 | ## SALT `tiamat`
23 | - name: debian-11-tiamat-py3
24 | driver:
25 | image: saltimages/salt-tiamat-py3:debian-11
26 | run_command: /lib/systemd/systemd
27 | - name: debian-10-tiamat-py3
28 | driver:
29 | image: saltimages/salt-tiamat-py3:debian-10
30 | run_command: /lib/systemd/systemd
31 | - name: debian-9-tiamat-py3
32 | driver:
33 | image: saltimages/salt-tiamat-py3:debian-9
34 | run_command: /lib/systemd/systemd
35 | - name: ubuntu-2204-tiamat-py3
36 | driver:
37 | image: saltimages/salt-tiamat-py3:ubuntu-22.04
38 | run_command: /lib/systemd/systemd
39 | - name: ubuntu-2004-tiamat-py3
40 | driver:
41 | image: saltimages/salt-tiamat-py3:ubuntu-20.04
42 | run_command: /lib/systemd/systemd
43 | - name: ubuntu-1804-tiamat-py3
44 | driver:
45 | image: saltimages/salt-tiamat-py3:ubuntu-18.04
46 | run_command: /lib/systemd/systemd
47 | - name: centos-stream8-tiamat-py3
48 | driver:
49 | image: saltimages/salt-tiamat-py3:centos-stream8
50 | - name: centos-7-tiamat-py3
51 | driver:
52 | image: saltimages/salt-tiamat-py3:centos-7
53 | - name: amazonlinux-2-tiamat-py3
54 | driver:
55 | image: saltimages/salt-tiamat-py3:amazonlinux-2
56 | - name: oraclelinux-8-tiamat-py3
57 | driver:
58 | image: saltimages/salt-tiamat-py3:oraclelinux-8
59 | - name: oraclelinux-7-tiamat-py3
60 | driver:
61 | image: saltimages/salt-tiamat-py3:oraclelinux-7
62 | - name: almalinux-8-tiamat-py3
63 | driver:
64 | image: saltimages/salt-tiamat-py3:almalinux-8
65 | - name: rockylinux-8-tiamat-py3
66 | driver:
67 | image: saltimages/salt-tiamat-py3:rockylinux-8
68 |
69 | ## SALT `master`
70 | - name: debian-11-master-py3
71 | driver:
72 | image: saltimages/salt-master-py3:debian-11
73 | run_command: /lib/systemd/systemd
74 | - name: debian-10-master-py3
75 | driver:
76 | image: saltimages/salt-master-py3:debian-10
77 | run_command: /lib/systemd/systemd
78 | - name: debian-9-master-py3
79 | driver:
80 | image: saltimages/salt-master-py3:debian-9
81 | run_command: /lib/systemd/systemd
82 | - name: ubuntu-2204-master-py3
83 | driver:
84 | image: saltimages/salt-master-py3:ubuntu-22.04
85 | run_command: /lib/systemd/systemd
86 | - name: ubuntu-2004-master-py3
87 | driver:
88 | image: saltimages/salt-master-py3:ubuntu-20.04
89 | run_command: /lib/systemd/systemd
90 | - name: ubuntu-1804-master-py3
91 | driver:
92 | image: saltimages/salt-master-py3:ubuntu-18.04
93 | run_command: /lib/systemd/systemd
94 | - name: centos-stream8-master-py3
95 | driver:
96 | image: saltimages/salt-master-py3:centos-stream8
97 | - name: centos-7-master-py3
98 | driver:
99 | image: saltimages/salt-master-py3:centos-7
100 | - name: fedora-36-master-py3
101 | driver:
102 | image: saltimages/salt-master-py3:fedora-36
103 | - name: fedora-35-master-py3
104 | driver:
105 | image: saltimages/salt-master-py3:fedora-35
106 | - name: opensuse-leap-153-master-py3
107 | driver:
108 | image: saltimages/salt-master-py3:opensuse-leap-15.3
109 | # Workaround to avoid intermittent failures on `opensuse-leap-15.3`:
110 | # => SCP did not finish successfully (255): (Net::SCP::Error)
111 | transport:
112 | max_ssh_sessions: 1
113 | - name: opensuse-tmbl-latest-master-py3
114 | driver:
115 | image: saltimages/salt-master-py3:opensuse-tumbleweed-latest
116 | # Workaround to avoid intermittent failures on `opensuse-tumbleweed`:
117 | # => SCP did not finish successfully (255): (Net::SCP::Error)
118 | transport:
119 | max_ssh_sessions: 1
120 | - name: amazonlinux-2-master-py3
121 | driver:
122 | image: saltimages/salt-master-py3:amazonlinux-2
123 | - name: oraclelinux-8-master-py3
124 | driver:
125 | image: saltimages/salt-master-py3:oraclelinux-8
126 | - name: oraclelinux-7-master-py3
127 | driver:
128 | image: saltimages/salt-master-py3:oraclelinux-7
129 | - name: arch-base-latest-master-py3
130 | driver:
131 | image: saltimages/salt-master-py3:arch-base-latest
132 | - name: gentoo-stage3-latest-master-py3
133 | driver:
134 | image: saltimages/salt-master-py3:gentoo-stage3-latest
135 | run_command: /sbin/init
136 | - name: gentoo-stage3-systemd-master-py3
137 | driver:
138 | image: saltimages/salt-master-py3:gentoo-stage3-systemd
139 | - name: almalinux-8-master-py3
140 | driver:
141 | image: saltimages/salt-master-py3:almalinux-8
142 | - name: rockylinux-8-master-py3
143 | driver:
144 | image: saltimages/salt-master-py3:rockylinux-8
145 |
146 | ## SALT `3004.1`
147 | - name: debian-11-3004-1-py3
148 | driver:
149 | image: saltimages/salt-3004.1-py3:debian-11
150 | run_command: /lib/systemd/systemd
151 | - name: debian-10-3004-1-py3
152 | driver:
153 | image: saltimages/salt-3004.1-py3:debian-10
154 | run_command: /lib/systemd/systemd
155 | - name: debian-9-3004-1-py3
156 | driver:
157 | image: saltimages/salt-3004.1-py3:debian-9
158 | run_command: /lib/systemd/systemd
159 | - name: ubuntu-2204-3004-1-py3
160 | driver:
161 | image: saltimages/salt-3004.1-py3:ubuntu-22.04
162 | run_command: /lib/systemd/systemd
163 | - name: ubuntu-2004-3004-1-py3
164 | driver:
165 | image: saltimages/salt-3004.1-py3:ubuntu-20.04
166 | run_command: /lib/systemd/systemd
167 | - name: ubuntu-1804-3004-1-py3
168 | driver:
169 | image: saltimages/salt-3004.1-py3:ubuntu-18.04
170 | run_command: /lib/systemd/systemd
171 | - name: centos-stream8-3004-1-py3
172 | driver:
173 | image: saltimages/salt-3004.1-py3:centos-stream8
174 | - name: centos-7-3004-1-py3
175 | driver:
176 | image: saltimages/salt-3004.1-py3:centos-7
177 | - name: fedora-36-3004-1-py3
178 | driver:
179 | image: saltimages/salt-3004.1-py3:fedora-36
180 | - name: fedora-35-3004-1-py3
181 | driver:
182 | image: saltimages/salt-3004.1-py3:fedora-35
183 | - name: amazonlinux-2-3004-1-py3
184 | driver:
185 | image: saltimages/salt-3004.1-py3:amazonlinux-2
186 | - name: oraclelinux-8-3004-1-py3
187 | driver:
188 | image: saltimages/salt-3004.1-py3:oraclelinux-8
189 | - name: oraclelinux-7-3004-1-py3
190 | driver:
191 | image: saltimages/salt-3004.1-py3:oraclelinux-7
192 | - name: arch-base-latest-3004-1-py3
193 | driver:
194 | image: saltimages/salt-3004.1-py3:arch-base-latest
195 | - name: gentoo-stage3-latest-3004-1-py3
196 | driver:
197 | image: saltimages/salt-3004.1-py3:gentoo-stage3-latest
198 | run_command: /sbin/init
199 | - name: gentoo-stage3-systemd-3004-1-py3
200 | driver:
201 | image: saltimages/salt-3004.1-py3:gentoo-stage3-systemd
202 | - name: almalinux-8-3004-1-py3
203 | driver:
204 | image: saltimages/salt-3004.1-py3:almalinux-8
205 | - name: rockylinux-8-3004-1-py3
206 | driver:
207 | image: saltimages/salt-3004.1-py3:rockylinux-8
208 |
209 | ## SALT `3004.0`
210 | - name: opensuse-leap-153-3004-0-py3
211 | driver:
212 | image: saltimages/salt-3004.0-py3:opensuse-leap-15.3
213 | # Workaround to avoid intermittent failures on `opensuse-leap-15.3`:
214 | # => SCP did not finish successfully (255): (Net::SCP::Error)
215 | transport:
216 | max_ssh_sessions: 1
217 | - name: opensuse-tmbl-latest-3004-0-py3
218 | driver:
219 | image: saltimages/salt-3004.0-py3:opensuse-tumbleweed-latest
220 | # Workaround to avoid intermittent failures on `opensuse-tumbleweed`:
221 | # => SCP did not finish successfully (255): (Net::SCP::Error)
222 | transport:
223 | max_ssh_sessions: 1
224 |
225 | ## SALT `3003.4`
226 | - name: debian-10-3003-4-py3
227 | driver:
228 | image: saltimages/salt-3003.4-py3:debian-10
229 | run_command: /lib/systemd/systemd
230 | - name: debian-9-3003-4-py3
231 | driver:
232 | image: saltimages/salt-3003.4-py3:debian-9
233 | run_command: /lib/systemd/systemd
234 | - name: ubuntu-2004-3003-4-py3
235 | driver:
236 | image: saltimages/salt-3003.4-py3:ubuntu-20.04
237 | run_command: /lib/systemd/systemd
238 | - name: ubuntu-1804-3003-4-py3
239 | driver:
240 | image: saltimages/salt-3003.4-py3:ubuntu-18.04
241 | run_command: /lib/systemd/systemd
242 | - name: centos-stream8-3003-4-py3
243 | driver:
244 | image: saltimages/salt-3003.4-py3:centos-stream8
245 | - name: centos-7-3003-4-py3
246 | driver:
247 | image: saltimages/salt-3003.4-py3:centos-7
248 | - name: amazonlinux-2-3003-4-py3
249 | driver:
250 | image: saltimages/salt-3003.4-py3:amazonlinux-2
251 | - name: oraclelinux-8-3003-4-py3
252 | driver:
253 | image: saltimages/salt-3003.4-py3:oraclelinux-8
254 | - name: oraclelinux-7-3003-4-py3
255 | driver:
256 | image: saltimages/salt-3003.4-py3:oraclelinux-7
257 | - name: almalinux-8-3003-4-py3
258 | driver:
259 | image: saltimages/salt-3003.4-py3:almalinux-8
260 |
261 | verifier:
262 | # https://www.inspec.io/
263 | name: inspec
264 | sudo: true
265 | reporter:
266 | # cli, documentation, html, progress, json, json-min, json-rspec, junit
267 | - cli
268 |
269 | suites:
270 | - name: default
271 | provisioner:
272 | state_top:
273 | base:
274 | '*':
275 | - prometheus._mapdata
276 | - prometheus
277 | pillars:
278 | top.sls:
279 | base:
280 | '*':
281 | - prometheus
282 | pillars_from_files:
283 | prometheus.sls: test/salt/pillar/default.sls
284 | verifier:
285 | inspec_tests:
286 | - path: test/integration/default
287 | - name: repo
288 | provisioner:
289 | state_top:
290 | base:
291 | '*':
292 | - prometheus._mapdata
293 | - prometheus
294 | pillars:
295 | top.sls:
296 | base:
297 | '*':
298 | - prometheus
299 | pillars_from_files:
300 | prometheus.sls: test/salt/pillar/repo.sls
301 | verifier:
302 | inspec_tests:
303 | - path: test/integration/repo
304 |
--------------------------------------------------------------------------------
/pillar.example:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | # Prometheus has two approaches to handling config arguments, through an environment
5 | # file or directly adding to the service file.
6 | # This formular takes both approaches in seperate circumstances, with the archive
7 | # install approach implementing a custom service file, and the repo (default) approach
8 | # using an environ file with the standard package provided service file.
9 | # As a result, depending on the install method used, the environ:args or service:args
10 | # pillars need to be set appropriately.
11 | # The default options given under service in the default.yaml may not therefore apply
12 | # depending on the install method, and in some cases they are no longer consistent
13 | # with the default configuration in the latest package.
14 | # This applies to all components with an example provided for node_exporter.
15 | prometheus:
16 | wanted:
17 | clientlibs:
18 | - golang
19 | - haskell
20 | - rust
21 | component:
22 | # List components (ie, exporters) using underscores and
23 | # removing the 'prometheus' prefix
24 | - prometheus
25 | - alertmanager
26 | - node_exporter
27 | - php-fpm_exporter
28 | - postgres_exporter
29 | # - memcached_exporter # not in upstream repo, only archive
30 |
31 | exporters:
32 | node_exporter:
33 | textfile_collectors_dependencies: []
34 | textfile_collectors:
35 | ipmitool:
36 | enable: false
37 | remove: false
38 | pkg: ipmitool
39 | smartmon:
40 | enable: false
41 | remove: false
42 | pkg: smartmontools
43 | bash_pkg: bash
44 | smartctl: /usr/sbin/smartctl
45 | pkg:
46 | use_upstream_repo: false
47 | # Uses the archive install method with true or repo method with false. Default is
48 | # false.
49 | # The archive and repo methods use completely different approaches to
50 | # / service arguments handling, with different required pillar values.
51 | # The repo method uses the package service config, the archive method uses a custom
52 | # service config.
53 | use_upstream_archive: true
54 |
55 | clientlibs:
56 | # https://prometheus.io/docs/instrumenting/clientlibs
57 | # no bash & perl client tarballs are available
58 | golang:
59 | version: v1.6.0
60 | component:
61 | # If you use OS packages in Debian's family, components should have
62 | # a 'name' variable stating the name of the package (it's generally
63 | # something like `prometheus-component-with-dashes-replacing-underscores`
64 | # ie,
65 | # node_exporter:
66 | # name: prometheus-node-exporter
67 | #
68 | # See prometheus/osfamilymap.yaml for more examples
69 | alertmanager:
70 | config:
71 | # yamllint disable-line rule:line-length
72 | # ref https://github.com/prometheus/alertmanager/blob/master/config/testdata/conf.good.yml
73 | global:
74 | smtp_smarthost: 'localhost:25'
75 | smtp_from: 'alertmanager@example.org'
76 | smtp_auth_username: 'alertmanager'
77 | smtp_auth_password: "multiline\nmysecret"
78 | smtp_hello: "host.example.org"
79 | slack_api_url: "http://mysecret.example.com/"
80 | http_config:
81 | proxy_url: 'http://127.0.0.1:1025'
82 | route:
83 | group_by: ['alertname', 'cluster', 'service']
84 | group_wait: 30s
85 | group_interval: 5m
86 | repeat_interval: 3h
87 | receiver: team-X-mails
88 | routes:
89 | - match_re:
90 | service: ^(foo1|foo2|baz)$
91 | receiver: team-X-mails
92 | routes:
93 | - match:
94 | severity: critical
95 | receiver: team-X-mails
96 | receivers:
97 | - name: 'team-X-mails'
98 | email_configs:
99 | - to: 'team-X+alerts@example.org'
100 |
101 | inhibit_rules:
102 | - name: opsGenie-receiver
103 | opsgenie_configs:
104 | - api_key: mysecret
105 | - name: slack-receiver
106 | slack_configs:
107 | - channel: '#my-channel'
108 | image_url: 'http://some.img.com/img.png'
109 |
110 | node_exporter:
111 | version: v0.18.1
112 | archive:
113 | source_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
114 | environ:
115 | args:
116 | collector.systemd: null
117 | web.listen-address: ":9110"
118 | service:
119 | name: prometheus-node-exporter
120 | args:
121 | collector.systemd: null
122 | web.listen-address: ":9110"
123 | # collector.textfile.directory: /var/tmp/node_exporter
124 |
125 | prometheus:
126 | service:
127 | args:
128 | web.listen-address: 0.0.0.0:9090
129 | config:
130 | # yamllint disable-line rule:line-length
131 | # ref https://raw.githubusercontent.com/prometheus/prometheus/release-2.10/config/testdata/conf.good.yml
132 | # my global config
133 | global:
134 | # Set the scrape interval to every 15 seconds. Default is every 1 minute
135 | scrape_interval: 15s
136 | # Evaluate rules every 15 seconds. The default is every 1 minute
137 | evaluation_interval: 15s
138 | # scrape_timeout is set to the global default (10s)
139 |
140 | # Alertmanager configuration
141 | alerting:
142 | alertmanagers:
143 | - static_configs:
144 | - targets:
145 | - alertmanager1:9093
146 | - alertmanager2:9093
147 | - alertmanager3:9093
148 |
149 | # Load rules once and periodically evaluate them according to the global
150 | # 'evaluation_interval'
151 | # You can manage these files with the `extra_files` dict (see below)
152 | rule_files:
153 | - "first_rules.yml"
154 | # - "second_rules.yml"
155 |
156 | # A scrape configuration containing exactly one endpoint to scrape:
157 | scrape_configs:
158 | # The job name is added as a label `job=` to any timeseries
159 | # scraped from this config
160 | - job_name: 'prometheus'
161 | # metrics_path defaults to '/metrics'
162 | # scheme defaults to 'http'
163 | static_configs:
164 | - targets: ['localhost:9090']
165 |
166 | - job_name: pushgateway
167 | scrape_interval: 5s
168 | honor_labels: true
169 | static_configs:
170 | - targets: ['pushgateway:9091']
171 |
172 | - job_name: 'blackbox'
173 | # https://github.com/prometheus/blackbox_exporter#prometheus-configuration
174 | metrics_path: /probe
175 | params:
176 | module: [http_2xx] # Look for a HTTP 200 response
177 | static_configs:
178 | - targets:
179 | - http://prometheus.io # Target to probe with http
180 | - https://prometheus.io # Target to probe with https
181 | - http://example.com:8080 # Target to probe with http on port 8080
182 | relabel_configs:
183 | - source_labels: [__address__]
184 | target_label: __param_target
185 | - source_labels: [__param_target]
186 | target_label: instance
187 | - target_label: __address__
188 | replacement: '127.0.0.1:9115' # real hostname and port
189 |
190 | pushgateway:
191 | version: v0.8.0
192 | archive:
193 | source_hash: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
194 | service:
195 | args:
196 | web.listen-address: ":9091"
197 | web.telemetry-path: "/metrics"
198 |
199 | php-fpm_exporter:
200 | version: v0.6.1
201 | archive:
202 | official: false
203 | tar: false
204 | # yamllint disable-line rule:line-length
205 | source: https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64
206 | source_hash: 40e52d84f7decb5fdad9fadacf63cb2de26ebddce56e11b20651555e8d6c6130
207 | service:
208 | args:
209 | addr: ":9253"
210 | fastcgi: "unix:///run/php/php-fpm.sock"
211 |
212 | postgres_exporter:
213 | version: v0.8.0
214 | service:
215 | env:
216 | - 'DATA_SOURCE_NAME=foo:bar@/'
217 | archive:
218 | official: false
219 | # yamllint disable-line rule:line-length
220 | source: https://github.com/wrouesnel/postgres_exporter/releases/download/v0.8.0/postgres_exporter_v0.8.0_linux-amd64.tar.gz
221 | skip_verify: true
222 |
223 | mysqld_exporter:
224 | service:
225 | env:
226 | - 'DATA_SOURCE_NAME=foo:bar@/'
227 | linux:
228 | # 'Alternatives system' priority: zero disables (default)
229 | # yamllint disable-line rule:braces
230 | altpriority: {{ range(1, 100000) | random }}
231 |
232 | # This dict lets you manage other config files (like the `rule_files` for the
233 | # alertmanager) or split the config un multiple and organize files in meaninful ways
234 | extra_files:
235 | first_rules:
236 | component: alertmanager
237 | config:
238 | groups:
239 | - name: example
240 | rules:
241 | - alert: HighRequestLatency
242 | expr: 'job:request_latency_seconds:mean5m{job="myjob"} > 0.5'
243 | for: 10m
244 | labels:
245 | severity: page
246 | annotations:
247 | summary: High request latency
248 | # You can specify a `file` parameter, which will be used to create a file
249 | # under the prometheus config dir. In this example, the file will be
250 | # named /etc/prometheus/subdir/second.yml
251 | second_rules:
252 | file: subdir/second
253 | component: alertmanager
254 | config:
255 | groups:
256 | - name: example
257 | rules:
258 | - alert: HighRequestLatency
259 | expr: 'job:request_latency_seconds:mean5m{job="myjob"} > 0.5'
260 | for: 10m
261 | labels: {}
262 |
263 | tofs:
264 | # The files_switch key serves as a selector for alternative
265 | # directories under the formula files directory. See TOFS pattern
266 | # doc for more info
267 | # Note: Any value not evaluated by `config.get` will be used literally
268 | # This can be used to set custom paths, as many levels deep as required
269 | files_switch:
270 | - any/path/can/be/used/here
271 | - id
272 | - osfinger
273 | - os
274 | - os_family
275 | # All aspects of path/file resolution are customisable using the options below
276 | # This is unnecessary in most cases; there are sensible defaults
277 | # path_prefix: prometheus_alt
278 | # dirs:
279 | # files: files_alt
280 | # default: default_alt
281 | source_files:
282 | prometheus-config-file-file-managed:
283 | - 'alt_config.yml.jinja'
284 | prometheus-archive-install-managed-service:
285 | - 'alt_systemd.ini.jinja'
286 |
--------------------------------------------------------------------------------
/pre-commit_semantic-release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | ###############################################################################
4 | # (A) Update `FORMULA` with `${nextRelease.version}`
5 | ###############################################################################
6 | sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA
7 |
8 |
9 | ###############################################################################
10 | # (B) Use `m2r2` to convert automatically produced `.md` docs to `.rst`
11 | ###############################################################################
12 |
13 | # Install `m2r2`
14 | pip3 install m2r2
15 |
16 | # Copy and then convert the `.md` docs
17 | cp ./*.md docs/
18 | cd docs/ || exit
19 | m2r2 --overwrite ./*.md
20 |
21 | # Change excess `H1` headings to `H2` in converted `CHANGELOG.rst`
22 | sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst
23 | sed -i -e '1,4s/-/=/g' CHANGELOG.rst
24 |
25 | # Use for debugging output, when required
26 | # cat AUTHORS.rst
27 | # cat CHANGELOG.rst
28 |
29 | # Return back to the main directory
30 | cd ..
31 |
--------------------------------------------------------------------------------
/prometheus/_mapdata/_mapdata.jinja:
--------------------------------------------------------------------------------
1 | # yamllint disable rule:indentation rule:line-length
2 | # {{ grains.get("osfinger", grains.os) }}
3 | ---
4 | {#- use salt.slsutil.serialize to avoid encoding errors on some platforms #}
5 | {{ salt["slsutil.serialize"](
6 | "yaml",
7 | map,
8 | default_flow_style=False,
9 | allow_unicode=True,
10 | )
11 | | regex_replace("^\s+'$", "'", multiline=True)
12 | | trim
13 | }}
14 |
--------------------------------------------------------------------------------
/prometheus/_mapdata/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 | ---
4 | {#- Get the `tplroot` from `tpldir` #}
5 | {%- set tplroot = tpldir.split("/")[0] %}
6 | {%- from tplroot ~ "/map.jinja" import prometheus with context %}
7 |
8 | {%- set _mapdata = {
9 | "values": prometheus,
10 | } %}
11 | {%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %}
12 |
13 | {%- set output_dir = "/temp" if grains.os_family == "Windows" else "/tmp" %}
14 | {%- set output_file = output_dir ~ "/salt_mapdata_dump.yaml" %}
15 |
16 | {{ tplroot }}-mapdata-dump:
17 | file.managed:
18 | - name: {{ output_file }}
19 | - source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja
20 | - template: jinja
21 | - context:
22 | map: {{ _mapdata | yaml }}
23 |
--------------------------------------------------------------------------------
/prometheus/archive/alternatives/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- if grains.kernel|lower == 'linux' and p.linux.altpriority|int > 0 and grains.os_family != 'Arch' %}
8 | {%- if 'wanted' in p and p.wanted and 'component' in p.wanted and p.wanted.component %}
9 |
10 | {%- for name in p.wanted.component %}
11 | {%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
12 | {%- for cmd in p.pkg.component[name]['commands'] %}
13 |
14 | prometheus-server-alternatives-clean-{{ name }}-{{ cmd }}:
15 | alternatives.remove:
16 | - unless: {{ p.pkg.use_upstream_repo }}
17 | - name: link-prometheus-{{ name }}-{{ cmd }}
18 | - path: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
19 | - onlyif: update-alternatives --get-selections |grep ^prometheus-{{ name }}-{{ cmd }}
20 |
21 | {%- endfor %}
22 | {%- endif %}
23 | {%- endfor %}
24 |
25 | {%- endif %}
26 | {%- endif %}
27 |
--------------------------------------------------------------------------------
/prometheus/archive/alternatives/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .install
6 |
--------------------------------------------------------------------------------
/prometheus/archive/alternatives/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- if grains.kernel|lower == 'linux' and p.linux.altpriority|int > 0 and grains.os_family != 'Arch' %}
8 | {%- set sls_archive_install = tplroot ~ '.archive.install' %}
9 |
10 | include:
11 | - {{ sls_archive_install }}
12 |
13 | {%- if 'wanted' in p and p.wanted and 'component' in p.wanted and p.wanted.component %}
14 | {%- for name in p.wanted.component %}
15 | {%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
16 | {%- set dir_symlink = p.dir.symlink ~ '/bin' %}
17 | {%- if 'service' in p.pkg.component[name] %}
18 | {%- set dir_symlink = p.dir.symlink ~ '/sbin' %}
19 | {%- endif %}
20 | {%- for cmd in p.pkg.component[name]['commands'] %}
21 |
22 | prometheus-server-alternatives-install-{{ name }}-{{ cmd }}:
23 | cmd.run:
24 | - name: update-alternatives --install {{ dir_symlink }}/{{ cmd }} link-prometheus-{{ name }}-{{ cmd }} {{ p.pkg.component[name]['path'] }}/{{ cmd }} {{ p.linux.altpriority }} # noqa 204
25 | - unless:
26 | - {{ grains.os_family not in ('Suse',) }}
27 | - {{ p.pkg.use_upstream_repo }}
28 | - require:
29 | - sls: {{ sls_archive_install }}
30 | alternatives.install:
31 | - name: link-prometheus-{{ name }}-{{ cmd }}
32 | - link: {{ dir_symlink }}/{{ cmd }}
33 | - path: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
34 | - priority: {{ p.linux.altpriority }}
35 | - order: 10
36 | - require:
37 | - sls: {{ sls_archive_install }}
38 | - unless:
39 | - {{ grains.os_family in ('Suse',) }}
40 | - {{ p.pkg.use_upstream_repo }}
41 |
42 | prometheus-server-alternatives-set-{{ name }}-{{ cmd }}:
43 | alternatives.set:
44 | - name: link-prometheus-{{ name }}-{{ cmd }}
45 | - path: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
46 | - require:
47 | - alternatives: prometheus-server-alternatives-install-{{ name }}-{{ cmd }}
48 | - sls: {{ sls_archive_install }}
49 | - unless:
50 | - {{ grains.os_family in ('Suse',) }}
51 | - {{ p.pkg.use_upstream_repo }}
52 |
53 | {%- endfor %}
54 | {%- endif %}
55 | {%- endfor %}
56 | {%- endif %}
57 |
58 | {%- endif %}
59 |
--------------------------------------------------------------------------------
/prometheus/archive/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %}
7 | {%- set sls_service_clean = tplroot ~ '.service.clean' %}
8 |
9 | include:
10 | - {{ sls_service_clean }}
11 | - {{ sls_alternatives_clean }}
12 |
13 | prometheus-archive-clean-prerequisites:
14 | file.absent:
15 | - name: {{ p.dir.var }}
16 |
17 | {%- for name in p.wanted.component %}
18 |
19 | prometheus-archive-clean-{{ name }}:
20 | file.absent:
21 | - name: {{ p.pkg.component[name]['path'] }}
22 |
23 | {%- if (grains.kernel|lower == 'linux' and p.linux.altpriority|int <= 0) or grains.os_family|lower in ('macos', 'arch') %}
24 | {%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
25 | {%- for cmd in p.pkg.component[name]['commands'] %}
26 |
27 | prometheus-archive-clean-{{ name }}-file-symlink-{{ cmd }}:
28 | file.absent:
29 | - names:
30 | - {{ p.dir.symlink }}/bin/{{ cmd }}
31 | - {{ p.dir.symlink }}/sbin/{{ cmd }}
32 | - {{ p.dir.var }}/{{ name }}
33 | - {{ p.dir.service }}/{{ name }}.service
34 | - require:
35 | - sls: {{ sls_alternatives_clean }}
36 | - sls: {{ sls_service_clean }}
37 | - require_in:
38 | - user: prometheus-archive-clean-{{ name }}-user-group
39 |
40 | {%- endfor %}
41 | {%- endif %}
42 | {%- endif %}
43 | {%- endfor %}
44 |
--------------------------------------------------------------------------------
/prometheus/archive/init.sls:
--------------------------------------------------------------------------------
1 | #.-*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- if p.pkg.use_upstream_archive %}
8 |
9 | include:
10 | - .install
11 | - .alternatives
12 |
13 | {%- endif %}
14 |
--------------------------------------------------------------------------------
/prometheus/archive/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
7 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
8 | {%- set sls_config_users = tplroot ~ '.config.users' %}
9 |
10 | include:
11 | - {{ sls_config_users }}
12 |
13 | prometheus-archive-install-prerequisites:
14 | {%- if grains.os != 'Windows' %}
15 | pkg.installed:
16 | - names: {{ p.pkg.deps|json }}
17 | {%- endif %}
18 | file.directory:
19 | - name: {{ p.dir.var }}
20 | - makedirs: True
21 | - require:
22 | - sls: {{ sls_config_users }}
23 | {%- if grains.os != 'Windows' %}
24 | - mode: 755
25 | - user: {{ p.identity.rootuser }}
26 | - group: {{ p.identity.rootgroup }}
27 | {%- endif %}
28 |
29 | {%- for name in p.wanted.component %}
30 |
31 | prometheus-archive-directory-{{ name }}:
32 | file.directory:
33 | - name: {{ p.pkg.component[name]['path'] }}
34 | - makedirs: True
35 | {%- if grains.os != 'Windows' %}
36 | - user: {{ p.identity.rootuser }}
37 | - group: {{ p.identity.rootgroup }}
38 | - mode: '0755'
39 | - recurse:
40 | - user
41 | - group
42 | - mode
43 | {%- endif %}
44 | prometheus-archive-install-{{ name }}:
45 | {%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
46 | archive.extracted:
47 | {{- format_kwargs(p.pkg.component[name]['archive']) }}
48 | - trim_output: true
49 | - enforce_toplevel: false
50 | - options: --strip-components=1
51 | - force: {{ p.force }}
52 | - retry: {{ p.retry_option|json }}
53 | - require:
54 | - file: prometheus-archive-directory-{{ name }}
55 | {%- if grains.os != 'Windows' %}
56 | - user: {{ p.identity.rootuser }}
57 | - group: {{ p.identity.rootgroup }}
58 | {%- endif %}
59 | {% else %}
60 | file.managed:
61 | - name: {{ p.pkg.component[name]['path'] }}/{{ name }}
62 | - source: {{ p.pkg.component[name]['archive']['source'] }}
63 | - source_hash: {{ p.pkg.component[name]['archive']['source_hash'] }}
64 | - mode: '0755'
65 | - require:
66 | - file: prometheus-archive-directory-{{ name }}
67 | {%- if grains.os != 'Windows' %}
68 | - user: {{ p.identity.rootuser }}
69 | - group: {{ p.identity.rootgroup }}
70 | {%- endif %}
71 | {%- endif %}
72 | {%- if (grains.kernel|lower == 'linux' and p.linux.altpriority|int <= 0) or grains.os_family|lower in ('macos', 'arch') %}
73 | {%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
74 | {%- for cmd in p.pkg.component[name]['commands'] %}
75 |
76 | prometheus-archive-install-{{ name }}-file-symlink-{{ cmd }}:
77 | file.symlink:
78 | {%- if 'service' in p.pkg.component[name] %}
79 | - name: {{ p.dir.symlink }}/sbin/{{ cmd }}
80 | {%- else %}
81 | - name: {{ p.dir.symlink }}/bin/{{ cmd }}
82 | {% endif %}
83 | - target: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
84 | - force: True
85 | - require:
86 | {%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
87 | - archive: prometheus-archive-install-{{ name }}
88 | {% else %}
89 | - file: prometheus-archive-install-{{ name }}
90 | {% endif %}
91 |
92 | {%- endfor %}
93 | {%- endif %}
94 | {%- endif %}
95 | {%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] is mapping %}
96 |
97 | prometheus-archive-install-{{ name }}-file-directory:
98 | file.directory:
99 | - name: {{ p.dir.var }}{{ p.div }}{{ name }}
100 | - makedirs: True
101 | {%- if grains.os != 'Windows' %}
102 | - user: {{ name }}
103 | - group: {{ name }}
104 | - mode: '0755'
105 | - require:
106 | - user: prometheus-config-users-install-{{ name }}-user-present
107 | - group: prometheus-config-users-install-{{ name }}-group-present
108 |
109 | {%- endif %}
110 | {%- if grains.kernel|lower == 'linux' %}
111 |
112 | prometheus-archive-install-{{ name }}-managed-service:
113 | file.managed:
114 | - name: {{ p.dir.service }}/{{ p.pkg.component[name]['service'].get('name', name) }}.service
115 | - source: {{ files_switch(['systemd.ini.jinja'],
116 | lookup='prometheus-archive-install-' ~ name ~ '-managed-service'
117 | )
118 | }}
119 | - mode: '0644'
120 | - user: {{ p.identity.rootuser }}
121 | - group: {{ p.identity.rootgroup }}
122 | - makedirs: True
123 | - template: jinja
124 | - context:
125 | desc: prometheus - {{ name }} service
126 | name: {{ name }}
127 | user: {{ name }}
128 | group: {{ name }}
129 | env: {{ p.pkg.component[name]['service'].get('env', [])|tojson }}
130 | workdir: {{ p.dir.var }}/{{ name }}
131 | stop: ''
132 | {%- set all_args = p.pkg.component.get(name).get('service').get('args', {}) %}
133 | {%- set commandline_only_args = ["storage.tsdb.retention.time"] %}
134 | {%- if name in ('node_exporter', 'consul_exporter') or 'config_file' not in p.pkg.component[name] %}
135 | {%- set args = all_args %}
136 | {%- else %}
137 | {%- set args = {'config.file': p.pkg.component[name]['config_file']} %}
138 | {%- endif %}
139 | {%- for arg in commandline_only_args %}
140 | {%- set value = all_args.get(arg) %}
141 | {%- if value is not none %}
142 | {%- do args.update({arg: value}) %}
143 | {%- endif %}
144 | {%- endfor %}
145 | {%- set flags = [] %}
146 | {%- for param, value in args.items() %}
147 | {%- if value is not none %}
148 | {% do flags.append("--" ~ param ~ "=" ~ value ) %}
149 | {%- else %}
150 | {% do flags.append("--" ~ param ) %}
151 | {%- endif %}
152 | {%- endfor %}
153 | start: {{ p.pkg.component[name]['path'] }}/{{ name }} {{ flags|join(' ') }}
154 | - require:
155 | - file: prometheus-archive-install-{{ name }}-file-directory
156 | {%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
157 | - archive: prometheus-archive-install-{{ name }}
158 | {% else %}
159 | - file: prometheus-archive-install-{{ name }}
160 | {% endif %}
161 | - user: prometheus-config-users-install-{{ name }}-user-present
162 | - group: prometheus-config-users-install-{{ name }}-group-present
163 | cmd.run:
164 | - name: systemctl daemon-reload
165 | - onchanges:
166 | {%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
167 | - archive: prometheus-archive-install-{{ name }}
168 | {% else %}
169 | - file: prometheus-archive-install-{{ name }}
170 | {% endif %}
171 |
172 | {%- endif %}{# linux #}
173 | {%- endif %}{# service #}
174 | {%- endfor %}
175 |
--------------------------------------------------------------------------------
/prometheus/clean.sls:
--------------------------------------------------------------------------------
1 | #.-*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .service.clean
6 | - .config.clean
7 | - .exporters.clean
8 | - .clientlibs.clean
9 | - .archive.clean
10 | - .package.clean
11 |
--------------------------------------------------------------------------------
/prometheus/clientlibs/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- for name in p.wanted.clientlibs %}
8 |
9 | prometheus-clientlibs-clean-{{ name }}:
10 | file.absent:
11 | - name: {{ p.pkg.clientlibs[name]['path'] }}
12 |
13 | {%- endfor %}
14 |
--------------------------------------------------------------------------------
/prometheus/clientlibs/init.sls:
--------------------------------------------------------------------------------
1 | #.-*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .install
6 |
--------------------------------------------------------------------------------
/prometheus/clientlibs/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
7 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
8 | {%- set sls_archive_install = tplroot ~ '.archive.install' %}
9 | {%- set sls_package_install = tplroot ~ '.package.install' %}
10 |
11 | include:
12 | - {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
13 |
14 | {%- for name in p.wanted.clientlibs %}
15 |
16 | prometheus-clientlibs-install-{{ name }}:
17 | file.directory:
18 | - name: {{ p.pkg.clientlibs[name]['path'] }}
19 | - makedirs: True
20 | - require_in:
21 | - archive: prometheus-clientlibs-install-{{ name }}
22 | {%- if grains.os|lower != 'windows' %}
23 | - user: {{ p.identity.rootuser }}
24 | - group: {{ p.identity.rootgroup }}
25 | - mode: '0755'
26 | - recurse:
27 | - user
28 | - group
29 | - mode
30 | {%- endif %}
31 | {%- if grains.get('osfinger', '') in ['Oracle Linux Server-8', 'Amazon Linux-2'] %}
32 | pkg.installed:
33 | - name: tar
34 | - require_in:
35 | - archive: prometheus-clientlibs-install-{{ name }}
36 | {%- endif %}
37 | archive.extracted:
38 | {{- format_kwargs(p.pkg.clientlibs[name]['archive']) }}
39 | - trim_output: true
40 | - enforce_toplevel: false
41 | - force: {{ p.force }}
42 | - options: --strip-components=1
43 | - retry: {{ p.retry_option|json }}
44 | {%- if grains.os|lower != 'windows' %}
45 | - user: {{ p.identity.rootuser }}
46 | - group: {{ p.identity.rootgroup }}
47 | {%- endif %}
48 |
49 | {%- endfor %}
50 |
--------------------------------------------------------------------------------
/prometheus/config/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- set sls_service_clean = tplroot ~ '.service.clean' %}
7 |
8 | include:
9 | - {{ sls_service_clean }}
10 |
11 | {%- for name in p.wanted.component %}
12 |
13 | prometheus-config-clean-{{ name }}:
14 | - names:
15 | - {{ p.dir.etc }}{{ d.div }}{{ name }}.yml
16 | - {{ p.pkg.component[name]['environ_file'] }}
17 | {%- if grains.os_family|lower in ('freebsd',) %}
18 | sysrc.absent:
19 | - name: {{ name }}_environ
20 | {%- endif %}
21 | user.absent:
22 | - name: {{ name }}
23 | {%- if grains.os_family == 'MacOS' %}
24 | - onlyif: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
25 | {%- endif %}
26 | group.absent:
27 | - name: {{ name }}
28 | - require:
29 | - {{ sls_config_clean }}
30 |
31 | {%- endfor %}
32 |
--------------------------------------------------------------------------------
/prometheus/config/environ.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
7 | {%- from tplroot ~ "/files/macros.jinja" import concat_args %}
8 | {%- set sls_archive_install = tplroot ~ '.archive.install' %}
9 | {%- set sls_package_install = tplroot ~ '.package.install' %}
10 | {%- set sls_service_running = tplroot ~ '.service.running' %}
11 |
12 | include:
13 | - {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
14 | - {{ sls_service_running }}
15 |
16 | {%- for name in p.wanted.component %}
17 | {%- if 'environ' in p.pkg.component[name] and 'args' in p.pkg.component[name]['environ'] %}
18 | {%- set args = p.pkg.component[name]['environ']['args'] %}
19 | {%- set arg_name = p.pkg.component[name]['environ']['environ_arg_name'] %}
20 | {%- if 'environ_file' in p.pkg.component[name] and p.pkg.component[name]['environ_file'] %}
21 |
22 | prometheus-config-install-{{ name }}-environ_file:
23 | file.managed:
24 | - name: {{ p.pkg.component[name]['environ_file'] }}
25 | - source: {{ files_switch(['environ.sh.jinja'],
26 | lookup='prometheus-config-install-' ~ name ~ '-environ_file'
27 | )
28 | }}
29 | - makedirs: True
30 | - template: jinja
31 | {%- if grains.os != 'Windows' %}
32 | - mode: 640
33 | - user: {{ p.identity.rootuser }}
34 | - group: {{ p.identity.rootgroup }}
35 | {%- endif %}
36 | - context:
37 | args: {{ concat_args(args) }}
38 | arg_name: {{ arg_name }}
39 | - watch_in:
40 | - service: prometheus-service-running-{{ name }}
41 | - require:
42 | - sls: {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
43 |
44 | {%- if grains.os_family == 'FreeBSD' %}
45 |
46 | prometheus-config-environ-{{ name }}-all:
47 | sysrc.managed:
48 | - name: {{ name }}_environ
49 | # service prometheus restart tends to hang on FreeBSD
50 | # https://github.com/saltstack/salt/issues/44848#issuecomment-487016414
51 | - value: "{{ concat_args(p.pkg.component[name]['environ']) }} >/dev/null 2>&1"
52 | - watch_in:
53 | - service: prometheus-service-running-{{ name }}
54 |
55 | {%- endif %}
56 | {%- endif %}
57 | {%- endif %}
58 | {%- endfor %}
59 |
--------------------------------------------------------------------------------
/prometheus/config/file.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
7 |
8 | {%- set sls_archive_install = tplroot ~ '.archive.install' %}
9 | {%- set sls_package_install = tplroot ~ '.package.install' %}
10 | {%- set sls_config_users = tplroot ~ '.config.users' %}
11 |
12 | include:
13 | - {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
14 | - {{ sls_config_users }}
15 |
16 | prometheus-config-file-etc-file-directory:
17 | file.directory:
18 | - name: {{ p.dir.etc }}
19 | - makedirs: True
20 | {%- if grains.os != 'Windows' %}
21 | - mode: '0755'
22 | - user: {{ p.identity.rootuser }}
23 | - group: {{ p.identity.rootgroup }}
24 | {%- endif %}
25 | - require:
26 | - sls: {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
27 |
28 | # This loop manages the main config file for each component
29 | {%- for name in p.wanted.component %}
30 | {%- if 'config' in p.pkg.component[name] and p.pkg.component[name]['config'] %}
31 |
32 | prometheus-config-file-{{ name }}-file-managed:
33 | file.managed:
34 | - name: {{ p.dir.etc }}{{ p.div }}{{ name }}.yml
35 | - source: {{ files_switch(['config.yml.jinja'],
36 | lookup='prometheus-config-file-' ~ name ~ '-file-managed'
37 | )
38 | }}
39 | - makedirs: True
40 | - template: jinja
41 | {%- if grains.os != 'Windows' %}
42 | - mode: 644
43 | - user: {{ name }}
44 | - group: {{ name }}
45 | {%- endif %}
46 | - context:
47 | config: {{ p.pkg.component[name]['config']|json }}
48 | - require:
49 | - file: prometheus-config-file-etc-file-directory
50 | - user: prometheus-config-users-install-{{ name }}-user-present
51 | - group: prometheus-config-users-install-{{ name }}-group-present
52 | - watch_in:
53 | - service: prometheus-service-running-{{ name }}
54 |
55 | {%- endif %}
56 | {%- endfor %}
57 |
58 | # This loop manages other config files, like `rules_files`
59 | {%- for ef in p.extra_files %}
60 | {%- set name = p.extra_files[ef]['file'] | default(ef) %}
61 | {%- set component = p.extra_files[ef]['component'] | default('prometheus') %}
62 |
63 | prometheus-config-file-{{ ef }}-file-managed:
64 | file.managed:
65 | - name: {{ p.dir.etc }}{{ p.div }}{{ name }}.yml
66 | - source: {{ files_switch(['config.yml.jinja'],
67 | lookup='prometheus-config-file-' ~ ef ~ '-file-managed'
68 | )
69 | }}
70 | - makedirs: True
71 | - template: jinja
72 | {%- if grains.os != 'Windows' %}
73 | - mode: 644
74 | - user: {{ component }}
75 | - group: {{ component }}
76 | {%- endif %}
77 | - context:
78 | config: {{ p.extra_files[ef]['config'] }}
79 | - require:
80 | - file: prometheus-config-file-etc-file-directory
81 | - user: prometheus-config-users-install-{{ component }}-user-present
82 | - group: prometheus-config-users-install-{{ component }}-group-present
83 | - watch_in:
84 | - service: prometheus-service-running-{{ component }}
85 |
86 | {%- endfor %}
87 |
--------------------------------------------------------------------------------
/prometheus/config/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .file
6 | - .environ
7 | - .storage
8 |
--------------------------------------------------------------------------------
/prometheus/config/storage.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
7 | {%- from tplroot ~ "/files/macros.jinja" import concat_args %}
8 | {%- set sls_archive_install = tplroot ~ '.archive.install' %}
9 | {%- set sls_package_install = tplroot ~ '.package.install' %}
10 |
11 | include:
12 | - {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
13 |
14 | {%- for name in p.wanted.component %}
15 | {%- if 'environ' in p.pkg.component[name] and 'args' in p.pkg.component[name]['environ'] %}
16 | {%- set args = p.pkg.component[name]['environ']['args'] %}
17 | {%- if 'storage.tsdb.path' in args.keys() %}
18 |
19 | prometheus-service-args-{{ name }}-data-dir:
20 | file.directory:
21 | - name: {{ args['storage.tsdb.path'] }}
22 | - user: {{ name }}
23 | - group: {{ name }}
24 | - makedirs: True
25 | - watch_in:
26 | - service: prometheus-service-running-{{ name }}
27 | - require:
28 | - user: prometheus-config-users-install-{{ name }}-user-present
29 | - group: prometheus-config-users-install-{{ name }}-group-present
30 |
31 | {%- endif %}
32 | {% endif %}
33 | {% endfor %}
34 |
--------------------------------------------------------------------------------
/prometheus/config/users.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- for name in p.wanted.component %}
8 |
9 | prometheus-config-users-install-{{ name }}-group-present:
10 | group.present:
11 | - name: {{ name }}
12 | - system: true
13 | - require_in:
14 | - user: prometheus-config-users-install-{{ name }}-user-present
15 |
16 | prometheus-config-users-install-{{ name }}-user-present:
17 | user.present:
18 | - name: {{ name }}
19 | - groups:
20 | - {{ name }}
21 | {%- if grains.os != 'Windows' %}
22 | - shell: {{ p.shell }}
23 | {%- if grains.kernel|lower == 'linux' %}
24 | - createhome: false
25 | - system: true
26 | {%- elif grains.os_family == 'MacOS' %}
27 | - unless: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
28 | {%- endif %}
29 | {%- endif %}
30 |
31 | {%- endfor %}
32 |
--------------------------------------------------------------------------------
/prometheus/cpuarchmap.yaml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | #
4 | # Setup variables using grains['cuparch'] based logic.
5 | # You just need to add the key:values for an `osarch` that differ
6 | # from `defaults.yaml` + `os_family.yaml`.
7 | # Only add an `cpuarch` which is/will be supported by the formula
8 | #
9 | # If you do not need to provide defaults via the `cpuarch` grain,
10 | # you will need to provide at least an empty dict in this file, e.g.
11 | # cpuarch: {}
12 | ---
13 | # Windows has no 'osarch' grain
14 | Default:
15 | dingdong: null
16 |
17 | AMD64:
18 | arch: amd64
19 |
--------------------------------------------------------------------------------
/prometheus/defaults.yaml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | prometheus:
5 | div: '/'
6 | force: false
7 | overwrite: true
8 | extra_files: {}
9 | wanted:
10 | clientlibs: []
11 | component:
12 | - prometheus
13 | - alertmanager
14 | - node_exporter
15 | # memcached_exporter # only available as archive
16 | firewall: false # disabled for travis ci
17 | dir:
18 | default: /etc/default
19 | archive: /opt/prometheus
20 | etc: /etc/prometheus
21 | service: /usr/lib/systemd/system
22 | symlink: /usr/local
23 | tmp: /tmp/prometheus
24 | var: /var/lib/prometheus
25 |
26 | pkg:
27 | uri: https://github.com/prometheus
28 | use_upstream_repo: false
29 | use_upstream_package: true
30 | use_upstream_archive: false
31 | deps:
32 | - gzip
33 | - tar
34 | repo:
35 | humanname: prometheus
36 | name: prometheus
37 | comments:
38 | - installed by salt
39 | enabled: 1
40 | gpgcheck: 1
41 |
42 | component:
43 | alertmanager:
44 | version: v0.21.0
45 | config_file: /etc/prometheus/alertmanager.yml
46 | config: {}
47 | environ_file: /etc/default/prometheus-alertmanager
48 | environ:
49 | environ_arg_name: ARGS
50 | # These service args will not impact installs using the non archive method and
51 | # instead should be added as environ args in such a case
52 | service:
53 | args:
54 | config.file: /etc/prometheus/alertmanager.yml
55 | storage.path: /var/lib/alertmanager
56 | firewall:
57 | ports:
58 | - tcp/4505
59 | - tcp/4506
60 | - tcp/9093
61 | # tcp/9094
62 | archive:
63 | source_hash: 9ccd863937436fd6bfe650e22521a7f2e6a727540988eef515dde208f9aef232
64 | commands:
65 | - amtool
66 | - alertmanager
67 | blackbox_exporter:
68 | version: v0.18.0
69 | config_file: /etc/prometheus/blackbox_exporter.yml
70 | config: {}
71 | environ_file: /etc/default/prometheus-blackbox-exporter
72 | environ:
73 | environ_arg_name: ARGS
74 | archive:
75 | source_hash: a87f9530e31e2b20d03a6d941f6f051c57ee724f24b38f2615b8580ca63966dc
76 | commands:
77 | - blackbox_exporter
78 | firewall:
79 | ports:
80 | - tcp/4505
81 | - tcp/4506
82 | - tcp/9110
83 | consul_exporter:
84 | version: v0.7.1
85 | archive:
86 | source_hash: 92ffd37fb5f2350df21e7a688c28e7bb2882c309f613400eafdc411c818ec048
87 | commands:
88 | - consul_exporter
89 | firewall:
90 | ports:
91 | - tcp/4505
92 | - tcp/4506
93 | - tcp/9107
94 | graphite_exporter:
95 | version: v0.9.0
96 | archive:
97 | source_hash: 8da5bf07180f345abbd0e3c5ddf0f2bd319d930b6f9dd0385f4cfebdc6815c86
98 | commands:
99 | - graphite_exporter
100 | firewall:
101 | ports:
102 | - tcp/4505
103 | - tcp/4506
104 | - tcp/9108
105 | haproxy_exporter:
106 | version: v0.11.0
107 | archive:
108 | source_hash: 525ec4684b33a7fd1b23fe39e5c378e09cbc52b56fb3e203cffa26e09d22d10d
109 | commands:
110 | - haproxy_exporter
111 | firewall:
112 | ports:
113 | - tcp/4505
114 | - tcp/4506
115 | - tcp/9101
116 | memcached_exporter:
117 | version: v0.7.0
118 | archive:
119 | source_hash: a8dec3f2493330159b02ab5f8916726d2d41d70170f23206b1987cdb450a839b
120 | commands:
121 | - memcached_exporter
122 | firewall:
123 | ports:
124 | - tcp/4505
125 | - tcp/4506
126 | - tcp/9150
127 | mysqld_exporter:
128 | version: v0.12.1
129 | archive:
130 | source_hash: 133b0c281e5c6f8a34076b69ade64ab6cac7298507d35b96808234c4aa26b351
131 | commands:
132 | - mysqld_exporter
133 | firewall:
134 | ports:
135 | - tcp/4505
136 | - tcp/4506
137 | - tcp/9207
138 | node_exporter:
139 | version: v1.0.1
140 | environ_file: /etc/default/prometheus-node-exporter
141 | environ:
142 | environ_arg_name: ARGS
143 | config_file: /etc/prometheus/node_exporter.yml
144 | config: {}
145 | # These service args will not impact installs using the non archive method and
146 | # instead should be added as environ args in such a case
147 | service:
148 | args:
149 | collector.textfile.directory: /var/tmp/node_exporter
150 | archive:
151 | source_hash: 3369b76cd2b0ba678b6d618deab320e565c3d93ccb5c2a0d5db51a53857768ae
152 | commands:
153 | - node_exporter
154 | firewall:
155 | ports:
156 | - tcp/4505
157 | - tcp/4506
158 | - tcp/9100
159 | prometheus:
160 | name: prometheus
161 | version: v2.22.1
162 | config_file: /etc/prometheus/prometheus.yml
163 | config: {}
164 | environ_file: /etc/default/prometheus
165 | environ:
166 | environ_arg_name: ARGS
167 | # These service args will not impact installs using the non archive method and
168 | # instead should be added as environ args in such a case
169 | service:
170 | args:
171 | config.file: /etc/prometheus/prometheus.yml
172 | storage.tsdb.path: /var/lib/prometheus/data
173 | commands:
174 | - prometheus
175 | - promtool
176 | archive:
177 | source_hash: 9001a9cb939e0a6d9f2b67d22506c620bc9457777272fced43274b032ba35f44
178 | firewall:
179 | ports:
180 | - tcp/4505
181 | - tcp/4506
182 | - tcp/9090
183 | pushgateway:
184 | version: v1.3.0
185 | environ_file: /etc/default/prometheus-pushgateway
186 | environ:
187 | environ_arg_name: ARGS
188 | config_file: /etc/prometheus/pushgateway.yml
189 | config: {}
190 | service: {}
191 | archive:
192 | source_hash: 1ea7260a41c710a5b0f8ca1b90d18e70afdcc98ce23de61f88aba79a73d85947
193 | commands:
194 | - pushgateway
195 | firewall:
196 | ports:
197 | - tcp/4505
198 | - tcp/4506
199 | - tcp/9091
200 | statsd_exporter:
201 | version: v0.18.0
202 | archive:
203 | source_hash: d06793bd984a67e5cbead82b74e0a0f7bcd2518914ba243ab63ff8e8da532ca5
204 | commands:
205 | - statsd_exporter
206 | firewall:
207 | ports:
208 | - tcp/4505
209 | - tcp/4506
210 | - tcp/9102
211 | clientlibs:
212 | # https://prometheus.io/docs/instrumenting/clientlibs
213 | # no bash & perl client tarballs are available
214 | golang:
215 | version: v1.6.0
216 | archive:
217 | uri: https://github.com/prometheus/client_golang/archive
218 | skip_verify: true
219 | java:
220 | version: vparent-0.9.0
221 | archive:
222 | uri: https://github.com/prometheus/client_java/archive
223 | skip_verify: true
224 | python:
225 | version: v0.7.1
226 | archive:
227 | uri: https://github.com/prometheus/client_python/archive
228 | skip_verify: true
229 | ruby:
230 | version: v2.0.0
231 | archive:
232 | uri: https://github.com/prometheus/client_ruby/archive
233 | skip_verify: true
234 | c:
235 | version: v0.1.1
236 | archive:
237 | uri: https://github.com/digitalocean/prometheus-client-c/archive
238 | skip_verify: true
239 | cpp:
240 | version: v0.9.0
241 | archive:
242 | uri: https://github.com/jupp0r/prometheus-cpp/archive
243 | skip_verify: true
244 | clisp:
245 | version: v0.4.1
246 | archive:
247 | uri: https://github.com/deadtrickster/prometheus.cl/archive
248 | skip_verify: true
249 | dart:
250 | version: v0.4.0+4
251 | archive:
252 | uri: https://github.com/tentaclelabs/prometheus_client/archive
253 | skip_verify: true
254 | elixir:
255 | version: v2.0.0
256 | archive:
257 | uri: https://github.com/deadtrickster/prometheus.ex/archive
258 | skip_verify: true
259 | erlang:
260 | version: v4.4.0
261 | archive:
262 | uri: https://github.com/deadtrickster/prometheus.erl/archive
263 | skip_verify: true
264 | haskell:
265 | version: prometheus-proc-0.1.2.0
266 | archive:
267 | uri: https://github.com/fimad/prometheus-haskell/archive
268 | skip_verify: true
269 | nginx-lua:
270 | version: v0.20200420
271 | archive:
272 | uri: https://github.com/knyar/nginx-lua-prometheus/archive
273 | skip_verify: true
274 | tarantool-lua:
275 | version: v1.0.4
276 | archive:
277 | uri: https://github.com/tarantool/prometheus/archive
278 | skip_verify: true
279 | net:
280 | version: v3.5.0
281 | archive:
282 | uri: https://github.com/prometheus-net/prometheus-net/archive
283 | skip_verify: true
284 | node:
285 | version: v12.0.0
286 | archive:
287 | uri: https://github.com/siimon/prom-client/archive
288 | skip_verify: true
289 | php:
290 | version: v1.0.2
291 | archive:
292 | uri: https://github.com/endclothing/prometheus_client_php/archive
293 | skip_verify: true
294 | r:
295 | version: v1.0.1
296 | archive:
297 | uri: https://github.com/cfmack/pRometheus/archive
298 | skip_verify: true
299 | rust:
300 | version: v0.8.0
301 | archive:
302 | uri: https://github.com/tikv/rust-prometheus/archive
303 | skip_verify: true
304 |
305 | # Just here for testing
306 | added_in_defaults: defaults_value
307 | winner: defaults
308 |
309 | identity:
310 | rootuser: root
311 | rootgroup: root
312 |
313 | shell: /usr/sbin/nologin
314 |
315 | retry_option:
316 | # https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states
317 | attempts: 3
318 | until: true
319 | interval: 60
320 | splay: 10
321 | linux:
322 | altpriority: 0
323 | kernel: linux
324 |
--------------------------------------------------------------------------------
/prometheus/exporters/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- if 'exporters' in p and p.exporters and 'node_exporter' in p.exporters %}
8 |
9 | include:
10 | - .node_exporter.clean
11 |
12 | {%- endif %}
13 |
--------------------------------------------------------------------------------
/prometheus/exporters/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- if 'node_exporter' in p.wanted.component and 'exporters' in p and 'node_exporter' in p.exporters %}
8 |
9 | include:
10 | - .node_exporter
11 |
12 | {%- endif %}
13 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- if 'textfile_collectors' in p.exporters.node_exporter %}
8 | include:
9 | - .textfile_collectors.clean
10 | {%- endif %}
11 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- if 'textfile_collectors' in p.exporters.node_exporter %}
8 | include:
9 | - .textfile_collectors
10 | {%- endif %}
11 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- set name = 'node_exporter' %}
8 | {%- if name in p.wanted.component and 'service' in p.pkg.component[name] %}
9 |
10 | {%- if 'collector' in p.pkg.component[name]['service']['args'] %}
11 | prometheus-exporters-{{ name }}-collector-textfile-dir-absent:
12 | file.absent:
13 | - names:
14 | - {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
15 | - {{ p.dir.textfile_collectors }}
16 | {%- endif %}
17 |
18 | include:
19 | {%- for k, v in p.get('exporters', {}).get(name, {}).get('textfile_collectors', {}).items() %}
20 | - .{{ k }}.clean
21 | {%- endfor %}
22 | {%- endif %}
23 |
24 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/files/ipmitool:
--------------------------------------------------------------------------------
1 | #!/usr/bin/awk -f
2 |
3 | # Source: https://github.com/prometheus/node_exporter/blob/master/text_collector_examples/ipmitool
4 |
5 | #
6 | # Converts output of `ipmitool sensor` to prometheus format.
7 | #
8 | # With GNU awk:
9 | # ipmitool sensor | ./ipmitool > ipmitool.prom
10 | #
11 | # With BSD awk:
12 | # ipmitool sensor | awk -f ./ipmitool > ipmitool.prom
13 | #
14 |
15 | function export(values, name) {
16 | if (values["metric_count"] < 1) {
17 | return
18 | }
19 | delete values["metric_count"]
20 |
21 | printf("# HELP %s%s %s sensor reading from ipmitool\n", namespace, name, help[name]);
22 | printf("# TYPE %s%s gauge\n", namespace, name);
23 | for (sensor in values) {
24 | printf("%s%s{sensor=\"%s\"} %f\n", namespace, name, sensor, values[sensor]);
25 | }
26 | }
27 |
28 | # Fields are Bar separated, with space padding.
29 | BEGIN {
30 | FS = "[ ]*[|][ ]*";
31 | namespace = "node_ipmi_";
32 |
33 | # Friendly description of the type of sensor for HELP.
34 | help["temperature_celsius"] = "Temperature";
35 | help["volts"] = "Voltage";
36 | help["power_watts"] = "Power";
37 | help["speed_rpm"] = "Fan";
38 | help["status"] = "Chassis status";
39 |
40 | temperature_celsius["metric_count"] = 0;
41 | volts["metric_count"] = 0;
42 | power_watts["metric_count"] = 0;
43 | speed_rpm["metric_count"] = 0;
44 | status["metric_count"] = 0;
45 | }
46 |
47 | # Not a valid line.
48 | {
49 | if (NF < 3) {
50 | next
51 | }
52 | }
53 |
54 | # $2 is value field.
55 | $2 ~ /na/ {
56 | next
57 | }
58 |
59 | # $3 is type field.
60 | $3 ~ /degrees C/ {
61 | temperature_celsius[$1] = $2;
62 | temperature_celsius["metric_count"]++;
63 | }
64 |
65 | $3 ~ /Volts/ {
66 | volts[$1] = $2;
67 | volts["metric_count"]++;
68 | }
69 |
70 | $3 ~ /Watts/ {
71 | power_watts[$1] = $2;
72 | power_watts["metric_count"]++;
73 | }
74 |
75 | $3 ~ /RPM/ {
76 | speed_rpm[$1] = $2;
77 | speed_rpm["metric_count"]++;
78 | }
79 |
80 | $3 ~ /discrete/ {
81 | status[$1] = $2;
82 | status["metric_count"]++;
83 | }
84 |
85 | END {
86 | export(temperature_celsius, "temperature_celsius");
87 | export(volts, "volts");
88 | export(power_watts, "power_watts");
89 | export(speed_rpm, "speed_rpm");
90 | export(status, "status");
91 | }
92 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/files/smartmon.sh.jinja:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Script informed by the collectd monitoring script for smartmontools (using smartctl)
3 | # by Samuel B. (c) 2012
4 | # source at: http://devel.dob.sk/collectd-scripts/
5 |
6 | # TODO: This probably needs to be a little more complex. The raw numbers can have more
7 | # data in them than you'd think.
8 | # http://arstechnica.com/civis/viewtopic.php?p=22062211
9 |
10 | # Formatting done via shfmt -i 2
11 | # https://github.com/mvdan/sh
12 |
13 | parse_smartctl_attributes_awk="$(
14 | cat <<'SMARTCTLAWK'
15 | $1 ~ /^ *[0-9]+$/ && $2 ~ /^[a-zA-Z0-9_-]+$/ {
16 | gsub(/-/, "_");
17 | printf "%s_value{{ '{' }}%s,smart_id=\"%s\"} %d\n", $2, labels, $1, $4
18 | printf "%s_worst{{ '{' }}%s,smart_id=\"%s\"} %d\n", $2, labels, $1, $5
19 | printf "%s_threshold{{ '{' }}%s,smart_id=\"%s\"} %d\n", $2, labels, $1, $6
20 | printf "%s_raw_value{{ '{' }}%s,smart_id=\"%s\"} %e\n", $2, labels, $1, $10
21 | }
22 | SMARTCTLAWK
23 | )"
24 |
25 | smartmon_attrs="$(
26 | cat <<'SMARTMONATTRS'
27 | airflow_temperature_cel
28 | command_timeout
29 | current_pending_sector
30 | end_to_end_error
31 | erase_fail_count
32 | g_sense_error_rate
33 | hardware_ecc_recovered
34 | host_reads_mib
35 | host_reads_32mib
36 | host_writes_mib
37 | host_writes_32mib
38 | load_cycle_count
39 | media_wearout_indicator
40 | wear_leveling_count
41 | nand_writes_1gib
42 | offline_uncorrectable
43 | power_cycle_count
44 | power_on_hours
45 | program_fail_count
46 | raw_read_error_rate
47 | reallocated_event_count
48 | reallocated_sector_ct
49 | reported_uncorrect
50 | sata_downshift_count
51 | seek_error_rate
52 | spin_retry_count
53 | spin_up_time
54 | start_stop_count
55 | temperature_case
56 | temperature_celsius
57 | temperature_internal
58 | total_lbas_read
59 | total_lbas_written
60 | udma_crc_error_count
61 | unsafe_shutdown_count
62 | workld_host_reads_perc
63 | workld_media_wear_indic
64 | workload_minutes
65 | SMARTMONATTRS
66 | )"
67 | smartmon_attrs="$(echo ${smartmon_attrs} | xargs | tr ' ' '|')"
68 |
69 | parse_smartctl_attributes() {
70 | local disk="$1"
71 | local disk_type="$2"
72 | local labels="disk=\"${disk}\",type=\"${disk_type}\""
73 | local vars="$(echo "${smartmon_attrs}" | xargs | tr ' ' '|')"
74 | sed 's/^ \+//g' |
75 | awk -v labels="${labels}" "${parse_smartctl_attributes_awk}" 2>/dev/null |
76 | tr A-Z a-z |
77 | grep -E "(${smartmon_attrs})"
78 | }
79 |
80 | parse_smartctl_scsi_attributes() {
81 | local disk="$1"
82 | local disk_type="$2"
83 | local labels="disk=\"${disk}\",type=\"${disk_type}\""
84 | while read line; do
85 | attr_type="$(echo "${line}" | tr '=' ':' | cut -f1 -d: | sed 's/^ \+//g' | tr ' ' '_')"
86 | attr_value="$(echo "${line}" | tr '=' ':' | cut -f2 -d: | sed 's/^ \+//g')"
87 | case "${attr_type}" in
88 | number_of_hours_powered_up_) power_on="$(echo "${attr_value}" | awk '{ printf "%e\n", $1 }')" ;;
89 | Current_Drive_Temperature) temp_cel="$(echo ${attr_value} | cut -f1 -d' ' | awk '{ printf "%e\n", $1 }')" ;;
90 | Blocks_read_from_cache_and_sent_to_initiator_) lbas_read="$(echo ${attr_value} | awk '{ printf "%e\n", $1 }')" ;;
91 | Accumulated_start-stop_cycles) power_cycle="$(echo ${attr_value} | awk '{ printf "%e\n", $1 }')" ;;
92 | Elements_in_grown_defect_list) grown_defects="$(echo ${attr_value} | awk '{ printf "%e\n", $1 }')" ;;
93 | esac
94 | done
95 | [ ! -z "$power_on" ] && echo "power_on_hours_raw_value{${labels},smart_id=\"9\"} ${power_on}"
96 | [ ! -z "$temp_cel" ] && echo "temperature_celsius_raw_value{${labels},smart_id=\"194\"} ${temp_cel}"
97 | [ ! -z "$lbas_read" ] && echo "total_lbas_read_raw_value{${labels},smart_id=\"242\"} ${lbas_read}"
98 | [ ! -z "$power_cycle" ] && echo "power_cycle_count_raw_value{${labels},smart_id=\"12\"} ${power_cycle}"
99 | [ ! -z "$grown_defects" ] && echo "grown_defects_count_raw_value{${labels},smart_id=\"12\"} ${grown_defects}"
100 | }
101 |
102 | parse_smartctl_info() {
103 | local -i smart_available=0 smart_enabled=0 smart_healthy=0
104 | local disk="$1" disk_type="$2"
105 | local model_family='' device_model='' serial_number='' fw_version='' vendor='' product='' revision='' lun_id=''
106 | while read line; do
107 | info_type="$(echo "${line}" | cut -f1 -d: | tr ' ' '_')"
108 | info_value="$(echo "${line}" | cut -f2- -d: | sed 's/^ \+//g' | sed 's/"/\\"/')"
109 | case "${info_type}" in
110 | Model_Family) model_family="${info_value}" ;;
111 | Device_Model) device_model="${info_value}" ;;
112 | Serial_Number) serial_number="${info_value}" ;;
113 | Firmware_Version) fw_version="${info_value}" ;;
114 | Vendor) vendor="${info_value}" ;;
115 | Product) product="${info_value}" ;;
116 | Revision) revision="${info_value}" ;;
117 | Logical_Unit_id) lun_id="${info_value}" ;;
118 | esac
119 | if [[ "${info_type}" == 'SMART_support_is' ]]; then
120 | case "${info_value:0:7}" in
121 | Enabled) smart_enabled=1 ;;
122 | Availab) smart_available=1 ;;
123 | Unavail) smart_available=0 ;;
124 | esac
125 | fi
126 | if [[ "${info_type}" == 'SMART_overall-health_self-assessment_test_result' ]]; then
127 | case "${info_value:0:6}" in
128 | PASSED) smart_healthy=1 ;;
129 | esac
130 | elif [[ "${info_type}" == 'SMART_Health_Status' ]]; then
131 | case "${info_value:0:2}" in
132 | OK) smart_healthy=1 ;;
133 | esac
134 | fi
135 | done
136 | echo "device_info{\
137 | disk=\"${disk}\",\
138 | type=\"${disk_type}\",\
139 | vendor=\"${vendor}\",\
140 | product=\"${product}\",\
141 | revision=\"${revision}\",\
142 | lun_id=\"${lun_id}\",\
143 | model_family=\"${model_family}\",\
144 | device_model=\"${device_model}\",\
145 | serial_number=\"${serial_number}\",\
146 | firmware_version=\"${fw_version}\"\
147 | } 1"
148 | echo "device_smart_available{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_available}"
149 | echo "device_smart_enabled{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_enabled}"
150 | echo "device_smart_healthy{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_healthy}"
151 | }
152 |
153 | output_format_awk="$(
154 | cat <<'OUTPUTAWK'
155 | BEGIN { v = "" }
156 | v != $1 {
157 | print "# HELP smartmon_" $1 " SMART metric " $1;
158 | print "# TYPE smartmon_" $1 " gauge";
159 | v = $1
160 | }
161 | {print "smartmon_" $0}
162 | OUTPUTAWK
163 | )"
164 |
165 | format_output() {
166 | sort |
167 | awk -F'{' "${output_format_awk}"
168 | }
169 |
170 | smartctl_version="$({{ smartctl }} -V | head -n1 | awk '$1 == "smartctl" {print $2}')"
171 |
172 | echo "smartctl_version{version=\"${smartctl_version}\"} 1" | format_output
173 |
174 | if [[ "$(expr "${smartctl_version}" : '\([0-9]*\)\..*')" -lt 6 ]]; then
175 | exit
176 | fi
177 |
178 | device_list="$({{ smartctl }} --scan-open | awk '/^\/dev/{print $1 "|" $3}')"
179 |
180 | for device in ${device_list}; do
181 | disk="$(echo ${device} | cut -f1 -d'|')"
182 | type="$(echo ${device} | cut -f2 -d'|')"
183 | active=1
184 | echo "smartctl_run{disk=\"${disk}\",type=\"${type}\"}" "$(TZ=UTC date '+%s')"
185 | # Check if the device is in a low-power mode
186 | {{ smartctl }} -n standby -d "${type}" "${disk}" > /dev/null || active=0
187 | echo "device_active{disk=\"${disk}\",type=\"${type}\"}" "${active}"
188 | # Skip further metrics to prevent the disk from spinning up
189 | test ${active} -eq 0 && continue
190 | # Get the SMART information and health
191 | {{ smartctl }} -i -H -d "${type}" "${disk}" | parse_smartctl_info "${disk}" "${type}"
192 | # Get the SMART attributes
193 | case ${type} in
194 | atacam) {{ smartctl }} -A -d "${type}" "${disk}" | parse_smartctl_attributes "${disk}" "${type}" ;;
195 | sat) {{ smartctl }} -A -d "${type}" "${disk}" | parse_smartctl_attributes "${disk}" "${type}" ;;
196 | sat+megaraid*) {{ smartctl }} -A -d "${type}" "${disk}" | parse_smartctl_attributes "${disk}" "${type}" ;;
197 | scsi) {{ smartctl }} -A -d "${type}" "${disk}" | parse_smartctl_scsi_attributes "${disk}" "${type}" ;;
198 | megaraid*) {{ smartctl }} -A -d "${type}" "${disk}" | parse_smartctl_scsi_attributes "${disk}" "${type}" ;;
199 | *)
200 | echo "disk type is not sat, scsi or megaraid but ${type}"
201 | exit
202 | ;;
203 | esac
204 | done | format_output
205 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- set sls_config_users = tplroot ~ '.config.users' %}
7 |
8 | include:
9 | - {{ sls_config_users }}
10 |
11 | {%- set states = [] %}
12 | {%- set name = 'node_exporter' %}
13 | {%- if name in p.wanted.component and 'service' in p.pkg.component[name] %}
14 |
15 | {%- if 'collector' in p.pkg.component[name]['service']['args'] %}
16 | prometheus-exporters-{{ name }}-collector-textfile-dir:
17 | file.directory:
18 | - name: {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
19 | {%- if grains.os != 'Windows' %}
20 | - mode: 755
21 | - user: {{ name }}
22 | - group: {{ name }}
23 | {%- endif %}
24 | - makedirs: True
25 | - require:
26 | - user: prometheus-config-users-install-{{ name }}-user-present
27 | - group: prometheus-config-users-install-{{ name }}-group-present
28 | {%- endif %}
29 |
30 | {%- for k, v in p.get('exporters', {}).get(name, {}).get('textfile_collectors', {}).items() %}
31 | {%- if v.get('enable', False) %}
32 | {%- if v.get('remove', False) %}
33 | {%- set state = ".{}.clean".format(k) %}
34 | {%- else %}
35 | {%- set state = ".{}".format(k) %}
36 | {%- endif %}
37 | {%- do states.append(state) %}
38 | {%- endif %}
39 | {%- endfor %}
40 |
41 | {%- if states|length > 0 and p.exporters[name]['textfile_collectors_dependencies'] %}
42 | prometheus-exporters-{{ name }}-textfile-dependencies:
43 | pkg.installed:
44 | - pkgs: {{ p.exporters[name]['textfile_collectors_dependencies'] }}
45 | - require_in:
46 | {%- for state in states %}
47 | - sls: p.pkg.component[name]['config'][textfile_collectors{{ state }}
48 | {%- endfor %}
49 |
50 | include:
51 | {%- for state in states %}
52 | - {{ state }}
53 | {% endfor %}
54 | {%- endif %}
55 | {%- endif %}
56 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/ipmitool/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- set name = 'node_exporter' %}
7 |
8 | prometheus-exporters-clean-{{ name }}-textfile_collectors-ipmitool:
9 | pkg.removed:
10 | - name: {{ p.exporters[name]['textfile_collectors']['ipmitool']['pkg'] }}
11 | file.absent:
12 | - names:
13 | - {{ p.dir.archive ~ p.div ~ 'textfile_collectors' ~ p.div ~ 'ipmitool' }}
14 | - {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}{{ p.div }}ipmitool.prom
15 | cron.absent:
16 | - identifier: prometheus-exporters-{{ name }}-textfile_collectors-ipmitool-cronjob
17 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/ipmitool/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .install
6 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/ipmitool/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- set name = 'node_exporter' %}
8 | {%- set config = p.exporters[name]['textfile_collectors']['ipmitool'] %}
9 | {%- set dir = {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
10 | {%- set script = p.dir.archive ~ '/textfile_collectors/ipmitool' %}
11 | {%- set cmd_prefix = 'awk -f ' if grains.os_family in ['FreeBSD'] else '' %}
12 |
13 | prometheus-exporters-install-{{ name }}-textfile_collectors-ipmitool:
14 | pkg.installed:
15 | - name: {{ config.pkg }}
16 | file.managed:
17 | - name: {{ script }}
18 | - source: salt://prometheus/exporters-install/{{ name }}/textfile_collectors/files/ipmitool
19 | {%- if grains.os != 'Windows' %}
20 | - mode: 755
21 | {%- endif %}
22 | cron.present:
23 | - identifier: prometheus-exporters-{{ name }}-textfile_collectors-ipmitool-cronjob
24 | - name: cd {{ dir }} && LANG=C ipmitool sensor | {{ cmd_prefix }}{{ script }} > .ipmitool.prom$$; mv .ipmitool.prom$$ ipmitool.prom
25 | - minute: "{{ config.get('minute', '*') }}"
26 | - comment: Prometheus' {{ name }}'s ipmitool textfile collector
27 | - require:
28 | - file: prometheus-exporters-install-{{ name }}-textfile_collectors-ipmitool
29 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/smartmon/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- set name = 'node_exporter' %}
7 |
8 | prometheus-exporters-clean-{{ name }}-textfile_collectors-smartmon:
9 | pkg.removed:
10 | - name: {{ p.exporters[name]['textfile_collectors']['smartmon']['pkg'] }}
11 | file.absent:
12 | - names:
13 | - {{ p.dir.archive ~ p.div ~ 'textfile_collectors' ~ p.div ~ 'smartmon.sh' }}
14 | - {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}{{ p.div }}smartmon.prom
15 | cron.absent:
16 | - identifier: prometheus-exporters-{{ name }}-textfile_collectors-smartmon-cronjob
17 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/smartmon/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .install
6 |
--------------------------------------------------------------------------------
/prometheus/exporters/node_exporter/textfile_collectors/smartmon/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus with context %}
6 |
7 | {%- set name = 'node_exporter' %}
8 | {%- set config = p.exporters[name]['textfile_collectors']['smartmon'] %}
9 | {%- set dir = {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
10 | {%- set script = p.dir.archive ~ '/textfile_collectors/smartmon.sh' %}
11 |
12 | prometheus-exporters-install-{{ name }}-textfile_collectors-smartmon:
13 | pkg.installed:
14 | - names:
15 | - {{ config.pkg }}
16 | - {{ config.bash_pkg }}
17 | file.managed:
18 | - name: {{ script }}
19 | - source: salt://prometheus/exporters/{{ name }}/textfile_collectors/files/smartmon.sh.jinja
20 | - template: jinja
21 | - context:
22 | smartctl: {{ config.smartctl }}
23 | {%- if grains.os != 'Windows' %}
24 | - mode: 755
25 | {%- endif %}
26 | cron.present:
27 | - identifier: prometheus-exporters-{{ name }}-textfile_collectors-smartmon-cronjob
28 | - name: cd {{ dir }} && LANG=C {{ script }} > .smartmon.prom$$ && mv .smartmon.prom$$ smartmon.prom
29 | - minute: "{{ config.get('minute', '*') }}"
30 | - comment: Prometheus' {{ name }}'s smartmon textfile collector
31 | - require:
32 | - file: prometheus-exporters-install-{{ name }}-textfile_collectors-smartmon
33 |
--------------------------------------------------------------------------------
/prometheus/files/default/config.yml.jinja:
--------------------------------------------------------------------------------
1 | ########################################################################
2 | # File managed by Salt at <{{ source }}>.
3 | # Your changes may be overwritten.
4 | ########################################################################
5 |
6 | {{ config|yaml(False) }}
7 |
--------------------------------------------------------------------------------
/prometheus/files/default/environ.sh.jinja:
--------------------------------------------------------------------------------
1 | ########################################################################
2 | # File managed by Salt at <{{ source }}>.
3 | # Your changes may be overwritten.
4 | ########################################################################
5 | # Set the command-line arguments to pass to the server.%}"
6 | {{ arg_name }}="{{ args }}"
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/prometheus/files/default/systemd.ini.jinja:
--------------------------------------------------------------------------------
1 | #########################################################
2 | # File managed by Salt. Changes risk being overwritten.
3 | #########################################################
4 | [Unit]
5 | Description={{ desc }}
6 | Wants=network-online.target
7 | After=
8 | Documentation=https://github.com/saltstack-formulas/prometheus-formula
9 |
10 | [Service]
11 | {% for var in env %}
12 | Environment={{ var }}
13 | {% endfor %}
14 | User={{ user }}
15 | Group={{ group }}
16 | WorkingDirectory={{ workdir }}
17 | ExecStart={{ start }}
18 | ExecStop={{ stop }}
19 | PIDFile=/var/run/{{ name }}.pid
20 |
21 | [Install]
22 | WantedBy=multi-user.target
23 |
--------------------------------------------------------------------------------
/prometheus/files/macros.jinja:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=jinja
3 | #
4 | # Collection of common macros
5 |
6 | {%- macro format_kwargs(kwarg) -%}
7 |
8 | {%- filter indent(4) %}
9 | {%- for k, v in kwarg|dictsort() %}
10 | - {{ k }}: {{ v }}
11 | {%- endfor %}
12 | {%- endfilter %}
13 | {%- endmacro %}
14 |
15 | {%- macro concat_args(args) %}
16 | {%- set args = args|dictsort %}
17 | {%- if args|length > 0 %}
18 | {%- for k,v in args -%}
19 | {%- if not k or not v %}{% continue %}{% endif -%}
20 | {%- if v == True -%}
21 | --{{ k }}
22 | {%- elif v == False -%}
23 | --no-{{ k }}
24 | {%- else -%}
25 | --{{ k }}={{ v }}
26 | {%- endif -%}
27 | {%- if not loop.last %} {% endif -%}
28 | {%- endfor -%}
29 | {%- endif -%}
30 | {%- endmacro %}
31 |
--------------------------------------------------------------------------------
/prometheus/init.sls:
--------------------------------------------------------------------------------
1 | #.-*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | include:
8 | - {{ '.archive' if p.pkg.use_upstream_archive else '.package' }}
9 | - .config
10 | - .service
11 | - .exporters
12 | - .clientlibs
13 |
--------------------------------------------------------------------------------
/prometheus/libtofs.jinja:
--------------------------------------------------------------------------------
1 | {%- macro files_switch(
2 | source_files,
3 | lookup=None,
4 | default_files_switch=["id", "os_family"],
5 | indent_width=6,
6 | use_subpath=False
7 | ) %}
8 | {#-
9 | Returns a valid value for the "source" parameter of a "file.managed"
10 | state function. This makes easier the usage of the Template Override and
11 | Files Switch (TOFS) pattern.
12 | Params:
13 | * source_files: ordered list of files to look for
14 | * lookup: key under ":tofs:source_files" to prepend to the
15 | list of source files
16 | * default_files_switch: if there's no config (e.g. pillar)
17 | ":tofs:files_switch" this is the ordered list of grains to
18 | use as selector switch of the directories under
19 | "/files"
20 | * indent_width: indentation of the result value to conform to YAML
21 | * use_subpath: defaults to `False` but if set, lookup the source file
22 | recursively from the current state directory up to `tplroot`
23 | Example (based on a `tplroot` of `xxx`):
24 | If we have a state:
25 | Deploy configuration:
26 | file.managed:
27 | - name: /etc/yyy/zzz.conf
28 | - source: {{ files_switch(
29 | ["/etc/yyy/zzz.conf", "/etc/yyy/zzz.conf.jinja"],
30 | lookup="Deploy configuration",
31 | ) }}
32 | - template: jinja
33 | In a minion with id=theminion and os_family=RedHat, it's going to be
34 | rendered as:
35 | Deploy configuration:
36 | file.managed:
37 | - name: /etc/yyy/zzz.conf
38 | - source:
39 | - salt://xxx/files/theminion/etc/yyy/zzz.conf
40 | - salt://xxx/files/theminion/etc/yyy/zzz.conf.jinja
41 | - salt://xxx/files/RedHat/etc/yyy/zzz.conf
42 | - salt://xxx/files/RedHat/etc/yyy/zzz.conf.jinja
43 | - salt://xxx/files/default/etc/yyy/zzz.conf
44 | - salt://xxx/files/default/etc/yyy/zzz.conf.jinja
45 | - template: jinja
46 | #}
47 | {#- Get the `tplroot` from `tpldir` #}
48 | {%- set tplroot = tpldir.split("/")[0] %}
49 | {%- set path_prefix = salt["config.get"](tplroot ~ ":tofs:path_prefix", tplroot) %}
50 | {%- set files_dir = salt["config.get"](tplroot ~ ":tofs:dirs:files", "files") %}
51 | {%- set files_switch_list = salt["config.get"](
52 | tplroot ~ ":tofs:files_switch", default_files_switch
53 | ) %}
54 | {#- Lookup source_files (v2), files (v1), or fallback to an empty list #}
55 | {%- set src_files = salt["config.get"](
56 | tplroot ~ ":tofs:source_files:" ~ lookup,
57 | salt["config.get"](tplroot ~ ":tofs:files:" ~ lookup, []),
58 | ) %}
59 | {#- Append the default source_files #}
60 | {%- set src_files = src_files + source_files %}
61 | {#- Only add to [""] when supporting older TOFS implementations #}
62 | {%- set path_prefix_exts = [""] %}
63 | {%- if use_subpath and tplroot != tpldir %}
64 | {#- Walk directory tree to find {{ files_dir }} #}
65 | {%- set subpath_parts = tpldir.lstrip(tplroot).lstrip("/").split("/") %}
66 | {%- for path in subpath_parts %}
67 | {%- set subpath = subpath_parts[0 : loop.index] | join("/") %}
68 | {%- do path_prefix_exts.append("/" ~ subpath) %}
69 | {%- endfor %}
70 | {%- endif %}
71 | {%- for path_prefix_ext in path_prefix_exts | reverse %}
72 | {%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
73 | {#- For older TOFS implementation, use `files_switch` from the config #}
74 | {#- Use the default, new method otherwise #}
75 | {%- set fsl = salt["config.get"](
76 | tplroot ~ path_prefix_ext | replace("/", ":") ~ ":files_switch",
77 | files_switch_list,
78 | ) %}
79 | {#- Append an empty value to evaluate as `default` in the loop below #}
80 | {%- if "" not in fsl %}
81 | {%- set fsl = fsl + [""] %}
82 | {%- endif %}
83 | {%- for fs in fsl %}
84 | {%- for src_file in src_files %}
85 | {%- if fs %}
86 | {%- set fs_dirs = salt["config.get"](fs, fs) %}
87 | {%- else %}
88 | {%- set fs_dirs = salt["config.get"](
89 | tplroot ~ ":tofs:dirs:default", "default"
90 | ) %}
91 | {%- endif %}
92 | {#- Force the `config.get` lookup result as a list where necessary #}
93 | {#- since we need to also handle grains that are lists #}
94 | {%- if fs_dirs is string %}
95 | {%- set fs_dirs = [fs_dirs] %}
96 | {%- endif %}
97 | {%- for fs_dir in fs_dirs %}
98 | {#- strip empty elements by using a select #}
99 | {%- set url = (
100 | [
101 | "- salt:/",
102 | path_prefix_inc_ext.strip("/"),
103 | files_dir.strip("/"),
104 | fs_dir.strip("/"),
105 | src_file.strip("/"),
106 | ]
107 | | select
108 | | join("/")
109 | ) %}
110 | {{ url | indent(indent_width, true) }}
111 | {%- endfor %}
112 | {%- endfor %}
113 | {%- endfor %}
114 | {%- endfor %}
115 | {%- endmacro %}
116 |
--------------------------------------------------------------------------------
/prometheus/map.jinja:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=jinja
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
6 | {%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
7 | {%- import_yaml tplroot ~ "/cpuarchmap.yaml" as cpuarchmap %}
8 | {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
9 | {%- set _config = salt['config.get'](tplroot, default={}) %}
10 |
11 | {%- set defaults = salt['grains.filter_by'](
12 | default_settings,
13 | default=tplroot,
14 | merge=salt['grains.filter_by']( osfamilymap, grain='os_family',
15 | merge=salt['grains.filter_by']( osarchmap, grain='osarch',
16 | merge=salt['grains.filter_by']( cpuarchmap, grain='cpuarch',
17 | merge=salt['grains.filter_by']( _config, default='lookup'
18 | )
19 | )
20 | )
21 | )
22 | )
23 | %}
24 |
25 | {%- set p = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %}
26 |
27 | {# ## components ## #}
28 | {%- if 'component' in p.pkg and p.pkg.component is mapping %}
29 | {%- for name,v in p.pkg.component.items() %}
30 | {%- set url = None %}
31 | {%- set dir = name %}
32 | {%- if 'version' in v and v.version and 'archive' in v and v.archive and 'uri' in p.pkg %}
33 | {%- set uri = '%s/%s/releases/download/%s/%s'|format(p.pkg.uri, name, v.version, name) %}
34 | {%- set url = '%s-%s.%s-%s.tar.gz'|format(uri, v.version|replace('v',''), p.kernel, p.arch) %}
35 | {%- set dir = '%s-%s'|format(name, v.version) %}
36 | {%- do p.pkg.component[name].update({'path': p.dir.archive ~ '/' + dir }) %}
37 | {% if p.pkg.component[name]['archive'].get('official', true) %}
38 | {%- do p.pkg.component[name]['archive'].update({'name': p.dir.archive + '/' + dir, 'source': url}) %}
39 | {% else %}
40 | {%- do p.pkg.component[name]['archive'].update({'name': p.dir.archive + '/' + dir }) %}
41 | {% endif %}
42 | {%- endif %}
43 | {%- endfor %}
44 | {%- endif %}
45 |
46 | {# ## clientlibs ## #}
47 | {%- if 'clientlibs' in p.pkg and p.pkg.clientlibs is mapping %}
48 | {%- for name,v in p.pkg.clientlibs.items() %}
49 | {%- set url = None %}
50 | {%- set dir = name %}
51 | {%- if 'version' in v and v.version and 'archive' in v and v.archive and 'uri' in v.archive %}
52 | {%- set url = v.archive.uri ~ '/' ~ v.version ~ '.tar.gz' %}
53 | {%- set dir = name ~ '-' ~ v.version %}
54 | {%- endif %}
55 | {%- do p.pkg.clientlibs[name].update({'path': p.dir.archive ~ '/' + dir }) %}
56 | {%- do p.pkg.clientlibs[name]['archive'].update({'name': p.dir.archive + '/' + dir, 'source': url}) %}
57 | {%- endfor %}
58 | {%- endif %}
59 |
60 | {%- set prometheus = p %}
61 |
--------------------------------------------------------------------------------
/prometheus/osarchmap.yaml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | #
4 | # Setup variables using grains['osarch'] based logic.
5 | # You just need to add the key:values for an `osarch` that differ
6 | # from `defaults.yaml` + `os_family.yaml`.
7 | # Only add an `osarch` which is/will be supported by the formula
8 | #
9 | # If you do not need to provide defaults via the `osarch` grain,
10 | # you will need to provide at least an empty dict in this file, e.g.
11 | # osarch: {}
12 | ---
13 | amd64:
14 | arch: amd64
15 |
16 | x86_64:
17 | arch: amd64
18 |
19 | 386:
20 | arch: 386
21 |
22 | arm64:
23 | arch: arm64
24 |
25 | armv6l:
26 | arch: armv6l
27 |
28 | armv7l:
29 | arch: armv6l
30 |
31 | ppc64le:
32 | arch: ppc64le
33 |
34 | s390x:
35 | arch: s390x
36 |
--------------------------------------------------------------------------------
/prometheus/osfamilymap.yaml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | #
4 | # Setup variables using grains['os_family'] based logic.
5 | # You just need to add the key:values for an `os_family` that differ
6 | # from `defaults.yaml`.
7 | # Only add an `os_family` which is/will be supported by the formula
8 | #
9 | # If you do not need to provide defaults via the `os_family` grain,
10 | # you will need to provide at least an empty dict in this file, e.g.
11 | # osfamilymap: {}
12 | ---
13 | {%- if grains.os == 'MacOS' %}
14 | {%- set macos_rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %}
15 | {%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
16 | {%- endif %}
17 |
18 | Arch:
19 | pkg:
20 | component:
21 | alertmanager:
22 | name: alertmanager
23 | blackbox_exporter:
24 | name: prometheus-blackbox-exporter
25 | prometheus:
26 | environ_file: /etc/conf.d/prometheus
27 | environ:
28 | environ_arg_name: PROMETHEUS_ARGS
29 | node_exporter:
30 | name: prometheus-node-exporter
31 | environ_file: /etc/conf.d/prometheus-node-exporter
32 | environ:
33 | environ_arg_name: NODE_EXPORTER_ARGS
34 |
35 | Alpine: {}
36 |
37 | Debian:
38 | dir:
39 | service: /lib/systemd/system
40 | pkg:
41 | deps:
42 | - cron
43 | use_upstream_repo: false
44 | use_upstream_package: false
45 | use_upstream_archive: false
46 | component:
47 | alertmanager:
48 | name: prometheus-alertmanager
49 | service:
50 | name: prometheus-alertmanager
51 | args_file: /etc/default/prometheus-alertmanager
52 | apache_exporter:
53 | name: prometheus-apache-exporter
54 | service:
55 | name: prometheus-apache-exporter
56 | args_file: /etc/default/prometheus-apache-exporter
57 | bind_exporter:
58 | name: prometheus-bind-exporter
59 | args_file: /etc/default/prometheus-bind-exporter
60 | bird_exporter:
61 | name: prometheus-bird-exporter
62 | args_file: /etc/default/prometheus-bird-exporter
63 | prometheus:
64 | name: prometheus
65 | blackbox_exporter:
66 | name: prometheus-blackbox-exporter
67 | config_file: /etc/prometheus/blackbox.yml
68 | environ_file: /etc/default/prometheus-blackbox-exporter
69 | environ:
70 | environ_arg_name: ARGS
71 | service:
72 | name: prometheus-blackbox-exporter
73 | consul_exporter:
74 | name: prometheus-consul-exporter
75 | graphite_exporter:
76 | name: prometheus-graphite-exporter
77 | hacluster_exporter:
78 | name: prometheus-hacluster-exporter
79 | args_file: /etc/default/prometheus-hacluster-exporter
80 | haproxy_exporter:
81 | name: prometheus-haproxy-exporter
82 | args_file: /etc/default/prometheus-haproxy-exporter
83 | homeplug_exporter:
84 | name: prometheus-homeplug-exporter
85 | args_file: /etc/default/prometheus-homeplug-exporter
86 | ipmi_exporter:
87 | name: prometheus-ipmi-exporter
88 | args_file: /etc/default/prometheus-ipmi-exporter
89 | libvirt_exporter:
90 | name: prometheus-libvirt-exporter
91 | args_file: /etc/default/prometheus-libvirt-exporter
92 | mailexporter:
93 | name: prometheus-mailexporter
94 | args_file: /etc/default/prometheus-mailexporter
95 | memcached_exporter:
96 | name: prometheus-memcached-exporter
97 | mongodb_exporter:
98 | name: prometheus-mongodb-exporter
99 | args_file: /etc/default/prometheus-mongodb-exporter
100 | mysqld_exporter:
101 | name: prometheus-mysqld-exporter
102 | service:
103 | name: prometheus-mysqld-exporter
104 | args_file: /etc/default/prometheus-mysqld-exporter
105 | nginx_exporter:
106 | name: prometheus-nginx-exporter
107 | service:
108 | name: prometheus-nginx-exporter
109 | args_file: /etc/default/prometheus-nginx-exporter
110 | nginx_vts_exporter:
111 | name: prometheus-nginx-vts-exporter
112 | args_file: /etc/default/prometheus-nginx-vts-export
113 | node_exporter:
114 | name: prometheus-node-exporter
115 | service:
116 | name: prometheus-node-exporter
117 | args_file: /etc/default/prometheus-node-exporter
118 | node_exporter_collectors:
119 | name: prometheus-node-exporter-collectors
120 | args_file: /etc/default/prometheus-node-exporter-collectors
121 | openstack_exporter:
122 | name: prometheus-openstack-exporter
123 | args_file: /etc/default/prometheus-openstack-exporter
124 | pgbouncer_exporter:
125 | name: prometheus-pgbouncer-exporter
126 | args_file: /etc/default/prometheus-pgbouncer-exporter
127 | postfix_exporter:
128 | name: prometheus-postfix-exporter
129 | args_file: /etc/default/prometheus-postfix-exporter
130 | postgres_exporter:
131 | name: prometheus-postgres-exporter
132 | service:
133 | name: prometheus-postgres-exporter
134 | args_file: /etc/default/prometheus-postgres-exporter
135 | process_exporter:
136 | name: prometheus-process-exporter
137 | args_file: /etc/default/prometheus-process-exporter
138 | pushgateway:
139 | name: prometheus-pushgateway
140 | service:
141 | name: prometheus-pushgateway
142 | args_file: /etc/default/prometheus-pushgateway
143 | statsd_exporter:
144 | name: prometheus-statsd-exporter
145 | snmp_exporter:
146 | name: prometheus-snmp-exporter
147 | args_file: /etc/default/prometheus-snmp-exporter
148 | sql_exporter:
149 | name: prometheus-sql-exporter
150 | args_file: /etc/default/prometheus-sql-exporter
151 | squid_exporter:
152 | name: prometheus-squid-exporter
153 | args_file: /etc/default/prometheus-squid
154 | tplink_plug_exporter:
155 | name: prometheus-tplink-plug-exporter
156 | args_file: /etc/default/prometheus-tplink-plug-exporter
157 | trafficserver_exporter:
158 | name: prometheus-trafficserver-exporter
159 | args_file: /etc/default/prometheus-trafficserver-exporter
160 | varnish_exporter:
161 | name: prometheus-varnish-exporter
162 | args_file: /etc/default/prometheus-varnish-exporter
163 | xmpp_alerts:
164 | name: prometheus-xmpp-alerts
165 | args_file: /etc/default/prometheus-xmpp-alerts
166 |
167 | exporters:
168 | node_exporter:
169 | textfile_collectors_dependencies:
170 | - cron
171 |
172 | RedHat:
173 | pkg:
174 | use_upstream_repo: false # not working on cent8
175 | use_upstream_archive: false
176 | component:
177 | prometheus:
178 | name: prometheus2
179 | environ_file: /etc/default/prometheus
180 | environ:
181 | environ_arg_name: PROMETHEUS_OPTS
182 | args:
183 | config.file: /etc/prometheus/prometheus.yml
184 | storage.tsdb.path: /var/lib/prometheus/data
185 | web.console.libraries: /usr/share/prometheus/console_libraries
186 | web.console.templates: /usr/share/prometheus/consoles
187 | alertmanager:
188 | environ_file: /etc/default/alertmanager
189 | environ:
190 | environ_arg_name: ALERTMANAGER_OPTS
191 | args:
192 | config.file: /etc/prometheus/alertmanager.yml
193 | storage.path: /var/lib/prometheus/alertmanager
194 | node_exporter:
195 | environ_file: /etc/default/node_exporter
196 | environ:
197 | environ_arg_name: NODE_EXPORTER_OPTS
198 | pushgateway:
199 | environ_file: /etc/default/pushgateway
200 | environ:
201 | environ_arg_name: PUSHGATEWAY_OPTS
202 | blackbox_exporter:
203 | environ_file: /etc/default/blackbox_exporter
204 | environ:
205 | environ_arg_name: BLACKBOX_EXPORTER_OPTS
206 | args:
207 | config.file: /etc/prometheus/blackbox.yml
208 | repo:
209 | {%- if grains.os == 'Amazon' %}
210 | {%- set releasever = salt['cmd.run']("rpm -E '%{rhel}'") %}
211 | {% else %}
212 | {%- set releasever = "$releasever" %}
213 | {%- endif %}
214 | # yamllint disable rule:line-length
215 | baseurl: "https://packagecloud.io/prometheus-rpm/release/el/{{ releasever }}/$basearch"
216 | gpgkey: 'https://packagecloud.io/prometheus-rpm/release/gpgkey https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm'
217 | # yamllint enable rule:line-length
218 | sslverify: 1
219 | sslcacert: /etc/pki/tls/certs/ca-bundle.crt
220 | metadata_expire: 300
221 |
222 | Suse: {}
223 |
224 | Gentoo:
225 | pkg:
226 | use_upstream_repo: false
227 | use_upstream_archive: false
228 | component:
229 | alertmanager:
230 | name: app-metrics/alertmanager
231 | args_file: /etc/conf.d/alertmanager
232 | prometheus:
233 | name: app-metrics/prometheus
234 | args_file: /etc/conf.d/prometheus
235 | node_exporter:
236 | name: app-metrics/node_exporter
237 | args_file: /etc/conf.d/node_exporter
238 | bind_exporter:
239 | name: app-metrics/bind_exporter
240 | blackbox_exporter:
241 | name: app-metrics/blackbox_exporter
242 | burrow_exporter:
243 | name: app-metrics/burrow_exporter
244 | consul_exporter:
245 | name: app-metrics/consul_exporter
246 | dnsmasq_exporter:
247 | name: app-metrics/dnsmasq_exporter
248 | elasticsearch_exporter:
249 | name: app-metrics/elasticsearch_exporter
250 | github_exporter:
251 | name: app-metrics/github-exporter
252 | grok_exporter:
253 | name: app-metrics/grok_exporter
254 | memcached_exporter:
255 | name: app-metrics/memcached_exporter
256 | mongodb_exporter:
257 | name: app-metrics/mongodb_exporter
258 | mysqld_exporter:
259 | name: app-metrics/mysqld_exporter
260 | nginx_vts_exporter:
261 | name: app-metrics/nginx-vts-exporter
262 | openvpn_exporter:
263 | name: app-metrics/openvpn_exporter
264 | postfix_exporter:
265 | name: app-metrics/postfix_exporter
266 | postgres_exporter:
267 | name: app-metrics/postgres_exporter
268 | process_exporter:
269 | name: app-metrics/process-exporter
270 | rabbitmq_exporter:
271 | name: app-metrics/rabbitmq_exporter
272 | redis_exporter:
273 | name: app-metrics/redis_exporter
274 | snmp_exporter:
275 | name: app-metrics/snmp_exporter
276 | uwsgi_exporter:
277 | name: app-metrics/uwsgi_exporter
278 | vault_exporter:
279 | name: app-metrics/vault_exporter
280 |
281 | FreeBSD:
282 | identity:
283 | rootgroup: wheel
284 | dir:
285 | etc: /usr/local/etc/prometheus
286 | pkg:
287 | component:
288 | prometheus:
289 | archive:
290 | source_hash: 94a63f14baeadab2f17b5ae0bbeda6688e6d06f964ef4e32c2954a0ecf3996a1
291 | alertmanager:
292 | archive:
293 | source_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569
294 | blackbox_exporter:
295 | archive:
296 | source_hash: 2b92752decf2cf1883ce4f72301e4f911dab79efbd87db4df23dc9771e53e4af
297 | consul_exporter:
298 | archive:
299 | source_hash: 62e16c2f1acb9bf9411126478caccb5962da203cfb58d8c97f54b9c0add5171c
300 | graphite_exporter:
301 | archive:
302 | source_hash: ff424b923733d8247314353ba4d13a1c4b06450c35f005bfd6c3b6ff60b047fd
303 | haproxy_exporter:
304 | archive:
305 | source_hash: f32d158f9e3314828dc155a30a1f4c858876e1ea8ff543a4000afcbc7e923505
306 | memcached_exporter:
307 | archive:
308 | source_hash: 8fd53b9aede6b78e0530b159ccd0a437cf2f100da1ddc586681f389d804f5f19
309 | mysqld_exporter:
310 | archive:
311 | source_hash: 9bcbbd8b3568818fd4c95d255c6f93c357ea25aed3364d7428f4ff9c89cd489a
312 | node_exporter: {}
313 | pushgateway:
314 | archive:
315 | source_hash: ebcd21dc25e439eed64559e89cd7da9a94073d5ff321a8a3a4214ac2ebe04e34
316 | statsd_exporter:
317 | archive:
318 | source_hash: f345dff6311501f09bb5b6ba1128e925d504c6325ee97ad91a975f2be0d44da9
319 | exporters:
320 | node_exporter:
321 | textfile_collectors:
322 | smartmon:
323 | smartctl: /usr/local/sbin/smartctl
324 |
325 | OpenBSD:
326 | identity:
327 | rootgroup: wheel
328 | kernel: openbsd
329 | pkg:
330 | component:
331 | prometheus:
332 | archive:
333 | source_hash: c3c69919b359f00a84ef12f7ed6a956111790d64a71bd94990572baaf63377ce
334 | alertmanager:
335 | archive:
336 | source_hash: 88ce1b3f11bb28f24b98235994277b2c31aa03b2b2609e0058c04efa0cc5596f
337 | blackbox_exporter:
338 | archive:
339 | source_hash: 0dee97d1204bac925bde919958ae890730d87386a816ed0b248c8038ee43794d
340 | consul_exporter:
341 | archive:
342 | source_hash: b53ee2bd0e670907eac894387e286b0dd11eb3149fcd4e19ed586006d3de741a
343 | graphite_exporter:
344 | archive:
345 | source_hash: 98cbd7176f1c61023892de64ad26edc3cd7895037e3cc282c4edec53dded7156
346 | haproxy_exporter:
347 | archive:
348 | source_hash: bc2b222f6a08232ef643cd6dcda3264f3bd7388a5bee25365cef137c7dea17e8
349 | memcached_exporter:
350 | archive:
351 | source_hash: 21db1bffc561d47b4490ccb2cde721244d00e95f504cdcfee618bc4bb877e731
352 | mysqld_exporter:
353 | archive:
354 | source_hash: b37d6fe68e2c884540ea41c5efcfb16d0bc5da517fe3ba713144504df1ba635d
355 | pushgateway:
356 | archive:
357 | source_hash: 0bce168e4b19234df9e954393a2102c91e4d62336b2721ed882f2003a4445d51
358 | statsd_exporter:
359 | archive:
360 | source_hash: c89acb365b75af03ce612873d8b20226e3882c0177752ea0ce17a9f5e41eb5b4
361 |
362 | Solaris: {}
363 |
364 | Windows:
365 | div: '\\'
366 | kernel: windows
367 | dir:
368 | archive: C:\\prometheus
369 | etc: C:\\prometheus\\etc
370 | tmp: C:\\temp\\prometheus-salt-tmp
371 | var: C:\\prometheus\var
372 |
373 | pkg:
374 | component:
375 | prometheus:
376 | archive:
377 | source_hash: eb138082a4d5e4d5b1e3ca838fa508f053474d46bca76e87ab0834f0d8b110db
378 | alertmanager:
379 | archive:
380 | source_hash: 512dbed02a3cc7e3f06d737f56179e458c462762b3427063b89c62a54d9645c6
381 | blackbox_exporter:
382 | archive:
383 | source_hash: 21ea148870631310002cbd48be54ca45e8d300da5a902b0aec052f1a64316d93
384 | consul_exporter:
385 | archive:
386 | source_hash: 54579bc5dfa6a238e310a1874b0a362027661dfa1754535e74610dc8ef6163b1
387 | graphite_exporter:
388 | archive:
389 | source_hash: f83fad71bad99ccac145d65f82bf9d17fa37168a5dcce6415c6350e79a84e638
390 | haproxy_exporter:
391 | archive:
392 | source_hash: 044118feb98b74eb921e27bd4b511732b553896c672c19bdd3418445dc030794
393 | memcached_exporter:
394 | archive:
395 | source_hash: 9e83c00c9d249c942f65b6a48112e6bd6e28a3d15b8a1d35e935621657b3d837
396 | mysqld_exporter:
397 | archive:
398 | source_hash: 38605ae648f8def07a0f412d81a30a6c48c0d20a6981468d25b91c8aa529e599
399 | pushgateway:
400 | archive:
401 | source_hash: 506b555e7a13cabf3d85ec0dbe1bc6bc3a2444c0cc468baa8d31e7fc2fe18dd1
402 | statsd_exporter:
403 | archive:
404 | source_hash: 9362b7482e74792f111c4bb1a372b18a88f6354c78f24713bacfbcb050883556
405 |
406 | MacOS:
407 | div: '/'
408 | shell: /sbin/nologin
409 | dir:
410 | default: /etc/defaults
411 | identity:
412 | rootuser: {{ macos_rootuser | d('') }}
413 | rootgroup: {{ macos_rootgroup | d('') }}
414 | kernel: darwin
415 | pkg:
416 | component:
417 | prometheus:
418 | archive:
419 | source_hash: 740e36bcacc0c5d4495f5341fcfa8b7e0dc623d12e8b07ac291052ea0a681325
420 | alertmanager:
421 | archive:
422 | source_hash: efeebaa8e51c521ecb3440345fb65962533cae022d71dff8b127911e893ded2a
423 | blackbox_exporter:
424 | archive:
425 | source_hash: a371d0496adb5d62368d6606928c5effd318d1387f6b9a9998f8d0333492645a
426 | consul_exporter:
427 | archive:
428 | source_hash: 75641783938967c11c18d6d340028ff2dce7ad0ae5e300fa631b813cc6ea9647
429 | graphite_exporter:
430 | archive:
431 | source_hash: f9c0aa745502c0ab01fdcca29181801810202e0aed512a9aa9a37bb4be88a919
432 | haproxy_exporter:
433 | archive:
434 | source_hash: 8fdb8bb182586c57e5892816a02846bae0998916765d22bb81b2c444a3565862
435 | memcached_exporter:
436 | archive:
437 | source_hash: e10685cca5ffd8a3a7574b3dc096dc7418f34906abd399f881be06dd38be62cb
438 | mysqld_exporter:
439 | archive:
440 | source_hash: 8e0a7d8847790d6dcdcf392e6dd227458a7bcaa1e0890cc6326fdf956421f2a7
441 | node_exporter:
442 | archive:
443 | source_hash: 20fadb3108de0a9cc70a1333394e5be90416b4f91025f9fc66f5736335e94398
444 | pushgateway:
445 | archive:
446 | source_hash: 25399a4c6600c1931f9d9bd5294700c2b53f964188b1c6003f9d12a2e176aac1
447 | statsd_exporter:
448 | archive:
449 | source_hash: 15132494523c2b6a89e09b2da63452c8fe587fb82fcc3fd21cc75a4aa2766644
450 |
--------------------------------------------------------------------------------
/prometheus/package/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- set sls_config_clean = tplroot ~ '.config.clean' %}
8 | {%- set sls_service_clean = tplroot ~ '.service.clean' %}
9 | {%- set sls_repo_clean = tplroot ~ '.package.repo.clean' %}
10 |
11 | include:
12 | - {{ sls_config_clean }}
13 | - {{ sls_service_clean }}
14 | - {{ sls_repo_clean }}
15 |
16 | {%- for name in p.wanted.component %}
17 |
18 | prometheus-package-clean-{{ name }}-removed:
19 | pkg.removed:
20 | - name: {{ p.pkg.component[name].get('name', name) }}
21 | - require:
22 | - sls: {{ sls_config_clean }}
23 | - sls: {{ sls_service_clean }}
24 | - sls: {{ sls_repo_clean }}
25 |
26 | {%- endfor %}
27 |
--------------------------------------------------------------------------------
/prometheus/package/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .install
6 |
--------------------------------------------------------------------------------
/prometheus/package/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- set sls_service_running = tplroot ~ '.service.running' %}
8 | {%- set sls_repo_install = tplroot ~ '.package.repo.install' %}
9 |
10 | include:
11 | - {{ sls_service_running }}
12 | - {{ sls_repo_install }}
13 |
14 | {%- for name in p.wanted.component %}
15 |
16 | prometheus-package-install-{{ name }}-installed:
17 | pkg.installed:
18 | - name: {{ p.pkg.component[name].get('name', name) }}
19 | - require:
20 | - sls: {{ sls_repo_install }}
21 | - require_in:
22 | - sls: {{ sls_service_running }}
23 | - reload_modules: true
24 |
25 | {%- endfor %}
26 |
--------------------------------------------------------------------------------
/prometheus/package/repo/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- if grains.os_family|lower == 'redhat' %}
5 | {%- set tplroot = tpldir.split('/')[0] %}
6 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
7 |
8 | {%- if p.pkg.use_upstream_repo and 'repo' in p.pkg and p.pkg.repo %}
9 |
10 | prometheus-package-repo-clean-pkgrepo-managed:
11 | pkgrepo.absent:
12 | - name: {{ p.pkg['repo']['name'] }}
13 |
14 | {%- endif %}
15 | {%- endif %}
16 |
--------------------------------------------------------------------------------
/prometheus/package/repo/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .install
6 |
--------------------------------------------------------------------------------
/prometheus/package/repo/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- if grains.os_family == 'RedHat' %}
5 | {%- set tplroot = tpldir.split('/')[0] %}
6 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
7 |
8 | {%- if p.pkg.use_upstream_repo and 'repo' in p.pkg and p.pkg.repo %}
9 | {%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
10 |
11 | prometheus-package-repo-install-pkgrepo-managed:
12 | pkgrepo.managed:
13 | {{- format_kwargs(p.pkg.repo) }}
14 |
15 | {%- endif %}
16 | {%- else %}
17 |
18 | prometheus-package-repo-install-pkgrepo-managed:
19 | test.show_notification:
20 | - name: Skipping repository configuration
21 | - text: |
22 | At the moment, there's no repo for {{ grains['os'] }}
23 | See https://prometheus.io/download/
24 |
25 | {%- endif %}
26 |
--------------------------------------------------------------------------------
/prometheus/service/args/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
7 |
8 | {%- if grains.os_family in ('FreeBSD',) %}
9 | {%- set sls_service_clean = tplroot ~ '.service.clean' %}
10 |
11 | include:
12 | - {{ sls_service_clean }}
13 |
14 | {%- for name in p.wanted.component %}
15 | {%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
16 |
17 | prometheus-service-args-clean-{{ name }}:
18 | file.absent:
19 | - names:
20 | - /tmp/dummy-{{ name }}-dummy
21 | {%- if 'storage.tsdb.path' in p.pkg.component[name]['service']['args'] %}
22 | - {{ p.pkg.component[name]['service']['args']['storage.tsdb.path'] }}
23 | {%- endif %}
24 | - require:
25 | - sls: {{ sls_service_clean }}
26 |
27 | {%- if grains.os_family == 'FreeBSD' %}
28 | sysrc.absent:
29 | - names:
30 | - {{ name }}_args
31 | - {{ name }}_listen_address
32 | - {{ name }}_textfile_dir
33 | - {{ name }}_data_dir
34 | - {{ name }}_config
35 | - require:
36 | - sls: {{ sls_service_clean }}
37 | {%- endif %}
38 |
39 | {%- endif %}
40 | {%- endfor %}
41 | {%- endif %}
42 |
--------------------------------------------------------------------------------
/prometheus/service/args/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .install
6 |
--------------------------------------------------------------------------------
/prometheus/service/args/install.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
7 |
8 | {%- if grains.os_family in ('FreeBSD',) %}
9 | {%- set sls_config_users = tplroot ~ '.config.users' %}
10 | {%- set sls_service_running = tplroot ~ '.service.running' %}
11 | {%- set sls_archive_install = tplroot ~ '.archive.install' %}
12 | {%- set sls_package_install = tplroot ~ '.package.install' %}
13 |
14 |
15 | include:
16 | - {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
17 | - {{ sls_config_users }}
18 | - {{ sls_service_running }}
19 |
20 | {%- for name in p.wanted.component %}
21 | {%- if 'service' in p.pkg.component[name] and 'args' in p.pkg.component[name]['service'] %}
22 | {%- set args = p.pkg.component[name]['service']['args'] %}
23 | {%- if 'storage.tsdb.path' in args.keys() %}
24 |
25 | prometheus-service-args-{{ name }}-data-dir:
26 | file.directory:
27 | - name: {{ args['storage.tsdb.path'] }}
28 | - user: {{ name }}
29 | - group: {{ name }}
30 | - makedirs: True
31 | - watch_in:
32 | - service: prometheus-service-running-{{ name }}
33 | - require:
34 | - user: prometheus-config-users-install-{{ name }}-user-present
35 | - group: prometheus-config-users-install-{{ name }}-group-present
36 |
37 | {%- endif %}
38 | {%- if grains.os_family == 'FreeBSD' %}
39 | {%- if 'collector.textfile.directory' in args.keys() %}
40 |
41 | prometheus-service-args-{{ name }}-collector-textfile-directory:
42 | sysrc.managed:
43 | - name: {{ name }}_textfile_dir
44 | - value: {{ args.pop('collector.textfile.directory') }}
45 | - watch_in:
46 | - service: prometheus-service-running-{{ name }}
47 |
48 | {%- endif %}
49 | {%- if 'storage.tsdb.path' in args.keys() %}
50 |
51 | prometheus-service-args-{{ name }}-storage-tsdb-path:
52 | sysrc.managed:
53 | - name: {{ name }}_data_dir
54 | - value: {{ args.pop('storage.tsdb.path') }}
55 | - watch_in:
56 | - service: prometheus-service-running-{{ name }}
57 |
58 | {%- endif %}
59 | {%- if 'web.listen-address' in args.keys() %}
60 |
61 | prometheus-service-args-{{ name }}-web-listen-address:
62 | sysrc.managed:
63 | - name: {{ name }}_listen_address
64 | - value: {{ args.pop('web.listen-address') }}
65 | - watch_in:
66 | - service: prometheus-service-running-{{ name }}
67 |
68 | {%- endif %}
69 |
70 | prometheus-service-args-{{ name }}-install:
71 | sysrc.managed:
72 | - name: {{ name }}_config
73 | - value: {{ p.dir.etc }}/{{ name }}.yml
74 | - watch_in:
75 | - service: prometheus-service-running-{{ name }}
76 |
77 | {%- endif %}
78 | {%- endif %}
79 | {%- endfor %}
80 | {%- endif %}
81 |
--------------------------------------------------------------------------------
/prometheus/service/clean.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 |
7 | {%- for name in p.wanted.component %}
8 | {%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
9 | {%- set service_name = p.pkg.component[name]['service']['get'](name, {}).get('name', name) %}
10 |
11 | prometheus-service-clean-{{ name }}:
12 | service.dead:
13 | - name: {{ service_name }}
14 | - enable: False
15 | {%- if grains.kernel|lower == 'linux' %}
16 | - onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
17 | {%- endif %}
18 | file.absent:
19 | - name: {{ p.dir.service }}{{ p.div }}{{ name }}.service
20 | - require:
21 | - service: prometheus-service-clean-{{ name }}
22 | cmd.run:
23 | - onlyif: {{ grains.kernel|lower == 'linux' }}
24 | - name: systemctl daemon-reload
25 | - require:
26 | - file: prometheus-service-clean-{{ name }}
27 |
28 | {%- if grains.os_family == 'FreeBSD' %}
29 | sysrc.absent:
30 | - name: {{ name }}_environ
31 | - require:
32 | - service: prometheus-service-clean-{{ name }}
33 |
34 | {%- endif %}
35 | {%- endif %}
36 | {%- endfor %}
37 |
--------------------------------------------------------------------------------
/prometheus/service/init.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | include:
5 | - .args
6 | - .running
7 |
--------------------------------------------------------------------------------
/prometheus/service/running.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=sls
3 |
4 | {%- set tplroot = tpldir.split('/')[0] %}
5 | {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
6 | {%- set sls_config_file = tplroot ~ '.config.file' %}
7 | {%- set sls_config_environ = tplroot ~ '.config.environ' %}
8 |
9 | include:
10 | - {{ sls_config_file }}
11 | - {{ sls_config_environ }}
12 |
13 | {%- for name in p.wanted.component %}
14 | {%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
15 | {%- set service_name = p.pkg.component[name]['service'].get('name', name) %}
16 |
17 | {%- if grains.kernel|lower == 'linux' %}
18 | prometheus-service-running-{{ name }}-unmasked:
19 | service.unmasked:
20 | - name: {{ service_name }}
21 | - onlyif: systemctl list-unit-files | grep {{ service_name }} >/dev/null 2>&1
22 | - require_in:
23 | - service: prometheus-service-running-{{ name }}
24 | - require:
25 | - sls: {{ sls_config_file }}
26 | - file: prometheus-config-file-etc-file-directory
27 | {%- if p.wanted.firewall %}
28 | pkg.installed:
29 | - name: firewalld
30 | - reload_modules: true
31 | {%- endif %}
32 | {%- endif %}
33 |
34 | prometheus-service-running-{{ name }}:
35 | service.running:
36 | - enable: True
37 | - require:
38 | - sls: {{ sls_config_file }}
39 | {%- if grains.kernel|lower == 'linux' %}
40 | - onlyif: systemctl list-unit-files | grep {{ service_name }} >/dev/null 2>&1
41 | - names:
42 | - {{ service_name }}
43 | {%- if p.wanted.firewall %}
44 | - firewalld
45 | firewalld.present:
46 | - name: public
47 | - ports: {{ p.pkg.component[name]['firewall']['ports']|json }}
48 | - require:
49 | - service: prometheus-service-running-{{ name }}
50 | {%- endif %}
51 | {%- endif %}
52 | {%- endif %}
53 | {%- endfor %}
54 |
--------------------------------------------------------------------------------
/release-rules.js:
--------------------------------------------------------------------------------
1 | // No release is triggered for the types commented out below.
2 | // Commits using these types will be incorporated into the next release.
3 | //
4 | // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
5 | module.exports = [
6 | {breaking: true, release: 'major'},
7 | // {type: 'build', release: 'patch'},
8 | // {type: 'chore', release: 'patch'},
9 | // {type: 'ci', release: 'patch'},
10 | {type: 'docs', release: 'patch'},
11 | {type: 'feat', release: 'minor'},
12 | {type: 'fix', release: 'patch'},
13 | {type: 'perf', release: 'patch'},
14 | {type: 'refactor', release: 'patch'},
15 | {type: 'revert', release: 'patch'},
16 | {type: 'style', release: 'patch'},
17 | {type: 'test', release: 'patch'},
18 | ];
19 |
--------------------------------------------------------------------------------
/release.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | branch: 'master',
3 | repositoryUrl: 'https://github.com/saltstack-formulas/prometheus-formula',
4 | plugins: [
5 | ['@semantic-release/commit-analyzer', {
6 | preset: 'angular',
7 | releaseRules: './release-rules.js',
8 | }],
9 | '@semantic-release/release-notes-generator',
10 | ['@semantic-release/changelog', {
11 | changelogFile: 'CHANGELOG.md',
12 | changelogTitle: '# Changelog',
13 | }],
14 | ['@semantic-release/exec', {
15 | prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}',
16 | }],
17 | ['@semantic-release/git', {
18 | assets: ['*.md', 'docs/*.rst', 'FORMULA'],
19 | }],
20 | '@semantic-release/github',
21 | ],
22 | generateNotes: {
23 | preset: 'angular',
24 | writerOpts: {
25 | // Required due to upstream bug preventing all types being displayed.
26 | // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317
27 | // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410
28 | transform: (commit, context) => {
29 | const issues = []
30 |
31 | commit.notes.forEach(note => {
32 | note.title = `BREAKING CHANGES`
33 | })
34 |
35 | // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
36 | if (commit.type === `feat`) {
37 | commit.type = `Features`
38 | } else if (commit.type === `fix`) {
39 | commit.type = `Bug Fixes`
40 | } else if (commit.type === `perf`) {
41 | commit.type = `Performance Improvements`
42 | } else if (commit.type === `revert`) {
43 | commit.type = `Reverts`
44 | } else if (commit.type === `docs`) {
45 | commit.type = `Documentation`
46 | } else if (commit.type === `style`) {
47 | commit.type = `Styles`
48 | } else if (commit.type === `refactor`) {
49 | commit.type = `Code Refactoring`
50 | } else if (commit.type === `test`) {
51 | commit.type = `Tests`
52 | } else if (commit.type === `build`) {
53 | commit.type = `Build System`
54 | // } else if (commit.type === `chore`) {
55 | // commit.type = `Maintenance`
56 | } else if (commit.type === `ci`) {
57 | commit.type = `Continuous Integration`
58 | } else {
59 | return
60 | }
61 |
62 | if (commit.scope === `*`) {
63 | commit.scope = ``
64 | }
65 |
66 | if (typeof commit.hash === `string`) {
67 | commit.shortHash = commit.hash.substring(0, 7)
68 | }
69 |
70 | if (typeof commit.subject === `string`) {
71 | let url = context.repository
72 | ? `${context.host}/${context.owner}/${context.repository}`
73 | : context.repoUrl
74 | if (url) {
75 | url = `${url}/issues/`
76 | // Issue URLs.
77 | commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
78 | issues.push(issue)
79 | return `[#${issue}](${url}${issue})`
80 | })
81 | }
82 | if (context.host) {
83 | // User URLs.
84 | commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
85 | if (username.includes('/')) {
86 | return `@${username}`
87 | }
88 |
89 | return `[@${username}](${context.host}/${username})`
90 | })
91 | }
92 | }
93 |
94 | // remove references that already appear in the subject
95 | commit.references = commit.references.filter(reference => {
96 | if (issues.indexOf(reference.issue) === -1) {
97 | return true
98 | }
99 |
100 | return false
101 | })
102 |
103 | return commit
104 | },
105 | },
106 | },
107 | };
108 |
--------------------------------------------------------------------------------
/test/integration/default/README.md:
--------------------------------------------------------------------------------
1 | # InSpec Profile: `default`
2 |
3 | This shows the implementation of the `default` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
4 |
5 | ## Verify a profile
6 |
7 | InSpec ships with built-in features to verify a profile structure.
8 |
9 | ```bash
10 | $ inspec check default
11 | Summary
12 | -------
13 | Location: default
14 | Profile: profile
15 | Controls: 4
16 | Timestamp: 2019-06-24T23:09:01+00:00
17 | Valid: true
18 |
19 | Errors
20 | ------
21 |
22 | Warnings
23 | --------
24 | ```
25 |
26 | ## Execute a profile
27 |
28 | To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
29 |
30 | ```bash
31 | $ inspec exec default
32 | ..
33 |
34 | Finished in 0.0025 seconds (files took 0.12449 seconds to load)
35 | 8 examples, 0 failures
36 | ```
37 |
38 | ## Execute a specific control from a profile
39 |
40 | To run one control from the profile use `inspec exec /path/to/profile --controls name`.
41 |
42 | ```bash
43 | $ inspec exec default --controls package
44 | .
45 |
46 | Finished in 0.0025 seconds (files took 0.12449 seconds to load)
47 | 1 examples, 0 failures
48 | ```
49 |
50 | See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).
51 |
--------------------------------------------------------------------------------
/test/integration/default/controls/archive_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | control 'prometheus components' do
4 | title 'should be installed'
5 |
6 | case platform[:family]
7 | when 'debian'
8 | service_dir = '/lib/systemd/system'
9 | alert_manager_service = 'prometheus-alertmanager'
10 | node_exporter_service = 'prometheus-node-exporter'
11 | php_fpm_exporter_service = 'php-fpm_exporter'
12 | postgres_exporter_service = 'prometheus-postgres-exporter'
13 | mysqld_exporter_service = 'prometheus-mysqld-exporter'
14 | else
15 | service_dir = '/usr/lib/systemd/system'
16 | alert_manager_service = 'alertmanager'
17 | node_exporter_service = 'node_exporter'
18 | php_fpm_exporter_service = 'php-fpm_exporter'
19 | postgres_exporter_service = 'postgres_exporter'
20 | mysqld_exporter_service = 'mysqld_exporter'
21 | end
22 |
23 | # describe package('cron') do
24 | # it { should be_installed } # not available on amazonlinux?
25 | # end
26 | describe group('prometheus') do
27 | it { should exist }
28 | end
29 | describe user('prometheus') do
30 | it { should exist }
31 | end
32 | describe group('alertmanager') do
33 | it { should exist }
34 | end
35 | describe user('alertmanager') do
36 | it { should exist }
37 | end
38 | describe group('node_exporter') do
39 | it { should exist }
40 | end
41 | describe user('node_exporter') do
42 | it { should exist }
43 | end
44 | describe user('php-fpm_exporter') do
45 | it { should exist }
46 | end
47 | describe user('postgres_exporter') do
48 | it { should exist }
49 | end
50 | describe group('mysqld_exporter') do
51 | it { should exist }
52 | end
53 | describe user('mysqld_exporter') do
54 | it { should exist }
55 | end
56 | describe directory('/var/lib/prometheus') do
57 | it { should exist }
58 | end
59 | describe directory('/opt/prometheus/prometheus-v2.22.1') do
60 | it { should exist }
61 | its('group') { should eq 'root' }
62 | end
63 | describe file('/opt/prometheus/prometheus-v2.22.1/prometheus') do
64 | it { should exist }
65 | its('group') { should eq 'root' }
66 | end
67 | describe directory('/var/lib/prometheus/prometheus') do
68 | it { should exist }
69 | its('group') { should eq 'prometheus' }
70 | end
71 | describe file("#{service_dir}/prometheus.service") do
72 | it { should exist }
73 | its('group') { should eq 'root' }
74 | its('mode') { should cmp '0644' }
75 | end
76 | describe directory('/opt/prometheus/alertmanager-v0.21.0') do
77 | it { should exist }
78 | its('group') { should eq 'root' }
79 | end
80 | describe file('/opt/prometheus/alertmanager-v0.21.0/amtool') do
81 | it { should exist }
82 | its('group') { should eq 'root' }
83 | end
84 | describe directory('/var/lib/prometheus/alertmanager') do
85 | it { should exist }
86 | its('group') { should eq 'alertmanager' }
87 | end
88 | describe file("#{service_dir}/#{alert_manager_service}.service") do
89 | it { should exist }
90 | its('group') { should eq 'root' }
91 | its('mode') { should cmp '0644' }
92 | end
93 | describe directory('/opt/prometheus/node_exporter-v1.0.1') do
94 | it { should exist }
95 | its('group') { should eq 'root' }
96 | end
97 | describe file('/opt/prometheus/node_exporter-v1.0.1/node_exporter') do
98 | it { should exist }
99 | its('group') { should eq 'root' }
100 | end
101 | describe directory('/var/lib/prometheus/node_exporter') do
102 | it { should exist }
103 | its('group') { should eq 'node_exporter' }
104 | end
105 | describe file("#{service_dir}/#{node_exporter_service}.service") do
106 | it { should exist }
107 | its('group') { should eq 'root' }
108 | its('mode') { should cmp '0644' }
109 | end
110 | describe directory('/opt/prometheus/php-fpm_exporter-v0.6.1') do
111 | it { should exist }
112 | its('group') { should eq 'root' }
113 | end
114 | describe file('/opt/prometheus/php-fpm_exporter-v0.6.1/php-fpm_exporter') do
115 | it { should exist }
116 | its('group') { should eq 'root' }
117 | end
118 | describe directory('/var/lib/prometheus/php-fpm_exporter') do
119 | it { should exist }
120 | end
121 | describe file("#{service_dir}/#{php_fpm_exporter_service}.service") do
122 | it { should exist }
123 | its('group') { should eq 'root' }
124 | its('mode') { should cmp '0644' }
125 | end
126 | describe directory('/var/lib/prometheus/postgres_exporter') do
127 | it { should exist }
128 | end
129 | describe directory('/opt/prometheus/postgres_exporter-v0.8.0') do
130 | it { should exist }
131 | its('group') { should eq 'root' }
132 | end
133 | describe file('/opt/prometheus/postgres_exporter-v0.8.0/postgres_exporter') do
134 | it { should exist }
135 | its('group') { should eq 'root' }
136 | end
137 | describe file("#{service_dir}/#{postgres_exporter_service}.service") do
138 | it { should exist }
139 | its('group') { should eq 'root' }
140 | its('mode') { should cmp '0644' }
141 | end
142 | describe directory('/opt/prometheus/mysqld_exporter-v0.12.1') do
143 | it { should exist }
144 | its('group') { should eq 'root' }
145 | end
146 | describe file('/opt/prometheus/mysqld_exporter-v0.12.1/mysqld_exporter') do
147 | it { should exist }
148 | its('group') { should eq 'root' }
149 | end
150 | describe directory('/var/lib/prometheus/mysqld_exporter') do
151 | it { should exist }
152 | its('group') { should eq 'mysqld_exporter' }
153 | end
154 | describe file("#{service_dir}/#{mysqld_exporter_service}.service") do
155 | it { should exist }
156 | its('content') { should match 'Environment=DATA_SOURCE_NAME=foo:bar@/' }
157 | its('group') { should eq 'root' }
158 | its('mode') { should cmp '0644' }
159 | end
160 |
161 | describe file('/usr/local/sbin/alertmanager') do
162 | it { should exist }
163 | its('group') { should eq 'root' }
164 | end
165 | describe file('/usr/local/sbin/amtool') do
166 | it { should exist }
167 | its('group') { should eq 'root' }
168 | end
169 | describe file('/usr/local/sbin/node_exporter') do
170 | it { should exist }
171 | its('group') { should eq 'root' }
172 | end
173 | describe file('/usr/local/sbin/prometheus') do
174 | it { should exist }
175 | its('group') { should eq 'root' }
176 | end
177 | describe file('/usr/local/sbin/promtool') do
178 | it { should exist }
179 | its('group') { should eq 'root' }
180 | end
181 | end
182 |
--------------------------------------------------------------------------------
/test/integration/default/controls/config_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | control 'prometheus configuration files' do
4 | title 'should exist'
5 |
6 | describe file('/etc/prometheus/prometheus.yml') do
7 | it { should exist }
8 | its('group') { should eq 'prometheus' }
9 | its('mode') { should cmp '0644' }
10 | end
11 | describe file('/etc/prometheus/alertmanager.yml') do
12 | it { should exist }
13 | its('group') { should eq 'alertmanager' }
14 | its('mode') { should cmp '0644' }
15 | end
16 | describe file('/etc/prometheus/first_rules.yml') do
17 | it { should exist }
18 | its('group') { should eq 'alertmanager' }
19 | its('mode') { should cmp '0644' }
20 | end
21 | describe file('/etc/prometheus/subdir/second.yml') do
22 | it { should exist }
23 | its('group') { should eq 'alertmanager' }
24 | its('mode') { should cmp '0644' }
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/test/integration/default/controls/service_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | control 'services with a consistent service name on each distro' do
4 | title 'should be running'
5 |
6 | distro_services =
7 | case platform[:family]
8 | when 'debian'
9 | %w[
10 | prometheus
11 | prometheus-alertmanager
12 | prometheus-node-exporter
13 | prometheus-blackbox-exporter
14 | ]
15 | else
16 | %w[
17 | prometheus
18 | alertmanager
19 | node_exporter
20 | blackbox_exporter
21 | ]
22 | end
23 |
24 | distro_services.each do |service|
25 | describe service(service) do
26 | it { should be_enabled }
27 | it { should be_running }
28 | end
29 | end
30 |
31 | # blackbox_exporter port
32 | describe port(9115) do
33 | it { should be_listening }
34 | end
35 | end
36 |
37 | control 'services with any service name we want to give them' do
38 | title 'should be running'
39 |
40 | # if we set a service name in the pillar,
41 | # the formula should work, no matter what it is or the
42 | # install method we choose
43 |
44 | describe service('my-fancy-consul-exporter-service') do
45 | it { should be_enabled }
46 | it { should be_running }
47 | end
48 |
49 | # consul_exporter port
50 | describe port(9107) do
51 | it { should be_listening }
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/test/integration/default/inspec.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | name: default
5 | title: prometheus formula
6 | maintainer: SaltStack Formulas
7 | license: Apache-2.0
8 | summary: Verify that the prometheus formula is setup and configured correctly
9 | depends:
10 | - name: share
11 | path: test/integration/share
12 | supports:
13 | - platform-name: debian
14 | - platform-name: ubuntu
15 | - platform-name: centos
16 | - platform-name: fedora
17 | - platform-name: opensuse
18 | - platform-name: suse
19 | - platform-name: freebsd
20 | - platform-name: openbsd
21 | - platform-name: amazon
22 | - platform-name: oracle
23 | - platform-name: arch
24 | - platform-name: gentoo
25 | - platform-name: almalinux
26 | - platform-name: rocky
27 | - platform-name: mac_os_x
28 | - platform: windows
29 |
--------------------------------------------------------------------------------
/test/integration/repo/README.md:
--------------------------------------------------------------------------------
1 | # InSpec Profile: `repo`
2 |
3 | This shows the implementation of the `repo` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
4 |
5 | ## Verify a profile
6 |
7 | InSpec ships with built-in features to verify a profile structure.
8 |
9 | ```bash
10 | $ inspec check repo
11 | Summary
12 | -------
13 | Location: repo
14 | Profile: profile
15 | Controls: 4
16 | Timestamp: 2019-06-24T23:09:01+00:00
17 | Valid: true
18 |
19 | Errors
20 | ------
21 |
22 | Warnings
23 | --------
24 | ```
25 |
26 | ## Execute a profile
27 |
28 | To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
29 |
30 | ```bash
31 | $ inspec exec repo
32 | ..
33 |
34 | Finished in 0.0025 seconds (files took 0.12449 seconds to load)
35 | 8 examples, 0 failures
36 | ```
37 |
38 | ## Execute a specific control from a profile
39 |
40 | To run one control from the profile use `inspec exec /path/to/profile --controls name`.
41 |
42 | ```bash
43 | $ inspec exec repo --controls package
44 | .
45 |
46 | Finished in 0.0025 seconds (files took 0.12449 seconds to load)
47 | 1 examples, 0 failures
48 | ```
49 |
50 | See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).
51 |
--------------------------------------------------------------------------------
/test/integration/repo/controls/packages_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | control 'prometheus packages' do
4 | title 'should be installed'
5 |
6 | packages =
7 | case platform[:family]
8 | when 'redhat'
9 | %w[
10 | prometheus2
11 | alertmanager
12 | node_exporter
13 | ]
14 | when 'linux'
15 | case platform[:name]
16 | when 'arch'
17 | %w[
18 | prometheus
19 | alertmanager
20 | prometheus-node-exporter
21 | ]
22 | end
23 | else
24 | %w[
25 | prometheus
26 | prometheus-alertmanager
27 | prometheus-node-exporter
28 | ]
29 | end
30 |
31 | packages.each do |p|
32 | describe package(p) do
33 | it { should be_installed }
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/test/integration/repo/controls/repositories_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | control 'repositories' do
4 | impact 0.6
5 | title 'Configure the repositories'
6 | desc '
7 | Configure the Debian/RedHat repositories for the supported platforms.
8 | '
9 | tag 'repositories', 'apt', 'yum'
10 | ref 'Prometheus prerequisites - Section: Prometheus package repositories', url: 'https://prometheus.io/download'
11 |
12 | case os[:family]
13 | when 'debian'
14 | describe file('/etc/apt/sources.list.d/prometheus.list') do
15 | it { should_not exist }
16 | end
17 | when 'redhat', 'centos'
18 | describe yum.repo('prometheus') do
19 | it { should exist }
20 | it { should be_enabled }
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/repo/controls/service_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | control 'prometheus services' do
4 | title 'should be running'
5 |
6 | services =
7 | case platform[:family]
8 | when 'redhat'
9 | %w[
10 | node_exporter
11 | prometheus
12 | blackbox_exporter
13 | alertmanager
14 | ]
15 | else
16 | %w[
17 | prometheus
18 | prometheus-node-exporter
19 | prometheus-blackbox-exporter
20 | prometheus-alertmanager
21 | ]
22 | end
23 |
24 | node_exporter =
25 | case platform[:family]
26 | when 'redhat'
27 | 'node_exporter'
28 | else
29 | 'prometheus-node-exporter'
30 | end
31 |
32 | services.each do |service|
33 | describe service(service) do
34 | it { should be_enabled }
35 | it { should be_running }
36 | end
37 |
38 | describe file("/etc/default/#{service}") do
39 | it { should exist }
40 | end
41 | end
42 |
43 | # prometheus-node-exporter port
44 | describe port(9110) do
45 | it { should be_listening }
46 | end
47 |
48 | # environ args check
49 | describe file('/etc/default/prometheus') do
50 | its('content') { should include '--log.level=debug' }
51 | end
52 |
53 | describe file("/etc/default/#{node_exporter}") do
54 | its('content') { should include '--web.listen-address=:9110' }
55 | its('content') { should include '--log.level=debug' }
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/test/integration/repo/inspec.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | name: repo
5 | title: prometheus formula
6 | maintainer: SaltStack Formulas
7 | license: Apache-2.0
8 | summary: Verify that the prometheus formula is setup and configured correctly
9 | depends:
10 | - name: share
11 | path: test/integration/share
12 | supports:
13 | - platform-name: debian
14 | - platform-name: ubuntu
15 | - platform-name: centos
16 | - platform-name: fedora
17 | - platform-name: opensuse
18 | - platform-name: suse
19 | - platform-name: freebsd
20 | - platform-name: openbsd
21 | - platform-name: amazon
22 | - platform-name: oracle
23 | - platform-name: arch
24 | - platform-name: gentoo
25 | - platform-name: almalinux
26 | - platform-name: rocky
27 | - platform-name: mac_os_x
28 | - platform: windows
29 |
--------------------------------------------------------------------------------
/test/integration/share/README.md:
--------------------------------------------------------------------------------
1 | # InSpec Profile: `share`
2 |
3 | This shows the implementation of the `share` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
4 |
5 | Its goal is to share the libraries between all profiles.
6 |
7 | ## Libraries
8 |
9 | ### `system`
10 |
11 | The `system` library provides easy access to system dependent information:
12 |
13 | - `system.platform`: based on `inspec.platform`, modify to values that are more consistent from a SaltStack perspective
14 | - `system.platform[:family]` provide a family name for Arch and Gentoo
15 | - `system.platform[:name]` append `linux` to both `amazon` and `oracle`; ensure Windows platforms are resolved as simply `windows`
16 | - `system.platform[:release]` tweak Arch, Amazon Linux, Gentoo, openSUSE and Windows:
17 | - `Arch` is always `base-latest`
18 | - `Amazon Linux` release `2018` is resolved as `1`
19 | - `Gentoo` release is trimmed to its major version number and then the init system is appended (i.e. `sysv` or `sysd`)
20 | - `openSUSE` is resolved as `tumbleweed` if the `platform[:release]` is in date format
21 | - `Windows` uses the widely-used release number (e.g. `8.1` or `2019-server`) in place of the actual system release version
22 | - `system.platform[:finger]` is the concatenation of the name and the major release number (except for Ubuntu, which gives `ubuntu-20.04` for example)
23 |
--------------------------------------------------------------------------------
/test/integration/share/inspec.yml:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | name: share
5 | title: InSpec shared resources
6 | maintainer: SaltStack Formulas
7 | license: Apache-2.0
8 | summary: shared resources
9 | supports:
10 | - platform-name: debian
11 | - platform-name: ubuntu
12 | - platform-name: centos
13 | - platform-name: fedora
14 | - platform-name: opensuse
15 | - platform-name: suse
16 | - platform-name: freebsd
17 | - platform-name: openbsd
18 | - platform-name: amazon
19 | - platform-name: oracle
20 | - platform-name: arch
21 | - platform-name: gentoo
22 | - platform-name: almalinux
23 | - platform-name: rocky
24 | - platform-name: mac_os_x
25 | - platform: windows
26 |
--------------------------------------------------------------------------------
/test/integration/share/libraries/system.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # system.rb -- InSpec resources for system values
4 | # Author: Daniel Dehennin
5 | # Copyright (C) 2020 Daniel Dehennin
6 |
7 | # rubocop:disable Metrics/ClassLength
8 | class SystemResource < Inspec.resource(1)
9 | name 'system'
10 |
11 | attr_reader :platform
12 |
13 | def initialize
14 | super
15 | @platform = build_platform
16 | end
17 |
18 | private
19 |
20 | def build_platform
21 | {
22 | family: build_platform_family,
23 | name: build_platform_name,
24 | release: build_platform_release,
25 | finger: build_platform_finger,
26 | codename: build_platform_codename
27 | }
28 | end
29 |
30 | def build_platform_family
31 | case inspec.platform[:name]
32 | when 'arch', 'gentoo'
33 | inspec.platform[:name]
34 | else
35 | inspec.platform[:family]
36 | end
37 | end
38 |
39 | def build_platform_name
40 | case inspec.platform[:name]
41 | when 'amazon', 'oracle', 'rocky'
42 | "#{inspec.platform[:name]}linux"
43 | when /^windows_/
44 | inspec.platform[:family]
45 | else
46 | inspec.platform[:name]
47 | end
48 | end
49 |
50 | # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity
51 | def build_platform_release
52 | case inspec.platform[:name]
53 | when 'amazon'
54 | # `2018` relase is named `1` in `kitchen.yml`
55 | inspec.platform[:release].gsub(/2018.*/, '1')
56 | when 'arch'
57 | 'base-latest'
58 | when 'gentoo'
59 | "#{inspec.platform[:release].split('.')[0]}-#{derive_gentoo_init_system}"
60 | when 'mac_os_x'
61 | inspec.command('sw_vers -productVersion').stdout.to_s
62 | when 'opensuse'
63 | # rubocop:disable Style/NumericLiterals,Layout/LineLength
64 | inspec.platform[:release].to_i > 20210101 ? 'tumbleweed' : inspec.platform[:release]
65 | # rubocop:enable Style/NumericLiterals,Layout/LineLength
66 | when 'windows_8.1_pro'
67 | '8.1'
68 | when 'windows_server_2022_datacenter'
69 | '2022-server'
70 | when 'windows_server_2019_datacenter'
71 | '2019-server'
72 | when 'windows_server_2016_datacenter'
73 | '2016-server'
74 | else
75 | inspec.platform[:release]
76 | end
77 | end
78 | # rubocop:enable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity
79 |
80 | def derive_gentoo_init_system
81 | inspec.command('systemctl').exist? ? 'sysd' : 'sysv'
82 | end
83 |
84 | def build_platform_finger
85 | "#{build_platform_name}-#{build_finger_release}"
86 | end
87 |
88 | def build_finger_release
89 | case inspec.platform[:name]
90 | when 'ubuntu'
91 | build_platform_release.split('.').slice(0, 2).join('.')
92 | else
93 | build_platform_release.split('.')[0]
94 | end
95 | end
96 |
97 | # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity
98 | def build_platform_codename
99 | case build_platform_finger
100 | when 'ubuntu-22.04'
101 | 'jammy'
102 | when 'ubuntu-20.04'
103 | 'focal'
104 | when 'ubuntu-18.04'
105 | 'bionic'
106 | when 'debian-11'
107 | 'bullseye'
108 | when 'debian-10'
109 | 'buster'
110 | when 'debian-9'
111 | 'stretch'
112 | when 'almalinux-8'
113 | "AlmaLinux #{build_platform_release} (Arctic Sphynx)"
114 | when 'amazonlinux-2'
115 | 'Amazon Linux 2'
116 | when 'arch-base-latest'
117 | 'Arch Linux'
118 | when 'centos-7'
119 | 'CentOS Linux 7 (Core)'
120 | when 'centos-8'
121 | 'CentOS Stream 8'
122 | when 'opensuse-tumbleweed'
123 | 'openSUSE Tumbleweed'
124 | when 'opensuse-15'
125 | "openSUSE Leap #{build_platform_release}"
126 | when 'oraclelinux-8', 'oraclelinux-7'
127 | "Oracle Linux Server #{build_platform_release}"
128 | when 'gentoo-2-sysd', 'gentoo-2-sysv'
129 | 'Gentoo/Linux'
130 | when 'rockylinux-8'
131 | "Rocky Linux #{build_platform_release} (Green Obsidian)"
132 | else
133 | ''
134 | end
135 | end
136 | # rubocop:enable Metrics/MethodLength,Metrics/CyclomaticComplexity
137 | end
138 | # rubocop:enable Metrics/ClassLength
139 |
--------------------------------------------------------------------------------
/test/salt/pillar/default.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | # Uses the archive install method identified by 'use_upstream_archive: true'
5 | prometheus:
6 | wanted:
7 | clientlibs:
8 | - golang
9 | - haskell
10 | - rust
11 | component:
12 | # List components (ie, exporters) using underscores and
13 | # removing the 'prometheus' prefix
14 | - prometheus
15 | - alertmanager
16 | - node_exporter
17 | - blackbox_exporter
18 | - consul_exporter
19 | - php-fpm_exporter
20 | - postgres_exporter
21 | - mysqld_exporter
22 | - memcached_exporter # not in upstream repo, only archive
23 |
24 | exporters:
25 | node_exporter:
26 | textfile_collectors_dependencies: []
27 | textfile_collectors:
28 | ipmitool:
29 | enable: false
30 | remove: false
31 | pkg: ipmitool
32 | smartmon:
33 | enable: false
34 | remove: false
35 | pkg: smartmontools
36 | bash_pkg: bash
37 | smartctl: /usr/sbin/smartctl
38 | pkg:
39 | use_upstream_repo: false
40 | use_upstream_archive: true
41 |
42 | clientlibs:
43 | # https://prometheus.io/docs/instrumenting/clientlibs
44 | # no bash & perl client tarballs are available
45 | golang:
46 | version: v1.6.0
47 | component:
48 | # If you use OS packages in Debian's family, components should have
49 | # a 'name' variable stating the name of the package (it's generally
50 | # something like `prometheus-component-with-dashes-replacing-underscores`
51 | # ie,
52 | # node_exporter:
53 | # name: prometheus-node-exporter
54 | #
55 | # See prometheus/osfamilymap.yaml for more examples
56 | alertmanager:
57 | config:
58 | # yamllint disable-line rule:line-length
59 | # ref https://github.com/prometheus/alertmanager/blob/master/config/testdata/conf.good.yml
60 | global:
61 | smtp_smarthost: 'localhost:25'
62 | smtp_from: 'alertmanager@example.org'
63 | smtp_auth_username: 'alertmanager'
64 | smtp_auth_password: "multiline\nmysecret"
65 | smtp_hello: "host.example.org"
66 | slack_api_url: "http://mysecret.example.com/"
67 | http_config:
68 | proxy_url: 'http://127.0.0.1:1025'
69 | route:
70 | group_by: ['alertname', 'cluster', 'service']
71 | group_wait: 30s
72 | group_interval: 5m
73 | repeat_interval: 3h
74 | receiver: team-X-mails
75 | routes:
76 | - match_re:
77 | service: ^(foo1|foo2|baz)$
78 | receiver: team-X-mails
79 | routes:
80 | - match:
81 | severity: critical
82 | receiver: team-X-mails
83 | receivers:
84 | - name: 'team-X-mails'
85 | email_configs:
86 | - to: 'team-X+alerts@example.org'
87 |
88 | node_exporter:
89 | environ:
90 | args:
91 | collector.systemd: true
92 | web.listen-address: ":9110"
93 | service:
94 | args:
95 | collector.systemd: null
96 | web.listen-address: ":9110"
97 | # collector.textfile.directory: /var/tmp/node_exporter
98 |
99 | blackbox_exporter:
100 | service:
101 | args:
102 | web.listen-address: ":9115"
103 | config_file: /opt/prometheus/blackbox_exporter-v0.18.0/blackbox.yml
104 |
105 | consul_exporter:
106 | service:
107 | # This is to test that any fancy name we use, will work in archive mode
108 | name: my-fancy-consul-exporter-service
109 |
110 | mysqld_exporter:
111 | service:
112 | args:
113 | web.listen-address: 0.0.0.0:9192
114 | env:
115 | - 'DATA_SOURCE_NAME=foo:bar@/'
116 |
117 | prometheus:
118 | service:
119 | args:
120 | web.listen-address: 0.0.0.0:9090
121 | storage.tsdb.retention.time: 150d
122 | environ:
123 | args:
124 | web.listen-address: 0.0.0.0:9090
125 | log.level: debug
126 | config:
127 | # yamllint disable-line rule:line-length
128 | # ref https://raw.githubusercontent.com/prometheus/prometheus/release-2.10/config/testdata/conf.good.yml
129 | # my global config
130 | global:
131 | # Set the scrape interval to every 15 seconds. Default is every 1 minute
132 | scrape_interval: 15s
133 | # Evaluate rules every 15 seconds. The default is every 1 minute
134 | evaluation_interval: 15s
135 | # scrape_timeout is set to the global default (10s)
136 |
137 | # Alertmanager configuration
138 | alerting:
139 | alertmanagers:
140 | - static_configs:
141 | - targets:
142 | - alertmanager1:9093
143 | - alertmanager2:9093
144 | - alertmanager3:9093
145 |
146 | # Load rules once and periodically evaluate them according to the global
147 | # 'evaluation_interval'
148 | # You can manage these files with the `extra_files` dict (see below)
149 | rule_files:
150 | - "first_rules.yml"
151 | # - "second_rules.yml"
152 |
153 | # A scrape configuration containing exactly one endpoint to scrape:
154 | scrape_configs:
155 | # The job name is added as a label `job=` to any timeseries
156 | # scraped from this config
157 | - job_name: 'prometheus'
158 | # metrics_path defaults to '/metrics'
159 | # scheme defaults to 'http'
160 | static_configs:
161 | - targets: ['localhost:9090']
162 |
163 | - job_name: pushgateway
164 | scrape_interval: 5s
165 | honor_labels: true
166 | static_configs:
167 | - targets: ['pushgateway:9091']
168 |
169 | - job_name: 'blackbox'
170 | # https://github.com/prometheus/blackbox_exporter#prometheus-configuration
171 | metrics_path: /probe
172 | params:
173 | module: [http_2xx] # Look for a HTTP 200 response
174 | static_configs:
175 | - targets:
176 | - http://prometheus.io # Target to probe with http
177 | - https://prometheus.io # Target to probe with https
178 | - http://example.com:8080 # Target to probe with http on port 8080
179 | relabel_configs:
180 | - source_labels: [__address__]
181 | target_label: __param_target
182 | - source_labels: [__param_target]
183 | target_label: instance
184 | - target_label: __address__
185 | replacement: '127.0.0.1:9115' # real hostname and port
186 |
187 | pushgateway:
188 | version: v0.8.0
189 | archive:
190 | source_hash: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
191 | service:
192 | args:
193 | web.listen-address: ":9091"
194 | web.telemetry-path: "/metrics"
195 |
196 | # Unoffical php fpm exporter config
197 | php-fpm_exporter:
198 | version: v0.6.1
199 | archive:
200 | official: false
201 | tar: false
202 | # yamllint disable-line rule:line-length
203 | source: https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64
204 | source_hash: 40e52d84f7decb5fdad9fadacf63cb2de26ebddce56e11b20651555e8d6c6130
205 | service:
206 | args:
207 | addr: ":9253"
208 | fastcgi: "unix:///run/php/php-fpm.sock"
209 |
210 | postgres_exporter:
211 | version: v0.8.0
212 | service:
213 | env:
214 | - 'DATA_SOURCE_NAME=foo:bar@/'
215 | archive:
216 | official: false
217 | # yamllint disable-line rule:line-length
218 | source: https://github.com/wrouesnel/postgres_exporter/releases/download/v0.8.0/postgres_exporter_v0.8.0_linux-amd64.tar.gz
219 | skip_verify: true
220 |
221 | linux:
222 | # 'Alternatives system' priority: zero disables (default)
223 | # yamllint disable-line rule:braces
224 | altpriority: {{ range(1, 100000) | random }}
225 |
226 | # This dict lets you manage other config files (like the `rule_files` for the
227 | # alertmanager) or split the config un multiple and organize files in meaninful ways
228 | extra_files:
229 | first_rules:
230 | component: alertmanager
231 | config:
232 | groups:
233 | - name: example
234 | rules:
235 | - alert: HighRequestLatency
236 | expr: 'job:request_latency_seconds:mean5m{job="myjob"} > 0.5'
237 | for: 10m
238 | labels:
239 | severity: page
240 | annotations:
241 | summary: High request latency
242 | # You can specify a `file` parameter, which will be used to create a file
243 | # under the prometheus config dir. In this example, the file will be
244 | # named /etc/prometheus/subdir/second.yml
245 | second_rules:
246 | file: subdir/second
247 | component: alertmanager
248 | config:
249 | groups:
250 | - name: example
251 | rules:
252 | - alert: HighRequestLatency
253 | expr: 'job:request_latency_seconds:mean5m{job="myjob"} > 0.5'
254 | for: 10m
255 | labels: {}
256 |
257 | tofs:
258 | # The files_switch key serves as a selector for alternative
259 | # directories under the formula files directory. See TOFS pattern
260 | # doc for more info
261 | # Note: Any value not evaluated by `config.get` will be used literally
262 | # This can be used to set custom paths, as many levels deep as required
263 | files_switch:
264 | - any/path/can/be/used/here
265 | - id
266 | - osfinger
267 | - os
268 | - os_family
269 | # All aspects of path/file resolution are customisable using the options below
270 | # This is unnecessary in most cases; there are sensible defaults
271 | # path_prefix: prometheus_alt
272 | # dirs:
273 | # files: files_alt
274 | # default: default_alt
275 | source_files:
276 | prometheus-config-file-file-managed:
277 | - 'alt_config.yml.jinja'
278 | prometheus-archive-install-managed-service:
279 | - 'alt_systemd.ini.jinja'
280 |
--------------------------------------------------------------------------------
/test/salt/pillar/repo.sls:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | # vim: ft=yaml
3 | ---
4 | # Uses the standard install method from package repo
5 | prometheus:
6 | wanted:
7 | clientlibs:
8 | - golang
9 | - haskell
10 | - rust
11 | component:
12 | - prometheus
13 | - alertmanager
14 | - node_exporter
15 | - blackbox_exporter
16 |
17 | exporters:
18 | node_exporter:
19 | textfile_collectors_dependencies: []
20 | textfile_collectors:
21 | ipmitool:
22 | enable: false
23 | remove: false
24 | pkg: ipmitool
25 | smartmon:
26 | enable: false
27 | remove: false
28 | pkg: smartmontools
29 | bash_pkg: bash
30 | smartctl: /usr/sbin/smartctl
31 |
32 | pkg:
33 | # yamllint disable-line rule:braces rule:commas
34 | use_upstream_repo: {{ false if grains.os_family|lower in ('debian',) else true }}
35 | use_upstream_archive: false
36 |
37 | clientlibs:
38 | # https://prometheus.io/docs/instrumenting/clientlibs
39 | # no bash & perl client tarballs are available
40 | golang:
41 | version: v1.6.0
42 |
43 | component:
44 | alertmanager:
45 | config:
46 | # yamllint disable-line rule:line-length
47 | # ref https://github.com/prometheus/alertmanager/blob/master/config/testdata/conf.good.yml
48 | global:
49 | smtp_smarthost: 'localhost:25'
50 | smtp_from: 'alertmanager@example.org'
51 | smtp_auth_username: 'alertmanager'
52 | smtp_auth_password: "multiline\nmysecret"
53 | slack_api_url: "http://mysecret.example.com/"
54 | {%- if grains.get('oscodename', '') not in ['stretch', 'bionic'] %}
55 | smtp_hello: "host.example.org"
56 | http_config:
57 | proxy_url: 'http://127.0.0.1:1025'
58 | {%- endif %}
59 | route:
60 | group_by: ['alertname', 'cluster', 'service']
61 | group_wait: 30s
62 | group_interval: 5m
63 | repeat_interval: 3h
64 | receiver: team-X-mails
65 | routes:
66 | - match_re:
67 | service: ^(foo1|foo2|baz)$
68 | receiver: team-X-mails
69 | routes:
70 | - match:
71 | severity: critical
72 | receiver: team-X-mails
73 | receivers:
74 | - name: 'team-X-mails'
75 | email_configs:
76 | - to: 'team-X+alerts@example.org'
77 |
78 | node_exporter:
79 | version: v0.18.1
80 | archive:
81 | source_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
82 | environ:
83 | args:
84 | log.level: debug
85 | web.listen-address: ":9110"
86 | service:
87 | args:
88 | web.listen-address: ":9110"
89 | # collector.textfile.directory: /var/tmp/node_exporter
90 |
91 | blackbox_exporter:
92 | service:
93 | args:
94 | web.listen-address: ":9115"
95 |
96 | prometheus:
97 | service:
98 | args:
99 | web.listen-address: 0.0.0.0:9090
100 | environ:
101 | args:
102 | web.listen-address: 0.0.0.0:9090
103 | log.level: debug
104 | config:
105 | # yamllint disable-line rule:line-length
106 | # ref https://raw.githubusercontent.com/prometheus/prometheus/release-2.10/config/testdata/conf.good.yml
107 | # my global config
108 | global:
109 | # Set the scrape interval to every 15 seconds. Default is every 1 minute
110 | scrape_interval: 15s
111 | # Evaluate rules every 15 seconds. The default is every 1 minute
112 | evaluation_interval: 15s
113 | # scrape_timeout is set to the global default (10s)
114 |
115 | # Alertmanager configuration
116 | alerting:
117 | alertmanagers:
118 | - static_configs:
119 | - targets:
120 | - alertmanager1:9093
121 | - alertmanager2:9093
122 | - alertmanager3:9093
123 |
124 | # Load rules once and periodically evaluate them according to the global
125 | # 'evaluation_interval'
126 | rule_files:
127 | - "first_rules.yml"
128 | # - "second_rules.yml"
129 |
130 | # A scrape configuration containing exactly one endpoint to scrape:
131 | scrape_configs:
132 | # The job name is added as a label `job=` to any timeseries
133 | # scraped from this config
134 | - job_name: 'prometheus'
135 | # metrics_path defaults to '/metrics'
136 | # scheme defaults to 'http'
137 | static_configs:
138 | - targets: ['localhost:9090']
139 |
140 | - job_name: pushgateway
141 | scrape_interval: 5s
142 | honor_labels: true
143 | static_configs:
144 | - targets: ['pushgateway:9091']
145 |
146 | - job_name: 'blackbox'
147 | # https://github.com/prometheus/blackbox_exporter#prometheus-configuration
148 | metrics_path: /probe
149 | params:
150 | module: [http_2xx] # Look for a HTTP 200 response
151 | static_configs:
152 | - targets:
153 | - http://prometheus.io # Target to probe with http
154 | - https://prometheus.io # Target to probe with https
155 | - http://example.com:8080 # Target to probe with http on port 8080
156 | relabel_configs:
157 | - source_labels: [__address__]
158 | target_label: __param_target
159 | - source_labels: [__param_target]
160 | target_label: instance
161 | - target_label: __address__
162 | replacement: '127.0.0.1:9115' # real hostname and port
163 |
164 | pushgateway:
165 | version: v0.8.0
166 | archive:
167 | source_hash: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
168 | service:
169 | args:
170 | web.listen-address: ":9091"
171 | web.telemetry-path: "/metrics"
172 |
173 | linux:
174 | # 'Alternatives system' priority: zero disables (default)
175 | # yamllint disable-line rule:braces
176 | altpriority: {{ range(1, 100000) | random }}
177 |
178 | tofs:
179 | # The files_switch key serves as a selector for alternative
180 | # directories under the formula files directory. See TOFS pattern
181 | # doc for more info
182 | # Note: Any value not evaluated by `config.get` will be used literally
183 | # This can be used to set custom paths, as many levels deep as required
184 | files_switch:
185 | - any/path/can/be/used/here
186 | - id
187 | - osfinger
188 | - os
189 | - os_family
190 | # All aspects of path/file resolution are customisable using the options below
191 | # This is unnecessary in most cases; there are sensible defaults
192 | # path_prefix: prometheus_alt
193 | # dirs:
194 | # files: files_alt
195 | # default: default_alt
196 | source_files:
197 | prometheus-config-file-file-managed:
198 | - 'alt_config.yml.jinja'
199 | prometheus-archive-install-managed-service:
200 | - 'alt_systemd.ini.jinja'
201 |
--------------------------------------------------------------------------------