Follow the steps in this recipe to create an alert when predicted sales exceed inventory:
- Log in to your Splunk server and select the Operational Intelligence application.
- Ensure that the time range picker is set to Last 60 Minutes, and type the following search in the Splunk search bar. Then, click on the magnifying glass icon or hit Enter:
index=main sourcetype=log4j earliest=-0d@d requestType=removeItem OR requestType=updateCart OR requestType=addItem [search index=main sourcetype=log4j requestType="checkout" earliest=-0d@d | fields orderId] | eval quantity=if(requestType="removeItem",-1,quantity) | stats sum(quantity) AS quantity by itemId, date_hour | stats avg(quantity) as salesRate, sum(quantity) as Sales by itemId ...