Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting started with Business Metrics in PHP applications

Getting started with Business Metrics in PHP applications

Measuring & gathering infrastructure metrics is easy nowadays thanks to free tools like prometheus, grafana and a whole lot of exporters for servers, databases, redis, docker and so on. For sure those metrics are important for the reliable operation of your systems, but do they tell you, if your business is successful?
With a few examples I want to show you how to measure & monitor business relevant values from within your application(s) by introducing you to different PHP libraries that help you accomplish transparency of success factors. In the end I will show you how to set up a dashboard and alerts that even your manager(s) like and understand.

Holger Woltersdorf
CIO - Head of FORTUNE SOLUTIONS at Fortuneglobe GmbH. About 12 years of developer and team-lead experience in mobile communication and fashion eCommerce industry. PHP developer for more than 16 years, Co-founder and chairman of the PHP USERGROUP DRESDEN e.V., avid meetup and conference speaker, core-developer of the open-source PHP framework "IceHawk", dedicated to multiple other PHP open-source projects.

- https://twitter.com/hollodotme
- https://github.com/hollodotme
- https://hollo.me

You can find the shown example project on GitHub:
- https://github.com/php-usergroup-dresden/business-metrics-for-starters

Talk was given at PHPUGMRN in Mannheim, Germany.

Holger Woltersdorf

June 27, 2019
Tweet

More Decks by Holger Woltersdorf

Other Decks in Technology

Transcript

  1. WHAT ARE METRICS? CONTINUOUSLY MEASURED VALUES 
 TO REFLECT THE

    CURRENT STATE OF A SYSTEM ▸ UP or DOWN ▸ CPU USAGE ▸ MEMORY USAGE ▸ LOAD ▸ QUERIES PER SECOND ▸ REQUESTS PER SECOND ▸ CACHE HIT RATE ▸ FREE DISC SPACE ▸ PAGE SPEED
  2. ▸ https://prometheus.io ▸ https://hub.docker.com/r/prom/prometheus prometheus: image: prom/prometheus:latest restart: 'on-failure' volumes:

    - ./prometheus.yml:/etc/prometheus/prometheus.yml - ./data:/prometheus command: - '"--config.file=/etc/prometheus/prometheus.yml' - '"--storage.tsdb.path=/prometheus' - '"--storage.tsdb.retention=32d' - '"--web.enable-lifecycle' global: scrape_interval: 15s scrape_timeout: 10s evaluation_interval: 15s scrape_configs: # Prometheus self-monitoring - job_name: prometheus metrics_path: /metrics scheme: http static_configs: - targets: - localhost:9090
  3. Databases Aerospike exporter ClickHouse exporter Consul exporter (official) Couchbase exporter

    CouchDB exporter ElasticSearch exporter EventStore exporter Memcached exporter (official) MongoDB exporter MSSQL server exporter MySQL server exporter (official) OpenTSDB Exporter Oracle DB Exporter PgBouncer exporter PostgreSQL exporter Presto exporter ProxySQL exporter RavenDB exporter Redis exporter RethinkDB exporter SQL exporter Tarantool metric library Twemproxy Hardware related apcupsd exporter BIG-IP exporter Collins exporter IBM Z HMC exporter IoT Edison exporter IPMI exporter knxd exporter Netgear Cable Modem Exporter Netgear Router exporter Node/system metrics exporter (official) NVIDIA GPU exporter ProSAFE exporter Ubiquiti UniFi exporter Issue trackers and continuous integration Bamboo exporter Bitbucket exporter Confluence exporter Jenkins exporter JIRA exporter Messaging systems Beanstalkd exporter EMQ exporter Gearman exporter IBM MQ exporter Kafka exporter NATS exporter NSQ exporter Mirth Connect exporter MQTT blackbox exporter RabbitMQ exporter RabbitMQ Management Plugin exporter Storage Ceph exporter Ceph RADOSGW exporter Gluster exporter Hadoop HDFS FSImage exporter Lustre exporter ScaleIO exporter HTTP Apache exporter HAProxy exporter (official) Nginx metric library Nginx VTS exporter Passenger exporter Squid exporter Tinyproxy exporter Varnish exporter WebDriver exporter APIs AWS ECS exporter AWS Health exporter AWS SQS exporter Cloudflare exporter DigitalOcean exporter Docker Cloud exporter Docker Hub exporter GitHub exporter InstaClustr exporter Mozilla Observatory exporter OpenWeatherMap exporter Pagespeed exporter Rancher exporter Speedtest exporter Logging Fluentd exporter Google's mtail log data extractor Grok exporter Other monitoring systems Akamai Cloudmonitor exporter Alibaba Cloudmonitor exporter AWS CloudWatch exporter (official) Azure Monitor exporter Cloud Foundry Firehose exporter Collectd exporter (official) Google Stackdriver exporter Graphite exporter (official) Heka dashboard exporter Heka exporter InfluxDB exporter (official) JavaMelody exporter JMX exporter (official) Munin exporter Nagios / Naemon exporter New Relic exporter NRPE exporter Osquery exporter OTC CloudEye exporter Pingdom exporter scollector exporter Sensu exporter SNMP exporter (official) StatsD exporter (official) Miscellaneous ACT Fibernet Exporter BIND exporter Blackbox exporter (official) BOSH exporter cAdvisor Cachet exporter ccache exporter Dovecot exporter Dnsmasq exporter eBPF exporter Ethereum Client exporter Hostapd Exporter JMeter plugin Kannel exporter Kemp LoadBalancer exporter Kibana Exporter kube-state-metrics Meteor JS web framework exporter Minecraft exporter module OpenStack exporter PHP-FPM exporter PowerDNS exporter Process exporter rTorrent exporter SABnzbd exporter Script exporter Shield exporter Smokeping prober SMTP/Maildir MDA blackbox prober SoftEther exporter Transmission exporter Unbound exporter Xen exporter https://prometheus.io/docs/instrumenting/exporters/
  4. Software exposing Prometheus metrics Some third-party software exposes metrics in

    the Prometheus format, so no separate exporters are needed: App Connect Enterprise Ballerina Ceph Collectd Concourse CRG Roller Derby Scoreboard (direct) Docker Daemon Doorman (direct) Envoy Etcd (direct) Flink FreeBSD Kernel Grafana JavaMelody Kong Kubernetes (direct) Linkerd mgmt MidoNet midonet-kubernetes (direct) Minio Netdata Pretix Quobyte (direct) RobustIRC ScyllaDB Skipper SkyDNS (direct) Telegraf Traefik VerneMQ Weave Flux https://prometheus.io/docs/instrumenting/exporters/
  5. WHAT ARE BUSINESS METRICS? CONTINUOUSLY MEASURED VALUES 
 TO REFLECT

    THE CURRENT 
 SUCCESS OF YOUR BUSINESS ▸ ARTICLES ONLINE ▸ ORDERS PER HOUR ▸ SALES VOLUME ▸ ITEMS SHIPPED IN SLA ▸ CONVERSION RATE ▸ STOCK TURN DEVELOPMENT ▸ CUSTOMER SATISFACTION ▸ COST PER OPERATION (CPO)
  6. ▸ COUNTERS (can only go up) orders_total 1234.000000 orders_total 1235.000000

    1559024925 orders_total{shop="My-Shop"} 999.000000 orders_total{shop="Your-Shop"} 235.000000 orders_total{shop="My-Shop"} 999.000000 1559024925 orders_total{shop="Your-Shop"} 236.000000 1559024925 average_order_value 140.250000 average_order_value 141.500000 1559024925 average_order_value{shop="My-Shop"} 123.450000 average_order_value{shop="Your-Shop"} 156.780000 average_order_value{shop="My-Shop"} 101.020000 1559024925 average_order_value{shop="Your-Shop"} 199.890000 1559024925 ▸ GAUGES (can go up and down)
  7. ▸ Type-hinting and description # TYPE orders_total counter # HELP

    orders_total Total number of placed orders orders_total 1234.000000 orders_total 1235.000000 1559024925 orders_total{shop="My-Shop"} 999.000000 orders_total{shop="Your-Shop"} 235.000000 orders_total{shop="My-Shop"} 999.000000 1559024925 orders_total{shop="Your-Shop"} 236.000000 1559024925
  8. YOUR APP COLLECT METRICS IN REDIS WHENEVER SOMETHING HAPPENS IN

    YOUR APP & FLUSH THEM AS SOON AS PROMETHEUS CALLED THE ENDPOINT METRICS ENDPOINT