mirror of
https://github.com/natelandau/ansible-homelab-config.git
synced 2025-11-19 10:23:40 -05:00
97 lines
4.4 KiB
Django/Jinja
97 lines
4.4 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
|
|
#[[inputs.netstat]] # Collect TCP connections state and UDP socket counts
|
|
|
|
|
|
{% if 'macs' not in group_names %}
|
|
[[inputs.nstat]] # Collects network metrics
|
|
{% endif %}
|
|
|
|
{% if 'pis' in group_names%}
|
|
[[inputs.ntpq]]
|
|
dns_lookup = false ## If false, add -n for ntpq command. Can reduce metric gather times.
|
|
{% endif %}
|
|
|
|
{% if 'opnsense' in group_names %}
|
|
[[inputs.ntpq]]
|
|
dns_lookup = false ## If false, add -n for ntpq command. Can reduce metric gather times.
|
|
[[inputs.wireguard]]
|
|
devices = ["wg0","wg1"]
|
|
[[inputs.pf]]
|
|
{% endif %}
|