Skip to content

Instantly share code, notes, and snippets.

@stuart-warren
stuart-warren / elastic-search-metrics.sh
Last active December 15, 2015 22:09
Examples of Elastic search commands to create indexes and input data
curl -XDELETE 'http://localhost:9200/metrics'
curl -XPUT 'http://localhost:9200/metrics/' -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"metricanalyser" : {
"type" : "custom",
@stuart-warren
stuart-warren / lineWithFocusChart-opentsdb.html
Last active December 16, 2015 01:19
Takes a URL to the ascii output of opentsdb and outputs json in a format easily used by the NVD3.js graph library (at least lineWithFocusChart) Will probably build on this to create a nicer frontend / dashboard NVD3 (http://nvd3.org/) - D3 js library OpenTSDB (http://opentsdb.net/) - Metric collection tool
<!DOCTYPE html>
<meta charset="utf-8">
<!-- this works from within the examples folder -->
<link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
<style>
body {
@stuart-warren
stuart-warren / jolokia2opentsdb.py
Last active December 16, 2015 08:18
Script to use with tcollector and OpenTSDB to grab metrics from a java process using jolokia.
#!/usr/bin/env python
#
# Script to use with tcollector and OpenTSDB
# to grab metrics from a java process using
# jolokia.
#
# Author: https://github.com/stuart-warren
#
#
# see:
CQL:
DESCRIBE KEYSPACE kairosdb ;
ALTER KEYSPACE kairosdb WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': 2, 'dc2': 2 };
Get metrics:
curl -XPOST 'http://localhost:8080/api/v1/datapoints/query' -d '
{
"metrics": [
@stuart-warren
stuart-warren / kairosdb-nvd3.html
Created April 23, 2013 18:29
Loads up data from local KairosDB instance and creates NVD3.js graphs. Updates every 30 seconds, best used with start_relative times. See https://github.com/stuart-warren/django-opentsdb and https://github.com/proofpoint/kairosdb
<!DOCTYPE html>
<meta charset="utf-8">
<link href="static/novus-nvd3-f74b4de/src/nv.d3.css" rel="stylesheet" type="text/css">
<style>
body {
overflow-y:scroll;
}
@stuart-warren
stuart-warren / apache2-logstash
Last active March 6, 2017 09:04
Apache2 logging config to output JSON in Logstash json_event format
# Create a log format called 'logstash_json' that emits, in json, the parts of an http
# request I care about. For more details on the features of the 'LogFormat'
# directive, see the apache docs:
# http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats
# http://cookbook.logstash.net/recipes/apache-json-logs/
LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@message\": \"%m %H %U%q %s\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"protocol\": \"%H\", \"referrer\": \"%{Referer}i\", \"user-agent\": \"%{User-agent}i\" } }" logstash_json
# Apache 2.4 adds sub-second precision logging
# http://httpd.apache.org/docs/2.4/mod/mod_log_config.html#formats
# LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S}t.%{msec_frac}t%{%z}t\", \"@message\": \"%m %H %U%q %s\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"protocol\": \"%H\", \"referrer\": \"%{Refer
@stuart-warren
stuart-warren / tomcat-mkdeb.sh
Last active July 1, 2022 13:03
Create deb of Tomcat installing into its own dir (to allow multiple versions) Uses fpm
#!/bin/bash -xe
#
# sudo gem install fpm
# sudo apt-get install curl
# # Put this script in a folder called tomcat-packaging
# ./mkdeb.sh 7.0.40
# ./mkdeb.sh 6.0.37
#
VERSION=$1
@stuart-warren
stuart-warren / capistrano-mkdeb.sh
Created June 3, 2013 14:27
Package up capistrano for ubuntu/debian using fpm
#!/bin/bash
#
# from https://github.com/jordansissel/fpm/wiki/ConvertingGems
mkdir -p /tmp/gems
gem install --no-ri --no-rdoc --install-dir /tmp/gems/ capistrano
cd /tmp
find /tmp/gems/cache -name '*.gem' | xargs -rn1 fpm -d ruby -d rubygems --prefix /var/lib/gems/1.8 -s gem -t deb
# upload debs to apt repo
sudo apt-get update
@stuart-warren
stuart-warren / indexer.config
Last active October 24, 2017 18:39
Log4j logging config to output JSON in Logstash json_event format or to use Socket appender
input {
log4j {
port => 56445
type => "log4j"
}
}
output {
@stuart-warren
stuart-warren / cql-mkdeb.sh
Last active December 19, 2015 02:29
Use FPM to create a deb for python-cql (Cassandra CQL 3 driver)
#!/bin/bash
APP='python-cql'
# VERSION=1.4.0 # I assume this is worked out itself?
ITERATION='1'
# -v $VERSION \
rm -f ${APP}_*_all.deb
fpm \
-n $APP \
--iteration ${ITERATION} \