Files
natelandau_ansible-homelab-…/templates/telegraf/synology.conf.j2
Nathaniel Landau 84958e0ef8 Initial commit
2022-02-05 16:22:33 -05:00

235 lines
10 KiB
Django/Jinja

# Telegraf Configuration
#
# Telegraf is entirely plugin driven. All metrics are gathered from the
# declared inputs, and sent to the declared outputs.
#
# Plugins must be declared in here to be active.
# To deactivate a plugin, comment out the name and any variables.
#
# Use 'telegraf -config telegraf.conf -test' to see what metrics a config
# file would generate.
#
# Environment variables can be used anywhere in this config file, simply surround
# them with ${}. For strings the variable must be within quotes (ie, "${STR_VAR}"),
# for numbers and booleans they should be plain (ie, ${INT_VAR}, ${BOOL_VAR})
# Global tags can be specified here in key="value" format.
[global_tags]
dc = "{{ datacenter_name }}"
ip = "{{ ansible_host }}"
# Configuration for telegraf agent
[agent]
interval = "10s" ## Default data collection interval for all inputs
round_interval = true ## ie, if interval="10s" then always collect on :00, :10, :20, etc.
metric_batch_size = 1000 ## Controls the size of writes that Telegraf sends to output plugins
metric_buffer_limit = 10000 ## Maximum number of unwritten metrics per output.
collection_jitter = "5s" ## Jitter the collection by a random amount.
flush_interval = "10s" ## Default flushing interval for all outputs.
flush_jitter = "5s" ## Jitter the flush interval by a random amount
precision = ""
debug = false ## Log at debug level.
# quiet = false ## Log only error level messages.
{% if 'pis' in group_names %}
logtarget = "file" ## destination logs can be one of "file" or "stderr"
logfile = "/var/log/telegraf/telegraf.log"
logfile_rotation_interval = "1d"
# logfile_rotation_max_size = "0MB"
logfile_rotation_max_archives = 2
{% elif 'macs' in group_names %}
logtarget = "stderr" ## destination logs can be one of "file" or "stderr"
{% endif %}
hostname = "{{ inventory_hostname }}" ## Override default hostname, if empty use os.Hostname()
omit_hostname = false ## If set to true, do no set the "host" tag in the telegraf agent.
###############################################################################
# OUTPUT PLUGINS #
###############################################################################
[[outputs.influxdb]]
urls = ["http://influxdb.service.consul:{{ influxdb_port }}"]
database = "homelab"
retention_policy = "2day"
timeout = "5s"
###############################################################################
# INPUT PLUGINS #
###############################################################################
[[inputs.cpu]] # Read metrics about cpu usage
percpu = true ## Whether to report per-cpu stats or not
totalcpu = true ## Whether to report total system cpu stats or not
collect_cpu_time = false ## If true, collect raw CPU time metrics.
report_active = false ## If true, compute and report the sum of all non-idle CPU states.
[[inputs.disk]] # Read metrics about disk usage by mount point
#mount_points = ["/mnt/usbDrive","/boot"] # Restrict the stats to only the specified mount points.
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs", "nfsd", "nfs4", "smbfs"]
[[inputs.diskio]] # Read metrics about disk IO by device
[[inputs.internal]] # Collect telegraf memory stats.
collect_memstats = true
[[inputs.mem]] # Read metrics about memory usage
[[inputs.processes]] # Get the number of processes and group them by status
[[inputs.swap]] # Read metrics about swap memory usage
[[inputs.system]] # Read metrics about system load & uptime
[[inputs.net]] # Gather metrics about network interfaces
###############################################################################
# PROCESSOR PLUGINS #
###############################################################################
[[processors.regex]]
namepass = ["docker_container_mem"]
# Tag and field conversions defined in a separate sub-tables
[[processors.regex.tags]]
## Tag to change
key = "container_name"
## Regular expression to match on a tag value
pattern = "^([a-zA-Z0-9_]+)-\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"
## Matches of the pattern will be replaced with this string. Use ${1}
## notation to use the text of the first submatch.
replacement = "${1}"
[[processors.regex]]
namepass = ["docker_container_net"]
# Tag and field conversions defined in a separate sub-tables
[[processors.regex.tags]]
## Tag to change
key = "container_name"
## Regular expression to match on a tag value
pattern = "^([a-zA-Z0-9_]+)-\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"
## Matches of the pattern will be replaced with this string. Use ${1}
## notation to use the text of the first submatch.
replacement = "${1}"
[[processors.regex]]
namepass = ["docker_container_cpu"]
# Tag and field conversions defined in a separate sub-tables
[[processors.regex.tags]]
## Tag to change
key = "container_name"
## Regular expression to match on a tag value
pattern = "^([a-zA-Z0-9_]+)-\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"
## Matches of the pattern will be replaced with this string. Use ${1}
## notation to use the text of the first submatch.
replacement = "${1}"
[[processors.regex]]
namepass = ["docker_container_blkio"]
# Tag and field conversions defined in a separate sub-tables
[[processors.regex.tags]]
## Tag to change
key = "container_name"
## Regular expression to match on a tag value
pattern = "^([a-zA-Z0-9_]+)-\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"
## Matches of the pattern will be replaced with this string. Use ${1}
## notation to use the text of the first submatch.
replacement = "${1}"
[[processors.regex]]
namepass = ["docker_container_health"]
# Tag and field conversions defined in a separate sub-tables
[[processors.regex.tags]]
## Tag to change
key = "container_name"
## Regular expression to match on a tag value
pattern = "^([a-zA-Z0-9_]+)-\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"
## Matches of the pattern will be replaced with this string. Use ${1}
## notation to use the text of the first submatch.
replacement = "${1}"
[[processors.regex]]
namepass = ["docker_container_status"]
# Tag and field conversions defined in a separate sub-tables
[[processors.regex.tags]]
## Tag to change
key = "container_name"
## Regular expression to match on a tag value
pattern = "^([a-zA-Z0-9_]+)-\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"
## Matches of the pattern will be replaced with this string. Use ${1}
## notation to use the text of the first submatch.
replacement = "${1}"
###############################################################################
# INPUT PLUGINS #
###############################################################################
[[inputs.docker]]
## Docker Endpoint
## To use TCP, set endpoint = "tcp://[ip]:[port]"
## To use environment variables (ie, docker-machine), set endpoint = "ENV"
endpoint = "unix:///var/run/docker.sock"
## Set to true to collect Swarm metrics(desired_replicas, running_replicas)
## Note: configure this in one of the manager nodes in a Swarm cluster.
## configuring in multiple Swarm managers results in duplication of metrics.
gather_services = false
## Only collect metrics for these containers. Values will be appended to
## container_name_include.
## Deprecated (1.4.0), use container_name_include
container_names = []
## Set the source tag for the metrics to the container ID hostname, eg first 12 chars
source_tag = false
## Containers to include and exclude. Collect all if empty. Globs accepted.
container_name_include = []
container_name_exclude = []
## Container states to include and exclude. Globs accepted.
## When empty only containers in the "running" state will be captured.
## example: container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"]
## example: container_state_exclude = ["created", "restarting", "running", "removing", "paused", "exited", "dead"]
# container_state_include = []
# container_state_exclude = []
## Timeout for docker list, info, and stats commands
timeout = "5s"
## Whether to report for each container per-device blkio (8:0, 8:1...),
## network (eth0, eth1, ...) and cpu (cpu0, cpu1, ...) stats or not.
## Usage of this setting is discouraged since it will be deprecated in favor of 'perdevice_include'.
## Default value is 'true' for backwards compatibility, please set it to 'false' so that 'perdevice_include' setting
## is honored.
perdevice = true
## Specifies for which classes a per-device metric should be issued
## Possible values are 'cpu' (cpu0, cpu1, ...), 'blkio' (8:0, 8:1, ...) and 'network' (eth0, eth1, ...)
## Please note that this setting has no effect if 'perdevice' is set to 'true'
# perdevice_include = ["cpu"]
## Whether to report for each container total blkio and network stats or not.
## Usage of this setting is discouraged since it will be deprecated in favor of 'total_include'.
## Default value is 'false' for backwards compatibility, please set it to 'true' so that 'total_include' setting
## is honored.
total = false
## Specifies for which classes a total metric should be issued. Total is an aggregated of the 'perdevice' values.
## Possible values are 'cpu', 'blkio' and 'network'
## Total 'cpu' is reported directly by Docker daemon, and 'network' and 'blkio' totals are aggregated by this plugin.
## Please note that this setting has no effect if 'total' is set to 'false'
# total_include = ["cpu", "blkio", "network"]
## docker labels to include and exclude as tags. Globs accepted.
## Note that an empty array for both will include all labels as tags
docker_label_include = []
docker_label_exclude = ["traefik.*"] # Do not report on Traefik tags
## Which environment variables should we use as a tag
tag_env = ["JAVA_HOME", "HEAP_SIZE"]
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false