forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update docs and add truncate to stream node
- Loading branch information
1 parent
0393f37
commit d1356c5
Showing
11 changed files
with
241 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# The hostname of this node. | ||
# Must be resolvable by any configured InfluxDB hosts. | ||
hostname = "localhost" | ||
# Directory for storing a small amount of metadata about the server. | ||
data_dir = "/var/lib/kapacitor" | ||
# Your Enterprise token. By using Enterprise you can | ||
# send all internal statistics to the Enterprise | ||
# endpoints which will store and report on the | ||
# activity of your instances. | ||
token = "" | ||
|
||
[http] | ||
# HTTP API Server for Kapacitor | ||
# This server is always on, | ||
# it servers both as a write endpoint | ||
# and as the API endpoint for all other | ||
# Kapacitor calls. | ||
bind-address = ":9092" | ||
auth-enabled = false | ||
log-enabled = true | ||
write-tracing = false | ||
pprof-enabled = false | ||
https-enabled = false | ||
https-certificate = "/etc/ssl/kapacitor.pem" | ||
|
||
|
||
[[udp]] | ||
# UDP input for the scores stream | ||
enabled = true | ||
bind-address = ":9100" | ||
database = "game" | ||
retention-policy = "default" | ||
|
||
|
||
[logging] | ||
# Destination for logs | ||
# Can be a path to a file or 'STDOUT', 'STDERR'. | ||
file = "/var/log/kapacitor/kapacitor.log" | ||
# Logging level can be one of: | ||
# DEBUG, INFO, WARN, ERROR, or OFF | ||
level = "INFO" | ||
|
||
[replay] | ||
# Where to store replay files, aka recordings. | ||
dir = "/var/lib/kapacitor/replay" | ||
|
||
[task] | ||
# Where to store the tasks database | ||
dir = "/var/lib/kapacitor/tasks" | ||
|
||
[influxdb] | ||
# Connect to an InfluxDB cluster | ||
# Kapacitor can subscribe, query and write to this cluster. | ||
# Using InfluxDB is not required and can be disabled. | ||
enabled = true | ||
urls = ["http://localhost:8086"] | ||
username = "" | ||
password = "" | ||
timeout = 0 | ||
[influxdb.subscriptions] | ||
# Set of databases and retention policies to subscribe to. | ||
# If empty will subscribe to all. | ||
# | ||
# Format | ||
# db_name = <list of retention policies> | ||
# | ||
# Example: | ||
# my_database = [ "default", "longterm" ] | ||
|
||
[smtp] | ||
# Configure an SMTP email server | ||
# Will use TLS and authentication if possible | ||
# Only necessary for sending emails from alerts. | ||
enabled = false | ||
host = "localhost" | ||
port = 25 | ||
username = "" | ||
password = "" | ||
# Close idle connections after timeout | ||
idle-timeout = "30s" | ||
|
||
[reporting] | ||
# Send anonymous usage statistics | ||
# every 12 hours to Enterprise. | ||
enabled = true | ||
enterprise-url = "https://enterprise.influxdata.com" | ||
# The interval at which to send all | ||
# internal statistics to Enterprise. | ||
# If no token is specified this | ||
# setting has no effect. | ||
stats-interval = "1m0s" | ||
|
||
################################## | ||
# Input Methods, same as InfluxDB | ||
# | ||
|
||
[collectd] | ||
enabled = false | ||
bind-address = ":25826" | ||
database = "collectd" | ||
retention-policy = "" | ||
batch-size = 1000 | ||
batch-pending = 5 | ||
batch-timeout = "10s" | ||
typesdb = "/usr/share/collectd/types.db" | ||
|
||
[opentsdb] | ||
enabled = false | ||
bind-address = ":4242" | ||
database = "opentsdb" | ||
retention-policy = "" | ||
consistency-level = "one" | ||
tls-enabled = false | ||
certificate = "/etc/ssl/influxdb.pem" | ||
batch-size = 1000 | ||
batch-pending = 5 | ||
batch-timeout = "1s" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# default options: can be overriden with corresponding arguments. | ||
host=${1-localhost} | ||
port=${2-9100} | ||
games=${3-10} | ||
players=${4-100} | ||
|
||
games=$(seq $games) | ||
players=$(seq $players) | ||
# Spam score updates over UDP | ||
while true | ||
do | ||
for game in $games | ||
do | ||
game="g$game" | ||
for player in $players | ||
do | ||
player="p$player" | ||
score=$(($RANDOM % 1000)) | ||
echo "scores,player=$player,game=$game value=$score" > /dev/udp/$host/$port | ||
done | ||
done | ||
sleep 0.1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Define a result that contains the most recent score per player. | ||
var topPlayerScores = stream | ||
.from('scores') | ||
// Get the most recent score for each player per game. | ||
// Not likely that a player is playing two games but just in case. | ||
.groupBy('game', 'player') | ||
.window() | ||
// keep a buffer of the last 11s of scores | ||
// just in case a player score hasn't updated in a while | ||
.period(11s) | ||
// Emit the current score per player every second. | ||
.every(1s) | ||
// Align the window boundaries to be on the second. | ||
.align() | ||
.mapReduce(influxql.last('value')) | ||
|
||
// Calculate the top 15 scores per game | ||
var topScores = topPlayerScores | ||
.groupBy('game') | ||
.mapReduce(influxql.top(15, 'last', 'player')) | ||
|
||
// Expose top scores over the HTTP API at the 'top_scores' endpoint. | ||
// Now your app can just request the top scores from Kapacitor | ||
// and always get the most recent result. | ||
// | ||
// http://localhost:9092/api/v1/top_scores/top_scores | ||
topScores | ||
.httpOut('top_scores') | ||
|
||
// Sample the top scores and keep a score once every 10s | ||
var topScoresSampled = topScores | ||
.sample(10s) | ||
|
||
// Store top fifteen player scores in InfluxDB. | ||
topScoresSampled | ||
.influxDBOut() | ||
.database('game') | ||
.measurement('top_scores') | ||
|
||
// Calculate the max and min of the top scores. | ||
var max = topScoresSampled | ||
.mapReduce(influxql.max('top')) | ||
var min = topScoresSampled | ||
.mapReduce(influxql.min('top')) | ||
|
||
// Join the max and min streams back together and calculate the gap. | ||
max.join(min) | ||
.as('max', 'min') | ||
// calculate the difference between the max and min scores. | ||
.eval(lambda: "max.max" - "min.min", lambda: "max.max", lambda: "min.min") | ||
.as('gap', 'topFirst', 'topLast') | ||
// store the fields: gap, topFirst, and topLast in InfluxDB. | ||
.influxDBOut() | ||
.database('game') | ||
.measurement('top_scores_gap') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters