Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20211015 Telegraf - defaults - experimental branch - PR 3 of 3 #432

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .internal/templates/services/telegraf/buildFiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ RUN apt update && apt install -y rsync
# where IOTstack template files are stored
ENV IOTSTACK_DEFAULTS_DIR="iotstack_defaults"

# make a copy of the default config file
RUN mkdir -p /${IOTSTACK_DEFAULTS_DIR} && \
cp /etc/telegraf/telegraf.conf /${IOTSTACK_DEFAULTS_DIR}/
# copy template files to image
COPY ${IOTSTACK_DEFAULTS_DIR} /${IOTSTACK_DEFAULTS_DIR}

# 1. copy the default configuration file that ships with the image as
# a baseline reference for the user, and make it read-only.
# 2. strip comment lines and blank lines from the baseline reference to
# use as the starting point for the IOTstack default configuration.
# 3. edit the IOTstack default configuration to insert an appropriate
# URL for influxdb running in another container in the same stack.
ENV BASELINE_CONFIG=/${IOTSTACK_DEFAULTS_DIR}/telegraf-reference.conf
ENV IOTSTACK_CONFIG=/${IOTSTACK_DEFAULTS_DIR}/telegraf.conf
RUN cp /etc/telegraf/telegraf.conf ${BASELINE_CONFIG} && \
chmod 444 ${BASELINE_CONFIG} && \
grep -v -e "^[ ]*#" -e "^[ ]*$" ${BASELINE_CONFIG} >${IOTSTACK_CONFIG} && \
sed -i '/^\[\[outputs.influxdb\]\]/a\ \ urls = ["http://influxdb:8086"]' ${IOTSTACK_CONFIG}
ENV BASELINE_CONFIG=
ENV IOTSTACK_CONFIG=

# replace the docker entry-point script with a self-repairing version
ENV IOTSTACK_ENTRY_POINT="entrypoint.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Read metrics about docker containers
# Credit: @tablatronix
[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
gather_services = false
container_names = []
source_tag = false
container_name_include = []
container_name_exclude = []
timeout = "5s"
perdevice = false
total = true
docker_label_include = []
docker_label_exclude = []
tag_env = ["HEAP_SIZE"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Read metrics from MQTT topic(s)
# Credit: https://github.com/gcgarner/IOTstack/blob/master/.templates/telegraf/telegraf.conf
[[inputs.mqtt_consumer]]
servers = ["tcp://mosquitto:1883"]
topics = [
"telegraf/host01/cpu",
"telegraf/+/mem",
"sensors/#",
]
data_format = "json"
1 change: 1 addition & 0 deletions .internal/templates/services/telegraf/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ telegraf:
- "8125:8125/udp"
volumes:
- ./volumes/telegraf/:/etc/telegraf
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
- influxdb
- mosquitto
Expand Down