Skip to content

Instantly share code, notes, and snippets.

@jcooklin
Last active October 9, 2021 12:27
Show Gist options
  • Save jcooklin/5d81a20b852dec2c2e9250030bf7ba68 to your computer and use it in GitHub Desktop.
Save jcooklin/5d81a20b852dec2c2e9250030bf7ba68 to your computer and use it in GitHub Desktop.
relay-collectd-task

This compose file demonstrates the snap-relay, a stand-alone streaming plugin. The compose file will start a container for snap, the relay, collectd and influxdb. A short lived 'init' container is started which loads the plugins and starts the task.

This compose file makes the following assumptions.

---
version: 1
schedule:
type: "streaming"
workflow:
collect:
metrics:
/relay/collectd: {}
publish:
-
plugin_name: "influxdb"
config:
host: influxdb
port: 8086
database: "snap"
user: "admin"
password: "admin"
version: '3'
services:
snap:
container_name: snap
image: intelsdi/snap:alpine_test
volumes:
# Note: SNAP_PATH needs to be set and valid so that we can map the binaries
# into the container.
- ${SNAP_PATH}/linux/x86_64:/opt/snap/bin
- ${SNAP_PATH}/linux/x86_64:/opt/snap/sbin
ports:
- "8181:8181"
depends_on:
- collectd
- influxdb
- relay
links:
- relay
- influxdb
collectd:
container_name: collectd
image: revett/collectd
environment:
CONFIG_TYPE: graphite
EP_HOST: relay
EP_PORT: 6123
links:
- relay
depends_on:
- relay
influxdb:
container_name: influxdb
image: influxdb
ports:
- 8086:8086
- 8083:8083
relay:
container_name: relay
image: alpine
volumes:
# Note - please ensure the following:
# - That the path below is to the snap-relay
# - That the plugin has been built for Linux and that the binary exists at
# the top level of the project directory
- ${GVM_ROOT}/pkgsets/${gvm_go_name}/${gvm_pkgset_name}/src/github.com/intelsdi-x/snap-relay:/usr/local/bin
ports:
- 8182:8182
- 5801:5801
- 6123:6123
entrypoint:
- snap-relay
- --stand-alone
- --stand-alone-port
- "8182"
- --port
- "5801"
- --addr
- relay
- --graphite-tcp
- "relay:6123"
init:
container_name: init
image: alpine
volumes:
- ${SNAP_PATH}/linux/x86_64:/usr/local/bin
links:
- snap
- relay
- influxdb
entrypoint:
- /bin/ash
- -c
- "apk add --update curl; \
curl -i -XPOST http://influxdb:8086/query --data-urlencode \"q=CREATE DATABASE snap\"; \
curl -o /tmp/snap-plugin-publisher-influxdb http://snap.ci.snap-telemetry.io/plugins/snap-plugin-publisher-influxdb/latest/linux/x86_64/snap-plugin-publisher-influxdb; \
curl -o /tmp/collectd.yml https://gist.githubusercontent.com/jcooklin/5d81a20b852dec2c2e9250030bf7ba68/raw/56bd13b49fc4e3697c873f1602745501656ef216/collectd.yml; \
snaptel -u http://snap:8181 plugin load /tmp/snap-plugin-publisher-influxdb; \
snaptel -u http://snap:8181 plugin load http://relay:8182; \
snaptel -u http://snap:8181 task create -t /tmp/collectd.yml"
depends_on:
- snap
- relay
- influxdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment