Count of a value over time

Hi there.
I have a metric (gauge) that describes the state of my system, with few Integer values. I would like to count the number of times the value is 1 (for example) for the last 24 hours. This sounds awfully simple but I can’t get it… Any suggestion?