Skip to content

Instantly share code, notes, and snippets.

:octocat:
Working

Aliaksandr Kazlou zshamrock

View GitHub Profile
View versions.sh
#!/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
View telegraf-output-plugins-conf.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 = “”
View telegraf-input-plugins-conf.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 Mar 20, 2017
TICK services docker compose
View docker-compose.yml
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
View 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 Dec 2, 2016
Define and enable Kapacitor task
View kapacitor-cli-walkthrough
./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
View kapacitor-cli.sh
#!/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 Dec 2, 2016
Configure Slack integration for Kapacitor
View kapacitor-conf.snippet
[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 Dec 16, 2016
CPU Alert TICK script
View cpu_alert.tick
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 Dec 2, 2016
InfluxDB CLI Walk Through
View influxdb-cli-walkthrough
##### 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
You can’t perform that action at this time.