Skip to content

Commit

Permalink
Custom fpm metrics. Add metric exporter to local and deployment. (#669)
Browse files Browse the repository at this point in the history
* Local - add fpm exporter container.

* Add fpm exporter to our build & deployment

* Add lines to end of files.

* Add status endpoint to nginx - block at ingress level.

* Remove fpm-exporter

* Simplify by blocking by IP in server.conf.

* Update server.conf

* Add podmonitor to intranet-dev

* Add network policy for prometheus.
  • Loading branch information
EarthlingDavey authored Aug 14, 2024
1 parent c24fddc commit 5af392c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
docker image build -t $REGISTRY/$REPOSITORY:cron-$IMAGE_TAG \
--target build-cron .
# ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░
docker image push $REGISTRY/$REPOSITORY:fpm-$IMAGE_TAG
Expand Down
8 changes: 8 additions & 0 deletions deploy/config/local/nginx/server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,12 @@ server {
fastcgi_pass fpm;
}

# On local this can be accessed without restriction.
location = /status {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass fpm;
}

}
1 change: 1 addition & 0 deletions deploy/config/php-pool.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pm.min_spare_servers = 5;
pm.max_spare_servers = 20;
pm.max_requests = 500;
pm.max_children = 20;
pm.status_path = /status;

[global]
daemonize = no
Expand Down
12 changes: 12 additions & 0 deletions deploy/config/server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,16 @@ server {
fastcgi_pass fpm;
}

location = /status {
# Group 3 is set to the internal Cloud Platform IP range.
if ( $ip_group != 3 ) {
add_header Content-Type text/plain;
return 401;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass fpm;
}

}
1 change: 1 addition & 0 deletions deploy/development/deployment.tpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
image: ${ECR_URL}:${IMAGE_TAG_NGINX}
ports:
- containerPort: 8080
name: nginx-port
volumeMounts:
- name: uploads
mountPath: /var/www/html/public/app/uploads
Expand Down
16 changes: 16 additions & 0 deletions deploy/development/network-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: allow-prometheus-scraping
namespace: intranet-dev
spec:
podSelector:
matchLabels:
app: intranet-dev
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
component: monitoring
13 changes: 13 additions & 0 deletions deploy/development/pod-monitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: intranet-dev
namespace: intranet-dev
spec:
selector:
matchLabels:
app: intranet-dev
podMetricsEndpoints:
- port: nginx-port
path: "/status?openmetrics"
interval: 15s

0 comments on commit 5af392c

Please sign in to comment.