Update metrics configuration with new CPU, memory, disk usage, website status, and HTTP request count metrics. Add submetrics for detailed monitoring.

This commit is contained in:
Jeroen De Meerleer 2024-06-05 08:29:59 +02:00
parent 8ac31b0092
commit 09bba2a0c3
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -1,31 +1,94 @@
<?php
$config = [
'app_demo_metric1' => [ // Key is being used a prometheus key
'help' => 'Help text for metric',
'command' => 'The command to be run',
'jsonelem' => '0.metric', // The json element where the metric is found (Dot notated)
],
'app_demo_metric2' => [
'help' => 'Help text for metric',
'http' => [
'url' => 'http://example.com', // The url to get collected for the metric
'data' => 'responsebody', // The body is used as output
],
'jsonelem' => '0.metric',
],
'app_demo_metric3' => [
'help' => 'Help text for metric',
'http' => [
'url' => 'http://example.com', // The url to get collected for the metric
'data' => 'hasresponse', // If an error occured during request this will return 0, otherwise 1
'cpu_usage' => [
'help' => 'CPU usage percentage',
'type' => 'gauge',
'submetrics' => [
[
'command' => 'top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk \'{print 100 - $1}\'',
],
],
],
'app_demo_metric4' => [
'help' => 'Help text for metric',
'http' => [
'url' => 'http://example.com', // The url to get collected for the metric
'data' => 'responsetime', // This will return the transfer time
'proxy' => 'http://192.168.1.252:8080', // The proxy server the request needs to use
'memory_usage' => [
'help' => 'Memory usage percentage',
'type' => 'gauge',
'submetrics' => [
[
'command' => 'free | grep Mem | awk \'{print $3/$2 * 100.0}\'',
],
],
],
];
'disk_usage' => [
'help' => 'Disk usage percentage',
'type' => 'gauge',
'submetrics' => [
[
'command' => 'df -h / | grep / | awk \'{print $5}\' | sed \'s/%//g\'',
],
],
],
'website_response_time' => [
'help' => 'Response time of example.com in seconds',
'type' => 'gauge',
'submetrics' => [
[
'http' => [
'url' => 'http://example.com',
'data' => 'responsetime',
],
],
],
],
'website_status' => [
'help' => 'HTTP status code of example.com',
'type' => 'gauge',
'submetrics' => [
[
'http' => [
'url' => 'http://example.com',
'data' => 'hasresponse',
'statuscode' => [200],
],
],
],
],
'http_request_count' => [
'help' => 'Number of HTTP requests to example.com',
'type' => 'counter',
'submetrics' => [
[
'http' => [
'url' => 'http://example.com',
'data' => 'hasresponse',
],
],
],
],
'proxied_request' => [
'help' => 'Response time of example.com via proxy in seconds',
'type' => 'gauge',
'submetrics' => [
[
'http' => [
'url' => 'http://example.com',
'data' => 'responsetime',
'proxy' => 'http://your-proxy-server:8080',
],
],
],
],
'json_data_metric' => [
'help' => 'Value from JSON response of example.com',
'type' => 'gauge',
'submetrics' => [
[
'http' => [
'url' => 'http://example.com/api/data',
'data' => 'responsebody',
],
'jsonelem' => 'path.to.value', // Adjust the JSON path to the actual structure
],
],
],
];