prometheus: add support for installing webhook server

This commit is contained in:
uumas
2023-12-21 01:22:26 +02:00
parent 0eeeecb549
commit 681b788ac4
4 changed files with 66 additions and 0 deletions

View File

@@ -7,5 +7,6 @@ prometheus_install_grafana: false
prometheus_hcloud_relabel_configs: [] prometheus_hcloud_relabel_configs: []
prometheus_install_alertmanager: true prometheus_install_alertmanager: true
prometheus_install_webhook: false
alertmanager_storage_retention: "{{ prometheus_storage_retention }}" alertmanager_storage_retention: "{{ prometheus_storage_retention }}"

View File

@@ -51,6 +51,11 @@ argument_specs:
type: bool type: bool
required: false required: false
default: true default: true
prometheus_install_webhook:
description: If true, installs webhook server in the same docker network as prometheus and configures it
type: bool
required: false
default: false
alertmanager_storage_retention: alertmanager_storage_retention:
description: Period of time for which alertmanager data is stored for. A number followed by unit (s, m, h, d, w, y). Passed directly to alertmanager role description: Period of time for which alertmanager data is stored for. A number followed by unit (s, m, h, d, w, y). Passed directly to alertmanager role
@@ -58,6 +63,47 @@ argument_specs:
required: false required: false
default: "{{ prometheus_storage_retention | default('3650d') }}" default: "{{ prometheus_storage_retention | default('3650d') }}"
prometheus_webhook_handlers:
description: List of webhook server handlers
type: list
required: "{{ prometheus_install_webhook }}"
elements: dict
options:
id:
description: specifies the ID of your hook. This value is used to create the HTTP endpoint
type: str
required: true
execute-command:
description: specifies the command that should be executed when the hook is triggered
type: str
required: true
command-working-directory:
description: specifies the working directory that will be used for the script when it's executed
type: str
required: false
pass-arguments-to-command:
description: >
specifies the list of arguments that will be passed to the
command. See for more info:
https://github.com/adnanh/webhook/blob/master/docs/Referencing-Request-Values.md
type: list
required: false
elements: dict
options:
source:
description: Source of the argument. Use `string` to specify argument here.
type: str
required: true
choices:
- string
- header
- url
- request
- payload
name:
description: Argument if source is string, otherwise the source attribute name.
type: str
required: true
# All options after this will be passed directly to the container role # All options after this will be passed directly to the container role
docker_service_suffix: docker_service_suffix:

View File

@@ -31,6 +31,20 @@
- name: prometheus - name: prometheus
when: prometheus_install_alertmanager when: prometheus_install_alertmanager
- name: Webhook container for prometheus
include_role:
name: container
vars:
docker_service: prometheus_webhook
docker_image: thecatlady/webhook
reverse_proxy_type: none
docker_mounts:
- template: webhooks.yaml
path: /config/hooks.yml
docker_networks:
- name: prometheus
when: prometheus_install_webhook
- name: Grafana container for prometheus - name: Grafana container for prometheus
include_role: include_role:
name: grafana name: grafana

View File

@@ -0,0 +1,5 @@
---
{% for item in prometheus_webhook_handlers %}
- {{ item }}
{% endfor %}