influxdata / kapacitor

Open source framework for processing, monitoring, and alerting on time series data
MIT License
2.31k stars 492 forks source link

Add Previous state #1408

Open divgwd opened 7 years ago

divgwd commented 7 years ago

Hi, I wanted to if there is a way to get previous state in the alert node? meaning when I raise a critical alert for a certain system metric(say cpu usage) I get the level of the alert as 'CRITICAL' and if the usage comes down but still is high enough to raise a 'WARN' alert then I would want to know what the previous state was (in this case 'CRITICAL').Is there a way to know about the previous state?? Any help is appreciated! Thanks in advance!

nathanielc commented 7 years ago

@divgwd The previous state is actually maintained in the code but it is not exposed. It seems like a simple task to expose that field and let handlers use it when evaluating templates etc. PRs welcome.

divgwd commented 7 years ago

@nathanielc Hi, can you let me know how to compile the code once it's edited, am new to golang :)

sputnik13 commented 7 years ago

@divgwd there's a build.sh at the root of the repo

SamuelToh commented 7 years ago

@divgwd there is a guide on how to build and run the tests in CONTRIBUTION.MD file. See here.

fillest commented 6 years ago

Isn't it available in templates? I've tried {{.PreviousLevel}}->{{.Level}} but I get an error: alert2: template: message:1:2: executing \"message\" at <.PreviousLevel>: can't evaluate field PreviousLevel in type kapacitor.messageInfo

nixikanius commented 6 years ago

Hm. It looks like there is no support for the previous level in templates. Is it possible to add it?