How can we generate alert is there is pattern mismatch

For CPU alert if it stays at X%, how to generate alerts if its value changes to Y%(up) or Z%(down), It would be useful to identify spikes it due to schedule task or malicious activity.