Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing pmie webhook action configuration functionality #181

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ Example:
metrics_monitored_hosts: ["webserver.example.com", "database.example.com"]
```

### metrics_webhook_endpoint: ''

Webhook endpoint (URL) where notification about any automatically detected
performance issues are to be sent. By default, these events are logged to
the local system log only.

### metrics_retention_days: 14

Retain historical performance data for the specified number of days; after
Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ metrics_manage_firewall: false
# If true, manage the pmcd port, pmproxy ports using the selinux role
# depending upon the configuration parameters.
metrics_manage_selinux: false

# Webhook endpoint (URL) where notification about any automatically detected
# performance issues are to be sent. By default, these events are logged to the
# local system log only.
metrics_webhook_endpoint: ''
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

- name: Setup metric collection service.
vars:
pcp_pmie_endpoint: "{{ metrics_webhook_endpoint }}"
pcp_pmlogger_discard: "{{ metrics_retention_days }}"
pcp_target_hosts: "{{ metrics_monitored_hosts }}"
pcp_optional_agents: "{{ __metrics_domains }}"
Expand Down
18 changes: 18 additions & 0 deletions tests/check_notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: MIT
---
# yamllint disable rule:line-length
- name: Check if webhook notification is set
command: grep -E 'webhook_endpoint .* "?{{ __test_webhook }}"?' /var/lib/pcp/config/pmie/config.default
changed_when: false
register: __status
ignore_errors: true
# yamllint enable rule:line-length

- name: Debug failures
shell: |
cat /var/lib/pcp/config/pmie/config.default
echo '############################'
grep webhook_endpoint /var/lib/pcp/config/pmie/config.default
when: __status is failed
failed_when: __status is failed
changed_when: false
33 changes: 33 additions & 0 deletions tests/tests_verify_notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-License-Identifier: MIT
---
- name: Test configuration of webhook notification
hosts: all
vars:
__test_webhook: https://example.com:4242/endpoint

roles:
- role: linux-system-roles.metrics
vars:
metrics_webhook_endpoint: "{{ __test_webhook }}"

pre_tasks:
- name: Skip test if not supported by platform
meta: end_host
when: (ansible_distribution in ['RedHat', 'CentOS'] and
(ansible_facts['distribution_version'] is version('9.3', '<'))) or
ansible_distribution not in ['Fedora', 'RedHat', 'CentOS']

- name: Save state of services
import_tasks: get_services_state.yml

tasks:
- name: Check basic services and the webhook endpoint
include_tasks: "{{ item }}"
loop:
- check_pcp.yml
- check_pmie.yml
- check_notification.yml

post_tasks:
- name: Restore state of services
import_tasks: restore_services_state.yml
2 changes: 1 addition & 1 deletion tests/tests_verify_pmie_webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
hosts: all

roles:
- role: performancecopilot.metrics.pcp
- role: linux-system-roles.metrics
vars:
pcp_pmie_endpoint: https://example.com:12345/webhook

Expand Down
Loading