Skip to content

Instantly share code, notes, and snippets.

View rantav's full-sized avatar
🎯
Focusing

Ran Tavory rantav

🎯
Focusing
View GitHub Profile
@rantav
rantav / cloudwatch-event-to-slack-lambda.md
Last active January 14, 2021 03:18
CloudWatch Events to Slack

Sends Cloudwatch Event notifications to Slack

What is this?

AWS have released a new featue called CloudWatch Events, which lets you configure events fired by cloudwatch and direct them to SNS, Lambda functions, etc. Here's the blog post

Motivational image:

Here's the motivational image:

Slack image

@rantav
rantav / AwsClientMetricsCollector.java
Created November 9, 2014 13:08
Collecting AWS client metrics into codahale metrics, in java
package ...;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.Request;
environment.servlets().addFilter("HttpErrorLoggerFilter", new HttpErrorLoggerFilter())
.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
@rantav
rantav / .gitconfig
Last active September 1, 2017 22:07
gitconfig
# Many goodies from here and all around http://stackoverflow.com/questions/267761/what-does-your-gitconfig-contain
[user]
name = Your Full Name
email = [email protected]
[github]
user = your-github-username
[color]
@rantav
rantav / riemann-dynamic-threshold.rb
Last active May 17, 2018 05:51
Example how to do dynamic threshold in riemann
vagrant@precise64:~$ irb
1.9.3-p484 :002 > require "riemann"
=> true
# Set the threshold for the service "load" for "precise64" to 1
1.9.3-p484 :016 > Riemann::Client.new << {service: "dynamic-threshold-load", host: "precise64", metric: 1.0, ttl: Float::INFINITY}
# Set the threshold for the service "load" for "precise64" to 0
1.9.3-p484 :015 > Riemann::Client.new << {service: "dynamic-threshold-load", host: "precise64", metric: 0, ttl: Float::INFINITY}
# Set the threshold to 10
1.9.3-p484 :017 > Riemann::Client.new << {service: "dynamic-threshold-load", host: "precise64", metric: 10, ttl: Float::INFINITY}
# Clear the threshold
@rantav
rantav / riemann-maintenance-mode.rb
Last active September 3, 2016 15:48
Riemann example how to check whether a host is in maintenance mode. And Ruby code to set/unset maintenance mode.
vagrant@precise64:~$ irb
1.9.3-p484 :002 > require "riemann"
=> true
# Activate maintenance-mode:
1.9.3-p484 :010 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: "active", ttl: Float::INFINITY}
=> nil
# Deactivate maintenance-mode:
1.9.3-p484 :011 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: nil, ttl: Float::INFINITY}
=> nil
2013-09-22 13:04:54,600 INFO [com.gigaspaces.start] -
==================================================
GigaSpaces ServiceGrid starting using command <com.gigaspaces.start.services="GSC">
Log created by <vagrant> on Sun Sep 22 13:04:54 CEST 2013
==================================================
2013-09-22 13:04:55,307 CONFIG [com.gigaspaces.start] - platformJARs
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/required/commons-logging-1.1.1.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/required/gs-runtime.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/platform/jee/activation-1.1.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/platform/jee/geronimo-j2ee-connector_1.5_spec-1.1.jar
2013-09-22 13:04:33,076 INFO [org.cloudifysource.shell.commands.AbstractGSCommand] - Setting security profile to "nonsecure".
2013-09-22 13:10:01,563 INFO [org.cloudifysource.dsl.internal.packaging.Packager] - packing folder /vagrant/ungit-centos/ungit
2013-09-22 13:10:01,627 INFO [org.cloudifysource.dsl.internal.packaging.Packager] - created /tmp/ServicePackage7548892133262075543.tmp/ungit.zip
2013-09-22 13:35:16,452 WARNING [org.cloudifysource.shell.commands.AbstractGSCommand] - Events polling task has expired on remote server side
2013-09-22 13:40:21,646 INFO [org.cloudifysource.dsl.internal.packaging.Packager] - packing folder /vagrant/ungit-centos/ungit
2013-09-22 13:40:21,872 INFO [org.cloudifysource.dsl.internal.packaging.Packager] - created /tmp/ServicePackage5358811144477606907.tmp/ungit.zip
2013-09-22 13:40:44,472 WARNING [org.cloudifysource.shell.commands.AbstractGSCommand] - Service default.ungit already installed
2013-09-22 13:41:59,786 INFO [org.cloudifysource.dsl.internal.packaging.Pack
2013-09-22 13:42:22,098 INFO [com.gigaspaces.start] -
==================================================
GigaSpaces ServiceGrid starting using command <com.gigaspaces.start.services="GSC">
Log created by <vagrant> on Sun Sep 22 13:42:22 CEST 2013
==================================================
2013-09-22 13:42:22,805 CONFIG [com.gigaspaces.start] - platformJARs
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/required/commons-logging-1.1.1.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/required/gs-runtime.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/platform/jee/activation-1.1.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/platform/jee/geronimo-j2ee-connector_1.5_spec-1.1.jar
2013-09-22 13:04:35,102 INFO [com.gigaspaces.start] -
==================================================
GigaSpaces ServiceGrid starting using command <com.gigaspaces.start.services="LH,GSM,GSA,ESM",gsa.global.lus,0,gsa.lus,0,gsa.gsc,0,gsa.global.gsm,0,gsa.gsm_lus,0,gsa.global.esm,0,gsa.esm,0>
Log created by <vagrant> on Sun Sep 22 13:04:35 CEST 2013
==================================================
2013-09-22 13:04:35,794 CONFIG [com.gigaspaces.start] - platformJARs
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/required/commons-logging-1.1.1.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/required/gs-runtime.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/platform/jee/activation-1.1.jar
file:/vagrant/gigaspaces-cloudify-2.6.1-ga/lib/platform/jee/geronimo-j2ee-connector_1.5_spec-1.1.jar