]> git.proxmox.com Git - pve-docs.git/blame - notifications.adoc
bump version to 8.1.0
[pve-docs.git] / notifications.adoc
CommitLineData
1ba1e952
LW
1[[chapter_notifications]]
2Notifications
3=============
4ifndef::manvolnum[]
5:pve-toplevel:
6endif::manvolnum[]
7
c877f0aa
LW
8Overview
9--------
10
11{pve} will send notifications if case of noteworthy events in the system.
12
13There are a number of different xref:notification_events[notification events],
14each with their own set of metadata fields that can be used in
15notification matchers.
16
17A xref:notification_matchers[notification matcher] determines
18_which_ notifications shall be sent _where_.
19A matcher has _match rules_, that can be used to
20match on certain notification properties (e.g. timestamp, severity,
21metadata fields).
22If a matcher matches a notification, the notification will be routed
23to a configurable set of notification targets.
24
25A xref:notification_targets[notification target] is an abstraction for a
26destination where a notification should be sent to - for instance,
27a Gotify server instance, or a set of email addresses.
28There are multiple types of notification targets, including
29`sendmail`, which uses the system's sendmail command to send emails,
30or `gotify`, which sends a notification to a Gotify instance.
31
32The notification system can be configured in the GUI under
33Datacenter -> Notifications. The configuration is stored in
34`/etc/pve/notifications.cfg` and `/etc/pve/priv/notifications.cfg` -
35the latter contains sensitive configuration options such as
36passwords or authentication tokens for notification targets.
1ba1e952
LW
37
38[[notification_targets]]
39Notification Targets
40--------------------
41
f5f316bd 42[[notification_targets_sendmail]]
1ba1e952
LW
43Sendmail
44~~~~~~~~
45The sendmail binary is a program commonly found on Unix-like operating systems
46that handles the sending of email messages.
47It is a command-line utility that allows users and applications to send emails
48directly from the command line or from within scripts.
49
50The sendmail notification target uses the `sendmail` binary to send emails.
51
52
53NOTE: In standard {pve} installations, the `sendmail` binary is provided by
54Postfix. For this type of target to work correctly, it might be necessary to
55change Postfix's configuration so that it can correctly deliver emails.
56For cluster setups it is necessary to have a working Postfix configuration on
57every single cluster node.
58
59The configuration for Sendmail target plugins has the following options:
60
61* `mailto`: E-Mail address to which the notification shall be sent to. Can be
62set multiple times to accomodate multiple recipients.
63* `mailto-user`: Users to which emails shall be sent to. The user's email
64address will be looked up in `users.cfg`. Can be set multiple times to
65accomodate multiple recipients.
66* `author`: Sets the author of the E-Mail. Defaults to `Proxmox VE`.
67* `from-address`: Sets the from address of the E-Mail. If the parameter is not
68set, the plugin will fall back to the `email_from` setting from
69`datacenter.cfg`. If that is also not set, the plugin will default to
70`root@$hostname`, where `$hostname` is the hostname of the node.
e39dfad9 71* `comment`: Comment for this target
7a20522e 72The `From` header in the email will be set to `$author <$from-address>`.
1ba1e952 73
c877f0aa
LW
74Example configuration (`/etc/pve/notifications.cfg`):
75----
76sendmail: example
77 mailto-user root@pam
78 mailto-user admin@pve
79 mailto max@example.com
80 from-address pve1@example.com
81 comment Send to multiple users/addresses
82----
1ba1e952 83
f5f316bd 84[[notification_targets_smtp]]
7a20522e
LW
85SMTP
86~~~~
87
88SMTP notification targets can send emails directly to an SMTP mail relay.
89
90The configuration for SMTP target plugins has the following options:
91
92* `mailto`: E-Mail address to which the notification shall be sent to. Can be
93set multiple times to accomodate multiple recipients.
94* `mailto-user`: Users to which emails shall be sent to. The user's email
95address will be looked up in `users.cfg`. Can be set multiple times to
96accomodate multiple recipients.
97* `author`: Sets the author of the E-Mail. Defaults to `Proxmox VE`.
98* `from-address`: Sets the From-addresss of the email. SMTP relays might require
99that this address is owned by the user in order to avoid spoofing.
100The `From` header in the email will be set to `$author <$from-address>`.
101* `username`: Username to use during authentication. If no username is set,
102no authentication will be performed. The PLAIN and LOGIN authentication methods
103are supported.
104* `password`: Password to use when authenticating.
105* `mode`: Sets the encryption mode (`insecure`, `starttls` or `tls`). Defaults
106to `tls`.
107* `server`: Address/IP of the SMTP relay
108* `port`: The port to connect to. If not set, the used port
109defaults to 25 (`insecure`), 465 (`tls`) or 587 (`starttls`), depending on the
110value of `mode`.
111* `comment`: Comment for this target
112
113Example configuration (`/etc/pve/notifications.cfg`):
114----
115smtp: example
116 mailto-user root@pam
117 mailto-user admin@pve
118 mailto max@example.com
119 from-address pve1@example.com
120 username pve1
121 server mail.example.com
122 mode starttls
123----
124The matching entry in `/etc/pve/priv/notifications.cfg`, containing the
125secret token:
126----
127smtp: example
128 password somepassword
129----
130
f5f316bd 131[[notification_targets_gotify]]
1ba1e952
LW
132Gotify
133~~~~~~
134
135http://gotify.net[Gotify] is an open-source self-hosted notification server that
136allows you to send and receive push notifications to various devices and
137applications. It provides a simple API and web interface, making it easy to
138integrate with different platforms and services.
139
140The configuration for Gotify target plugins has the following options:
141
142* `server`: The base URL of the Gotify server, e.g. `http://<ip>:8888`
143* `token`: The authentication token. Tokens can be generated within the Gotify
144web interface.
e39dfad9 145* `comment`: Comment for this target
1ba1e952
LW
146
147NOTE: The Gotify target plugin will respect the HTTP proxy settings from the
148 xref:datacenter_configuration_file[datacenter configuration]
149
c877f0aa
LW
150Example configuration (`/etc/pve/notifications.cfg`):
151----
152gotify: example
153 server http://gotify.example.com:8888
154 comment Send to multiple users/addresses
155----
1ba1e952 156
c877f0aa
LW
157The matching entry in `/etc/pve/priv/notifications.cfg`, containing the
158secret token:
159----
160gotify: example
161 token somesecrettoken
162----
1ba1e952 163
c877f0aa
LW
164[[notification_matchers]]
165Notification Matchers
166---------------------
167Notification matchers route notifications to notification targets based
168on their matching rules. These rules can match of certain properties of
169a notification, such as the timestamp (`match-calendar`), the severity of
170the notificaiton (`match-severity`) or metadata fiels (`match-field`).
171If a matcher matches a notification, all targets configured for the matcher
172will receive the notification.
173
174An arbitrary number of matchers can be created, each with with their own
175matching rules and targets to notify.
176Every target is notified at most once for every notification, even if
177the target is used in multiple matchers.
178
179A matcher without any matching rules is always true; the configured targets
180will always be notified.
181----
182matcher: always-matches
183 target admin
184 comment This matcher always matches
185----
1ba1e952 186
c877f0aa
LW
187Matcher Options
188~~~~~~~~~~~~~~~
1ba1e952 189
c877f0aa
LW
190* `target`: Determine which target should be notified if the matcher matches.
191can be used multiple times to notify multiple targets.
192* `invert-match`: Inverts the result of the whole matcher
193* `mode`: Determines how the individual match rules are evaluated to compute
194the result for the whole matcher. If set to `all`, all matching rules must
195match. If set to `any`, at least one rule must match.
196a matcher must be true. Defaults to `all`.
197* `match-calendar`: Match the notification's timestamp against a schedule
198* `match-field`: Match the notification's metadata fields
199* `match-severity`: Match the notification's severity
e39dfad9 200* `comment`: Comment for this matcher
1ba1e952 201
f5f316bd 202[[notification_matchers_calendar]]
c877f0aa
LW
203Calendar Matching Rules
204~~~~~~~~~~~~~~~~~~~~~~~
205A calendar matcher matches the time when a notification is sent agaist a
206configurable schedule.
1ba1e952 207
c877f0aa
LW
208* `match-calendar 8-12`
209* `match-calendar 8:00-15:30`
210* `match-calendar mon-fri 9:00-17:00`
211* `match-calendar sun,tue-wed,fri 9-17`
1ba1e952 212
f5f316bd 213[[notification_matchers_field]]
c877f0aa
LW
214Field Matching Rules
215~~~~~~~~~~~~~~~~~~~~
216Notifications have a selection of metadata fields that can be matched.
1ba1e952 217
c877f0aa
LW
218* `match-field exact:type=vzdump` Only match notifications about backups.
219* `match-field regex:hostname=^.+\.example\.com$` Match the hostname of
220the node.
1ba1e952 221
c877f0aa
LW
222If a matched metadata field does not exist, the notification will not be
223matched.
224For instance, a `match-field regex:hostname=.*` directive will only match
225notifications that have an arbitraty `hostname` metadata field, but will
226not match if the field does not exist.
1ba1e952 227
f5f316bd 228[[notification_matchers_severity]]
c877f0aa
LW
229Severity Matching Rules
230~~~~~~~~~~~~~~~~~~~~~~~
231A notification has a associated severity that can be matched.
1ba1e952 232
c877f0aa
LW
233* `match-severity error`: Only match errors
234* `match-severity warning,error`: Match warnings and error
1ba1e952 235
c877f0aa 236The following severities are in use:
24451e5d 237`info`, `notice`, `warning`, `error`, `unknown`.
1ba1e952 238
1ba1e952 239
c877f0aa
LW
240Examples
241~~~~~~~~
242----
243matcher: workday
244 match-calendar mon-fri 9-17
245 target admin
246 comment Notify admins during working hours
247
248matcher: night-and-weekend
249 match-calendar mon-fri 9-17
250 invert-match true
251 target on-call-admins
252 comment Separate target for non-working hours
253----
1ba1e952 254
c877f0aa
LW
255----
256matcher: backup-failures
257 match-field exact:type=vzdump
258 match-severity error
259 target backup-admins
260 comment Send notifications about backup failures to one group of admins
261
262matcher: cluster-failures
263 match-field exact:type=replication
264 match-field exact:type=fencing
265 mode any
266 target cluster-admins
267 comment Send cluster-related notifications to other group of admins
268----
1ba1e952 269
c877f0aa
LW
270The last matcher could also be rewritten using a field matcher with a regular
271expression:
272----
273matcher: cluster-failures
274 match-field regex:type=^(replication|fencing)$
275 target cluster-admins
276 comment Send cluster-related notifications to other group of admins
277----
1ba1e952 278
c877f0aa
LW
279[[notification_events]]
280Notification Events
281-------------------
1ba1e952 282
c877f0aa
LW
283[width="100%",options="header"]
284|===========================================================================
285| Event | `type` | Severity | Metadata fields (in addition to `type`)
286| System updates available |`package-updates` | `info` | `hostname`
287| Cluster node fenced |`fencing` | `error` | `hostname`
288| Storage replication failed |`replication` | `error` | -
289| Backup finished |`vzdump` | `info` (`error` on failure) | `hostname`
7b293b5d 290| Mail for root |`system-mail` | `unknown`| -
c877f0aa 291|===========================================================================
1ba1e952 292
c877f0aa
LW
293[width="100%",options="header"]
294|=======================================================================
295| Field name | Description
296| `type` | Type of the notifcation
297| `hostname` | Hostname, including domain (e.g. `pve1.example.com`)
298|=======================================================================
1ba1e952 299
7b293b5d
LW
300System Mail Forwarding
301---------------------
302
303Certain local system daemons, such as `smartd`, generate notification emails
304that are initially directed to the local `root` user. {pve} will
305feed these mails into the notification system as a notification of
306type `system-mail` and with severity `unknown`.
307
308When the forwarding process involves an email-based target
309(like `sendmail` or `smtp`), the email is forwarded exactly as received, with all
310original mail headers remaining intact. For all other targets,
311the system tries to extract both a subject line and the main text body
312from the email content. In instances where emails solely consist of HTML
313content, they will be transformed into plain text format during this process.
314
c877f0aa
LW
315Permissions
316-----------
317
b4c816f4
LW
318In order to modify/view the configuration for notification targets,
319the `Mapping.Modify/Mapping.Audit` permissions are required for the
320`/mapping/notifications` ACL node.
321
322Testing a target requires `Mapping.Use`, `Mapping.Audit` or `Mapping.Modify`
323permissions on `/mapping/notifications`