Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@dch
dch / gist:4148379
Created November 26, 2012 14:07 — forked from ajohnstone/gist:4148292
graphite internal performance
Carbon relay - performance
alias(color(sumSeries(group(carbon.agents.*.updateOperations)), "blue"),"Updates")
alias(color(sumSeries(group(carbon.agents.*.metricsReceived)), "green"), "Metrics Received")
alias(color(sumSeries(group(carbon.agents.*.committedPoints)),"orange"),"Committed Points"))
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.pointsPerUpdate)),"yellow")),"PPU")
alias(secondYAxis(color(averageSeries(group(carbon.agents.*.cpuUsage)),"red")),"CPU (avg)")
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.creates)),"purple")),"Creates")
Metrics received
carbon.agents.*.metricsReceived
@dch
dch / load_test.js
Created February 5, 2013 19:02 — forked from natevw/load_test.js
/*
ulimit -n 4096 -u 256; export ERL_MAX_PORTS=4096
node backend/_attachments/load_test.js
couchdb -d -p /tmp/couch.pid
rm /tmp/couch.* /tmp/*.couch
*/
var mc = require('multicouch'),
f = require('fermata'),
q = require('queue-async');
(graphite-server
:port 2002
:host "0.0.0.0"
:parser-fn (fn [{:keys [service] :as event}]
(if-let [[src host service & tags]
(clojure.string/split service #"\.")]
{:host (clojure.string/replace host #"_" ".")
:service (clojure.string/join "." (concat [service] tags))
:tags (concat tags ["graphite" src service])})))
var net = require("net");
var repl = require("repl");
net.createServer(function(socket){
var replserver = repl.start("prompt > ", socket);
// You must explicitly give the repl client access to variables via replserver.context variable.
// The following line is intended for educational purposes only. DO NOT USE in practice.
replserver.context = exports; // DANGER: This gives repl client access to ALL global variables of this program.
replserver.context.myvar = "stuff";
# This file defines regular expression patterns that can be used to
# rewrite metric names in a search & replace fashion. It consists of two
# sections, [pre] and [post]. The rules in the pre section are applied to
# metric names as soon as they are received. The post rules are applied
# after aggregation has taken place.
#
# The general form of each rule is as follows:
#
# regex-pattern = replacement-text
#
:repl-options {:port 10101 :host "0.0.0.0" }
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

; Expire old events from the index every 15 seconds.
(periodically-expire 10 {:keep-keys [:host :service :tags]})
(def rollup-ttl 60)
(def throttle-ttl 120)
(defn event-log [prefix]
(fn [e] (info prefix (str e))))
(def email (mailer {:from "riemann@domain"}))