Skip to content

Instantly share code, notes, and snippets.

View zshamrock's full-sized avatar
:octocat:
Working

Aliaksandr Kazlou zshamrock

:octocat:
Working
View GitHub Profile
@zshamrock
zshamrock / docker-compose.yml
Last active March 20, 2017 13:23
TICK services docker compose
version: '2'
networks:
# create a network to share between TICK services, so they can connect to each other by specifying influxdb network name
influxdb:
services:
telegraf:
image: telegraf:1.1.2
container_name: telegraf1.1.2
@zshamrock
zshamrock / cpu_alert.tick
Last active December 16, 2016 16:18
CPU Alert TICK script
stream
// Select just the cpu measurement from our example database.
|from()
.measurement('cpu')
|alert()
.message('{{ .Level }}: CPU idle usage is above 80% threshold @ {{ index .Tags "host" }}')
.crit(lambda: "usage_idle" > 80)
// Whenever we get an alert write it to a file.
.log('/var/log/alerts.log')
@zshamrock
zshamrock / generate-conf.sh
Last active December 15, 2016 10:57
Generate default conf for TICK services
#!/usr/bin/env bash
. versions.sh
CONF_DIR=conf
TELEGRAF_CONF=${CONF_DIR}/telegraf.conf
INFLUXDB_CONF=${CONF_DIR}/influxdb.conf
CHRONOGRAF_CONF=${CONF_DIR}/chronograf.conf
KAPACITOR_CONF=${CONF_DIR}/kapacitor.conf
@zshamrock
zshamrock / influxdb-cli.sh
Last active December 15, 2016 10:56
InfluxDB CLI
#!/usr/bin/env bash
. versions.sh
docker run --rm --net=container:influxdb${INFLUXDB_VERSION} -it influxdb:${INFLUXDB_VERSION} influx -host localhost
@zshamrock
zshamrock / kapacitor-cli.sh
Last active December 15, 2016 10:55
Kapacitor CLI
#!/usr/bin/env bash
. versions.sh
docker run --rm --net=container:kapacitor${KAPACITOR_VERSION} \
-v $PWD/cli/kapacitor:/root -w=/root -it \
-v $PWD/cli/kapacitor/logs:/var/log \
kapacitor:${KAPACITOR_VERSION} bash -l
@zshamrock
zshamrock / versions.sh
Created December 15, 2016 10:54
TICK versions
#!/usr/bin/env bash
TELEGRAF_VERSION=1.1.2
INFLUXDB_VERSION=1.1.1
CHRONOGRAF_VERSION=1.1.0-beta2
KAPACITOR_VERSION=1.1.1
@zshamrock
zshamrock / telegraf-output-plugins-conf.snippet
Created December 2, 2016 14:34
Telegraf output plugins snippet
[[outputs.influxdb]]
## The full HTTP or UDP endpoint URL for your InfluxDB instance.
## Multiple urls can be specified as part of the same cluster,
## this means that only ONE of the urls will be written to each interval.
# urls = [“udp://localhost:8089”] # UDP endpoint example
urls = [“http://localhost:8086"] # required
## The target database for metrics (telegraf will create it if not exists).
database = “telegraf” # required
## Retention policy to write to. Empty string writes to the default rp.
retention_policy = “”
@zshamrock
zshamrock / telegraf-input-plugins-conf.snippet
Created December 2, 2016 14:33
Telegraf input plugins snippet
[[inputs.mongodb]]
servers = [“mongodb://<username>:<password>@mongo.dev.picnicinternational.com:27000/dev?authSource=admin”]
[[inputs.rabbitmq]]
url = “https://<node>.rmq.cloudamqp.com”
name = “dev-rabbitmq” # optional tag
username = “<username>”
password = “<password>”
## A list of nodes to pull metrics about. If not specified, metrics for
## all nodes are gathered.
nodes = [“rabbit@<node>-01”]
@zshamrock
zshamrock / kapacitor-cli-show-task
Created December 2, 2016 14:28
Kapacitor CLI show task
./kapacitor-cli.sh
root@kapacitor:~# kapacitor show cpu_alert
ID: cpu_alert
Error:
Template:
Type: stream
Status: enabled
Executing: true
Created: 02 Dec 16 07:15 UTC
Modified: 02 Dec 16 07:16 UTC
@zshamrock
zshamrock / kapacitor-cli-walkthrough
Created December 2, 2016 14:23
Define and enable Kapacitor task
./kapacitor-cli.sh 
root@kapacitor:~# kapacitor define cpu_alert -type stream -tick scripts/cpu_alert.tick -dbrp telegraf.autogen
root@kapacitor:~# kapacitor enable cpu_alert