Files
Zabbix-PHP-Execption-Monitor/zabbix_template_php_exceptions.yaml

69 lines
2.5 KiB
YAML
Raw Normal View History

2025-09-29 09:37:58 +02:00
zabbix_export:
version: '6.4'
template_groups:
- uuid: 7df96b18c230490a9a0a9e2307226338
name: 'Templates/Applications'
templates:
- uuid: c770cff7c4bf49e6b2b0e7a5f3d2c4a1
template: 'PHP Exceptions Monitoring'
name: 'PHP Exceptions Monitoring'
description: 'Template for monitoring PHP exceptions with deduplication'
groups:
- name: 'Templates/Applications'
macros:
- macro: '{$PHP.LOG.FILE}'
value: '/var/log/zabbix/php.exceptions.log'
description: 'Path to PHP exception log file'
items:
- uuid: 8df96b18c230490a9a0a9e2307226339
name: 'PHP Exception Monitor'
type: ZABBIX_PASSIVE
key: 'logrt[/var/log/zabbix/php.exceptions.log]'
delay: 30s
history: 7d
trends: '0'
value_type: LOG
description: 'Monitor PHP exceptions from log file'
triggers:
- uuid: 9df96b18c230490a9a0a9e2307226340
expression: 'logeventid(/PHP Exceptions Monitoring/logrt[/var/log/zabbix/php.exceptions.log])'
name: 'PHP Exception occurred'
event_name: 'PHP Exception: {ITEM.LASTVALUE}'
priority: WARNING
description: |
A PHP exception has occurred.
Details: {ITEM.LASTVALUE}
manual_close: 'YES'
tags:
- tag: scope
value: application
- tag: component
value: php
preprocessing:
- type: REGEX
parameters:
- '^(.*)$'
- '\1'
- type: JAVASCRIPT
parameters:
- |
// Parse JSON log entry and format for display
try {
var entry = JSON.parse(value);
var formattedStack = entry.stacktrace.split('\n').map(function(line, index) {
return (index + 1) + ': ' + line.trim();
}).join('\n');
return JSON.stringify({
host: entry.host,
file: entry.file,
line: entry.line,
message: entry.message,
stacktrace: formattedStack,
timestamp: entry.timestamp,
unique_id: entry.unique_id
});
} catch (e) {
return value;
}