title: Auto scale rule based on custom Cloudwatch alarm
body: <p>I have an auto-scaling group of EC2 servers that run a number of processes.
  This number of processes changes with the load and I'd like to trigger a scaling (up/down) based on the number of processes.</p>
  <p>I've successfully set up a script that sends to Cloudwatch the number of processes on every servers, for every minutes, and I can see these on Cloudwatch. (I haven't set a dimension, to be able to get the value for all the servers).</p>
  <p>Then, I created an Alarm, that uses the average for the values sent, and if it reach a certain limit, it triggers the &quot;Add a new server&quot; to the auto scaling group, and when it stop being on alarm, it triggers a &quot;Remove a server&quot;.</p>
  <p>My issue is that when I add the new server, the average drops, since there is one more server now, which move the alarm to the ok state, removing the server, and increasing again the average, triggering again the alarm, etc.</p>
  <p>For instance, the limit is set to 10 processes on average. With 3 servers, if the average becomes 11, I trigger the alarm state, adding a server. Now with the new server, I'm at 33 processes (3 x 11) for 4 servers : 8,25 processes on average, thus triggering the &quot;OK&quot; alarm.</p>
  <p><strong>My question is</strong>: Is it possible to set up an alarm based on the number of processes without having the new trigger causes a up-down-up-down issue?</p>
  <p>Instead of average, I can use something else to trigger the alarm, such as min/max/I-don't-know.</p>
  <p>Thank you for your help. Happy to provide any other details if needed.</p>