catalogue-queries-top1-1h = topk(1, round(increase(request_duration_seconds_count{job="kubernetes-service-endpoints", kubernetes_name="front-end", kubernetes_namespace="sock-shop", method="get", name="front-end", route=~"/catalogue/.*-.*-.*-.*-.*", service="front-end", status_code="200"}[1h])))
catalogue-db = kube_service_info{namespace="sock-shop", service="catalogue-db"}
SockShop management decided that in order to increase income an advertising campaign should be launched. Each hour all customers will be sent a mail containing details about the most popular product in the company's catalogue. The management is hoping that will cause a snowball effect (the more people buy the more others are convinced that the product is worth buying). Some board members were not convinced that it'll be enough to bring the customers' attention. After discussing for a while everyone agreed that the product should be discounted.
To achieve this goal the catalogue-queries-top1-1h
metric has been created:
request_duration_seconds_count{...}[1h]
- counts requests for items during last hour, grouped by itemIdincrease
- the query from 1. accumulates result, but we're interested in its growthround
- mitigates the issues ofincrease
topk(1, ...)
- selects the top 1 value
The metric is used in the most-popular-this-hour
rule, which:
- Awaits for the aforementioned metric
- Checks the time constraint which will pass only once an hour
- Submits a
CreateSessionAction
that creates an HTTP session - Retrieves the product's details by making a GET request with the
HTTPSession
object returned by the previous action - Submits a
MySqlUpdateAction
that updates the product's price - Submits a
NotifyCustomersAction
SockShop management can observe products popularity trends on a Grafana dashboard