Observability is a good way to understand how your production application behaves under different traffic conditions. This guide explains what is available in Front-Commerce to expose this information to external tools.
Expose metrics for prometheus
Front-Commerce provides a /__front-commerce/metrics endpoint with data about
the node process and response times.
Configure it
To enable this endpoint, you need to define the environment variable
FRONT_COMMERCE_CLOUD_METRICS_KEY with a basic authentication token (base64
encoded, e.g. dXNlcjpwYXNzd29yZA== for user:password)
Access it
Call https://<your_website>/__front-commerce/metrics with the defined header
Authorization: Basic <FRONT_COMMERCE_CLOUD_METRICS_KEY>
Standard metrics
Front-Commerce is exposing some standard metrics about the node process like memory / CPU usage, please check OpenTelemetry Node.js SDK documentation for more information.
Other metrics
Measure external services call times
Once the /__front-commerce/metrics endpoint is enabled, you can count the time
spent calling external services.
Example with a magento backend service:
# TYPE outbound_requests_duration histogram
outbound_requests_duration_bucket{le="0.1",target="magento.location.net"} 0
outbound_requests_duration_bucket{le="0.25",target="magento.location.net"} 51
outbound_requests_duration_bucket{le="0.5",target="magento.location.net"} 58
outbound_requests_duration_bucket{le="1",target="magento.location.net"} 59
outbound_requests_duration_bucket{le="2",target="magento.location.net"} 74
outbound_requests_duration_bucket{le="+Inf",target="magento.location.net"} 75
outbound_requests_duration_sum{target="magento.location.net"} 31.227999999999998
outbound_requests_duration_count{target="magento.location.net"} 75
Count the dynamic routes held in memory
Dynamic routes (products, categories, CMS pages resolved through the dynamic route matcher) are injected into the Remix route tree as they are served, and kept under a least-recently-used bound:
# TYPE front_commerce_dynamic_routes gauge
front_commerce_dynamic_routes 342
# TYPE front_commerce_dynamic_routes_evictions gauge
front_commerce_dynamic_routes_evictions 0
Read them together. A gauge sitting at its maximum with a flat eviction count
just means the server has warmed up. A gauge at its maximum with a steadily
growing eviction count means the catalogue served is wider than the cache: every
new URL then drops another one and forces the route tree to be rebuilt, so
response times stay stable over time but higher than they need to be. Raise the
bound with FRONT_COMMERCE_SERVER_MAX_DYNAMIC_ROUTES (or
server.maxDynamicRoutes in front-commerce.config.ts) when that happens.