Monitor your PHP application with logs, metrics, pings, and traces. Slides: https://speakerdeck.com/xeraa/monitor-your-php-application-with-the-elastic-stack
- Quick overview of what is running in Kibana's monitoring view.
- Metricbeat System:
- Show the [Metricbeat System] Overview dashboard in Kibana.
- Then switch to [Metricbeat System] Host overview and see the spike.
- Build a visualization with Time Series Visual Builder to find out what is going on:
system.memory.used.bytes
perbeat.name
andsystem.process.memory.rss.bytes
persystem.process.name
sorted by theSum of system.process.memory.rss.bytes
. - Enable the
disabled: yes
in the deploy_bad.yml playbook to avoid any hiccups during the demo. Show the annotation of the event in the visualization above (potentially come back to it at the end of the talk).
- Packetbeat: Let attendees hit the CMS with a few requests.
- Show the [Packetbeat] Overview and [Packetbeat] Flows.
- Explain why [Packetbeat] HTTP is empty.
- Show [Packetbeat] TLS Sessions and explain why this is one of the more important Packetbeat features.
- Filebeat modules:
- Show the [Filebeat Nginx] Overview and [Filebeat Nginx] Access and error logs dashboards.
- Show the [Filebeat MySQL] Overview dashboard.
- Show the [Filebeat System] SSH login attempts, [Filebeat System] Sudo commands, and [Filebeat System] Syslog dashboard dashboards.
- Show the [Osquery Result] Compliance pack dashboard.
- Run
./ab.sh
on the backend instance to get a more interesting view of the [Filebeat Nginx] Overview and [Packetbeat] MySQL performance dashboards. - Metricbeat modules:
- Show the [Metricbeat Nginx] Overview dashboard based on https://xeraa.wtf/server-status.
- Show the [Metricbeat MySQL] Overview dashboard.
- Build a Time Series Visual Builder visualization for https://xeraa.wtf/status: Sum of
php_fpm.pool.connections.accepted
(optionally the derivative of this value), sum ofphp_fpm.pool.connections.queued
, and sum ofphp_fpm_pool.process.active
on a different axis and as a bar. - Add annotations to the previous visualizations — they don't correlate in this example, but it is still handy to see.
- Filebeat: Collecting both /var/www/html/silverstripe/logs/silverstripe.log and /var/www/html/silverstripe/logs/silverstripe.json. Hit https://xeraa.wtf/error/, https://xeraa.wtf/error/server/, https://xeraa.wtf/error/client/, and https://xeraa.wtf/error/exception/ for different errors and find them in the logs. Also point out the cloud
meta.*
andhost.*
information. - Heartbeat: Run Heartbeat and show the Heartbeat HTTP monitoring dashboard in Kibana, then stop either nginx or php-fpm (different response code).
- Auditbeat: Show the dashboards for [Auditbeat Auditd] Overview and [Auditbeat File Integrity] Overview.
- Kibana Dashboard Mode: Point attendees to the Kibana instance to let them play around on their own.
- Make sure you have your AWS account set up, access key created, and added as environment variables in
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
. Protip: Use https://github.com/sorah/envchain to keep your environment variables safe. - Create the Elastic Cloud instance with the same version as specified in variables.yml's
elastic_version
, enable Kibana as well as the GeoIP & user agent plugins, and set the environment variables with the values forELASTICSEARCH_HOST
,ELASTICSEARCH_USER
,ELASTICSEARCH_PASSWORD
, as well asKIBANA_HOST
,KIBANA_ID
. - Change into the lightsail/ directory.
- Change the settings to a domain you have registered under Route53 in inventory, variables.tf, and variables.yml. Set the Hosted Zone for that domain and export the Zone ID under the environment variable
TF_VAR_zone_id
. If you haven't created the Hosted Zone yet, you should set it up in the AWS Console first and then set the environment variable. - If you haven't installed the AWS plugin for Terraform, get it with
terraform init
first. Then create the keypair, DNS settings, and instances withterraform apply
. - Open HTTPS (443) on the network configuration on all instances as well as MySQL (3306) and APM server (8200) on the backend one (waiting for this Terraform issue to automate that step).
- Apply the base configuration to all instances with
ansible-playbook configure_all.yml
. - Apply the instance specific configuration with
ansible-playbook configure_frontend.yml
andansible-playbook configure_backend.yml
. - Deploy the JAR with
ansible-playbook deploy_bad.yml
(Ansible is also building it) andansible-playbook deploy_frontend.yml
.
When you are done, remove the instances, DNS settings, and key with terraform destroy
.
- Switch to: metricbeat keystore create && metricbeat keystore add output.elasticsearch.password
- Change: Alerting example
- APM: https://github.com/frankkoornstra/elastic-apm-agent/releases (needs PHP 7.2)