Skip to content

Instantly share code, notes, and snippets.

@nemo83
nemo83 / prometheus.yaml
Created August 17, 2017 05:33
[PromCon] Prometheus AWS plugin
- job_name: unlabelled_job
ec2_sd_configs:
- region: us-east-1
port: 9000
relabel_configs:
- source_labels: [__meta_ec2_tag_Name]
regex: (my-cool-api)
action: keep
@nemo83
nemo83 / disk-space-alerts.yaml
Created August 16, 2017 22:27
[PromCon] Disk Space alerts
# Alert if disk usage % greater than 80
disk_space_usage_pc=job:node_filesystem_used:pc{team="cerebro"}
ALERT disk_space_usage_pc_warning
IF disk_space_usage_pc > 80
FOR 5m
LABELS {
severity = "high"
}
ALERT disk_space_usage_pc_alert
@nemo83
nemo83 / Filters.scala
Created August 16, 2017 16:14
[PromCon] Prometheus Play Filters
import com.google.inject.{Inject, Singleton}
import org.lyranthe.prometheus.client._
class Filters @Inject()(prometheusFilter: PrometheusFilter) extends HttpFilters {
val filters = Seq(prometheusFilter)
}
@nemo83
nemo83 / PrometheusJmxInstrumentation.scala
Created August 16, 2017 15:28
[PromCon] Prometheus Jmx Instrumentation
import com.google.inject.{Inject, Singleton}
import org.lyranthe.prometheus.client._
@Singleton
class PrometheusJmxInstrumentation @Inject()()(implicit registry: Registry) {
jmx.register()
}
@nemo83
nemo83 / gist:fcc36fe785ec831cf62e35aa04e7ce55
Last active April 18, 2017 09:24 — forked from klovadis/gist:5170446
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v
@nemo83
nemo83 / Config.scala
Created November 16, 2015 17:35
Guice Module similar to Spring Configuration class.
package config
import akka.actor.ActorSystem
import com.example.driver.RedisClient
import com.google.inject.name.Named
import com.google.inject.{AbstractModule, Provides}
class Config extends AbstractModule {
override def configure(): Unit = {
@nemo83
nemo83 / MyRedisService.scala
Last active November 16, 2015 17:33
Perform Dependency Injection of Beans of the same type identified by name
package services
import com.example.driver.RedisClient
import com.google.inject.Inject
import com.google.inject.name.Named
class MyRedisService @Inject()(@Named("myDbOne") redisClientOne: RedisClient, @Named("myDbTwo") redisClientTwo: RedisClient) {
def doSomething = {
redisClientOne.doSomething
{
"type" : "object",
"properties" : {
"address" : {
"type" : "object",
"properties" : {
"addressLine2" : {
"type" : "string"
},
"addressLine1" : {
public class Address {
private String addressLine1;
private String addressLine2;
public String getAddressLine1() {
return addressLine1;
}
@Entity
@Table(name ="product")
public class Product {
private Integer id;
private String name;
private List<ProductItem> productItems =new LinkedList<ProductItem>();
public Product() {
}