Exposes a prometheus /metrics endpoint in your Laravel application, intended for use as a Kubernetes HPA driver.
saifh/laravel-phpfpm-prometheus-exporter is a Laravel package for exposes a prometheus /metrics endpoint in your laravel application, intended for use as a kubernetes hpa driver..
It currently has 3 GitHub stars and 7 downloads on Packagist (latest version 1.0.1).
Install it with composer require saifh/laravel-phpfpm-prometheus-exporter.
Discover more Laravel packages by saifh
or browse all Laravel packages to compare alternatives.
Last updated
This project exposes a Prometheus metrics endpoint in your Laravel application, based on FPM's current state.
It exposes 3 metrics:
This can be used in conjunction with Prometheus Adapter to give you new metrics to scale your application up and down with Kubernetes.
Publish the config file via
php artisan vendor:publish --tag=prometheus
to customize your configuration.
Given the following rule:
rules:
default: false
custom:
- seriesQuery: 'phpfpm_active_processes{namespace!="",pod_name!=""}'
resources:
overrides:
namespace:
resource: namespace
pod_name:
resource: pod
name:
matches: "phpfpm_active_processes"
as: "phpfpm_active_processes_utilization"
metricsQuery: avg(phpfpm_active_processes{<<.LabelMatchers>>} / phpfpm_total_processes{<<.LabelMatchers>>}) by (<<.GroupBy>>)
And the following Kubernetes HPA
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2
metadata:
name: php-fpm-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-fpm
# autoscale between 1 and 2 replicas
minReplicas: 1
maxReplicas: 2
metrics:
# use a "Pods" metric, which takes the average of the
# given metric across all pods controlled by the autoscaling target
- type: Pods
pods:
# use the metric that you used above: pods/http_requests
metric:
name: phpfpm_active_processes_utilization
#Value: 500m: Targets 50% utilization
target:
type: Value
averageValue: 500m
This will trigger a scale up when your average worker utilization hits 50%
Coming soon.
This project was heavily inspired by hipages/php-fpm_exporter.