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 / 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 / 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 / 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
@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 / kapacitor-conf.snippet
Created December 2, 2016 14:20
Configure Slack integration for Kapacitor
[slack]
enabled = true
  url = “https://hooks.slack.com/services/<integration point>”
  channel = “#influx-alerts”
  username = “kapacitor”
  icon-emoji = “”
  global = false
  state-changes-only = false
@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 / influxdb-cli-walkthrough
Last active December 2, 2016 14:09
InfluxDB CLI Walk Through
##### connect
$ ./influxdb-cli.sh
Connected to http://localhost:8086 version 1.1.0
InfluxDB shell version: 1.1.0
##### help
> help
Usage:
 connect <host:port> connects to another node specified by host:port