# Telegraf Configuration for Sensorgnome # 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] ## Environment variables can be used as tags, and throughout the config file ## These are set in /etc/default/telegraf sgid = "${SGID}" # Configuration for telegraf agent [agent] ## Default data collection interval for all inputs interval = "1m" ## Rounds collection interval to 'interval' ## ie, if interval="10s" then always collect on :00, :10, :20, etc. round_interval = true ## Telegraf will send metrics to outputs in batches of at most ## metric_batch_size metrics. ## This controls the size of writes that Telegraf sends to output plugins. metric_batch_size = 1000 ## Maximum number of unwritten metrics per output. Increasing this value ## allows for longer periods of output downtime without dropping metrics at the ## cost of higher maximum memory usage. metric_buffer_limit = 10000 ## Collection jitter is used to jitter the collection by a random amount. ## Each plugin will sleep for a random time within jitter before collecting. ## This can be used to avoid many plugins querying things like sysfs at the ## same time, which can have a measurable effect on the system. collection_jitter = "3s" ## Default flushing interval for all outputs. Maximum flush_interval will be ## flush_interval + flush_jitter flush_interval = "1m" ## Jitter the flush interval by a random amount. This is primarily to avoid ## large write spikes for users running a large number of telegraf instances. ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s flush_jitter = "30s" ## Collected metrics are rounded to the precision specified. Precision is ## specified as an interval with an integer + unit (e.g. 0s, 10ms, 2us, 4s). ## Valid time units are "ns", "us" (or "µs"), "ms", "s". precision = "1s" ## Log at debug level. # debug = false ## Log only error level messages. # quiet = false ## Override default hostname, if empty use os.Hostname() hostname = "" ## If set to true, do no set the "host" tag in the telegraf agent. omit_hostname = true ############################################################################### # OUTPUT PLUGINS # ############################################################################### # A plugin that can transmit metrics over HTTP [[outputs.http]] ## URL is the address to send metrics to url = "https://www.example.net/telegraf" ## Timeout for HTTP message # timeout = "5s" ## HTTP method, one of: "POST" or "PUT" # method = "POST" ## HTTP Basic Auth credentials username = "${SGID}" password = "${SGKEY}" ## Data format to output. ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md data_format = "json" json_timestamp_units = "1s" ## HTTP Content-Encoding for write request body, can be set to "gzip" to ## compress body or "identity" to apply no encoding. # content_encoding = "identity" ## MaxIdleConns controls the maximum number of idle (keep-alive) ## connections across all hosts. Zero means no limit. max_idle_conn = 1 ## Idle (keep-alive) connection timeout. ## Maximum amount of time before idle connection is closed. ## Zero means no limit. # idle_conn_timeout = 0 ## Optional list of statuscodes (<200 or >300) upon which requests should not be retried non_retryable_statuscodes = [409, 413] # Additional HTTP headers [outputs.http.headers] # Should be set manually to "application/json" for json data_format Content-Type = "application/json; charset=utf-8" ############################################################################### # INPUT PLUGINS # ############################################################################### # Read metrics about cpu usage [[inputs.cpu]] ## Whether to report per-cpu stats or not percpu = false ## Whether to report total system cpu stats or not totalcpu = true ## If true, collect raw CPU time metrics collect_cpu_time = false ## If true, compute and report the sum of all non-idle CPU states report_active = false ## If true and the info is available then add core_id and physical_id tags core_tags = false # Read metrics about disk usage by mount point [[inputs.disk]] ## By default stats will be gathered for all mount points. ## Set mount_points will restrict the stats to only the specified mount points. # mount_points = ["/"] ## Ignore mount points by filesystem type. ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] ## Ignore mount points by mount options. ## The 'mount' command reports options of all mounts in parathesis. ## Bind mounts can be ignored with the special 'bind' option. # ignore_mount_opts = [] # Read metrics about disk IO by device [[inputs.diskio]] ## By default, telegraf will gather stats for all devices including ## disk partitions. ## Setting devices will restrict the stats to the specified devices. # devices = ["sda", "sdb", "vd*"] # Get kernel statistics from /proc/stat #[[inputs.kernel]] # no configuration # Read metrics about memory usage [[inputs.mem]] fielddrop = ["huge_*", "high_*", "write*", "commit*"] # Get the number of processes and group them by status [[inputs.processes]] # Read metrics about swap memory usage [[inputs.swap]] # no configuration # Read metrics about system load & uptime [[inputs.system]] # no configuration # Get standard chrony metrics, requires chronyc executable. [[inputs.chrony]] ## If true, chronyc tries to perform a DNS lookup for the time server. # dns_lookup = false # # Query given DNS server and gives statistics # [[inputs.dns_query]] # ## servers to query # servers = ["8.8.8.8"] # # ## Network is the network protocol name. # # network = "udp" # # ## Domains or subdomains to query. # # domains = ["."] # # ## Query record type. # ## Possible values: A, AAAA, CNAME, MX, NS, PTR, TXT, SOA, SPF, SRV. # # record_type = "A" # # ## Dns server port. # # port = 53 # # ## Query timeout in seconds. # # timeout = 2 # # Returns ethtool statistics for given interfaces [[inputs.ethtool]] ## List of interfaces to pull metrics for # interface_include = ["eth0"] ## List of interfaces to ignore when pulling metrics. interface_exclude = ["wlan0", "ap0"] fieldpass = ["int*", "*x_bytes", "*x_packets", "*x_errors", "*x_unicast", "*x_multicast", "*x_broadcast"] # # Read metrics from one or more commands that can output to stdout # [[inputs.exec]] # ## Commands array # commands = [ # "/tmp/test.sh", # "/usr/bin/mycollector --foo=bar", # "/tmp/collect_*.sh" # ] # # ## Environment variables # ## Array of "key=value" pairs to pass as environment variables # ## e.g. "KEY=value", "USERNAME=John Doe", # ## "LD_LIBRARY_PATH=/opt/custom/lib64:/usr/local/libs" # # environment = [] # # ## Timeout for each command to complete. # timeout = "5s" # # ## measurement name suffix (for separating different commands) # name_suffix = "_mycollector" # # ## Data format to consume. # ## Each data format has its own unique set of configuration options, read # ## more about them here: # ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md # data_format = "influx" # # Read metrics from fail2ban. # [[inputs.fail2ban]] # ## Use sudo to run fail2ban-client # use_sudo = false # # Parse a complete file each interval # [[inputs.file]] # ## Files to parse each interval. Accept standard unix glob matching rules, # ## as well as ** to match recursive files and directories. # files = ["/tmp/metrics.out"] # # ## Character encoding to use when interpreting the file contents. Invalid # ## characters are replaced using the unicode replacement character. When set # ## to the empty string the data is not decoded to text. # ## ex: character_encoding = "utf-8" # ## character_encoding = "utf-16le" # ## character_encoding = "utf-16be" # ## character_encoding = "" # # character_encoding = "" # # ## Data format to consume. # ## Each data format has its own unique set of configuration options, read # ## more about them here: # ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md # data_format = "influx" # # # ## Name a tag containing the name of the file the data was parsed from. Leave empty # ## to disable. Cautious when file name variation is high, this can increase the cardinality # ## significantly. Read more about cardinality here: # ## https://docs.influxdata.com/influxdb/cloud/reference/glossary/#series-cardinality # # file_tag = "" # Count files in a directory [[inputs.filecount]] ## Directories to gather stats about. ## This accept standard unit glob matching rules, but with the addition of ## ** as a "super asterisk". ie: ## /var/log/** -> recursively find all directories in /var/log and count files in each directories ## /var/log/*/* -> find all directories with a parent dir in /var/log and count files in each directories ## /var/log -> count all files in /var/log and all of its subdirectories directories = ["/data/SGdata/*"] ## Only count files that match the name pattern. Defaults to "*". name = "*" ## Count files in subdirectories. Defaults to true. recursive = true ## Only count regular files. Defaults to true. regular_only = true ## Follow all symlinks while walking the directory tree. Defaults to false. follow_symlinks = false ## Only count files that are at least this size. If size is ## a negative number, only count files that are smaller than the ## absolute value of size. Acceptable units are B, KiB, MiB, KB, ... ## Without quotes and units, interpreted as size in bytes. size = "1B" ## Only count files that have not been touched for at least this ## duration. If mtime is negative, only count files that have been ## touched in this duration. Defaults to "0s". mtime = "0s" # Read stats about given file(s) [[inputs.filestat]] ## Files to gather stats about. ## These accept standard unix glob matching rules, but with the addition of ## ** as a "super asterisk". See https://github.com/gobwas/glob. files = ["/var/log/syslog", "/var/log/sg-control.log"] ## If true, read the entire file and calculate an md5 checksum. md5 = false # # Read formatted metrics from one or more HTTP endpoints # [[inputs.http]] # ## One or more URLs from which to read formatted metrics # urls = [ # "http://localhost/metrics" # ] # # ## HTTP method # # method = "GET" # # ## Optional HTTP headers # # headers = {"X-Special-Header" = "Special-Value"} # # ## HTTP entity-body to send with POST/PUT requests. # # body = "" # # ## HTTP Content-Encoding for write request body, can be set to "gzip" to # ## compress body or "identity" to apply no encoding. # # content_encoding = "identity" # # ## Optional file with Bearer token # ## file content is added as an Authorization header # # bearer_token = "/path/to/file" # # ## Optional HTTP Basic Auth Credentials # # username = "username" # # password = "pa$$word" # # ## OAuth2 Client Credentials. The options 'client_id', 'client_secret', and 'token_url' are required to use OAuth2. # # client_id = "clientid" # # client_secret = "secret" # # token_url = "https://indentityprovider/oauth2/v1/token" # # scopes = ["urn:opc:idm:__myscopes__"] # # ## HTTP Proxy support # # http_proxy_url = "" # # ## Optional TLS Config # # tls_ca = "/etc/telegraf/ca.pem" # # tls_cert = "/etc/telegraf/cert.pem" # # tls_key = "/etc/telegraf/key.pem" # ## Minimal TLS version to accept by the client # # tls_min_version = "TLS12" # ## Use TLS but skip chain & host verification # # insecure_skip_verify = false # # ## Optional Cookie authentication # # cookie_auth_url = "https://localhost/authMe" # # cookie_auth_method = "POST" # # cookie_auth_username = "username" # # cookie_auth_password = "pa$$word" # # cookie_auth_headers = { Content-Type = "application/json", X-MY-HEADER = "hello" } # # cookie_auth_body = '{"username": "user", "password": "pa$$word", "authenticate": "me"}' # ## cookie_auth_renewal not set or set to "0" will auth once and never renew the cookie # # cookie_auth_renewal = "5m" # # ## Amount of time allowed to complete the HTTP request # # timeout = "5s" # # ## List of success status codes # # success_status_codes = [200] # # ## Data format to consume. # ## Each data format has its own unique set of configuration options, read # ## more about them here: # ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md # # data_format = "influx" # # # HTTP/HTTPS request given an address a method and a timeout # [[inputs.http_response]] # ## List of urls to query. # # urls = ["http://localhost"] # # ## Set http_proxy. # ## Telegraf uses the system wide proxy settings if it's is not set. # # http_proxy = "http://localhost:8888" # # ## Set response_timeout (default 5 seconds) # # response_timeout = "5s" # # ## HTTP Request Method # # method = "GET" # # ## Whether to follow redirects from the server (defaults to false) # # follow_redirects = false # # ## Optional file with Bearer token # ## file content is added as an Authorization header # # bearer_token = "/path/to/file" # # ## Optional HTTP Basic Auth Credentials # # username = "username" # # password = "pa$$word" # # ## Optional HTTP Request Body # # body = ''' # # {'fake':'data'} # # ''' # # ## Optional name of the field that will contain the body of the response. # ## By default it is set to an empty String indicating that the body's # ## content won't be added # # response_body_field = '' # # ## Maximum allowed HTTP response body size in bytes. # ## 0 means to use the default of 32MiB. # ## If the response body size exceeds this limit a "body_read_error" will # ## be raised. # # response_body_max_size = "32MiB" # # ## Optional substring or regex match in body of the response (case sensitive) # # response_string_match = "\"service_status\": \"up\"" # # response_string_match = "ok" # # response_string_match = "\".*_status\".?:.?\"up\"" # # ## Expected response status code. # ## The status code of the response is compared to this value. If they match, # ## the field "response_status_code_match" will be 1, otherwise it will be 0. # ## If the expected status code is 0, the check is disabled and the field # ## won't be added. # # response_status_code = 0 # # ## 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 # ## Use the given name as the SNI server name on each URL # # tls_server_name = "" # # ## HTTP Request Headers (all values must be strings) # # [inputs.http_response.headers] # # Host = "github.com" # # ## Optional setting to map response http headers into tags # ## If the http header is not present on the request, no corresponding tag will # ## be added. If multiple instances of the http header are present, only the # ## first value will be used. # # http_header_tags = {"HTTP_HEADER" = "TAG_NAME"} # # ## Interface to use when dialing an address # # interface = "eth0" # Gather metrics about network interfaces [[inputs.net]] ## By default, telegraf gathers stats from any up interface (excluding loopback) ## Setting interfaces will tell it to gather these explicit interfaces, ## regardless of status. When specifying an interface, glob-style ## patterns are also supported. ## # interfaces = ["eth*", "enp0s[0-1]", "lo"] ## ## On linux systems telegraf also collects protocol stats. ## Setting ignore_protocol_stats to true will skip reporting of protocol metrics. ## ignore_protocol_stats = true ## # # Collect response time of a TCP or UDP connection # [[inputs.net_response]] # ## Protocol, must be "tcp" or "udp" # ## NOTE: because the "udp" protocol does not respond to requests, it requires # ## a send/expect string pair (see below). # protocol = "tcp" # ## Server address (default localhost) # address = "localhost:80" # # ## Set timeout # # timeout = "1s" # # ## Set read timeout (only used if expecting a response) # # read_timeout = "1s" # # ## The following options are required for UDP checks. For TCP, they are # ## optional. The plugin will send the given string to the server and then # ## expect to receive the given 'expect' string back. # ## string sent to the server # # send = "ssh" # ## expected string in answer # # expect = "ssh" # # ## Uncomment to remove deprecated fields; recommended for new deploys # # fielddrop = ["result_type", "string_found"] # # Read TCP metrics such as established, time wait and sockets counts. # [[inputs.netstat]] # # no configuration # Monitor process cpu and memory usage [[inputs.procstat]] ## PID file to monitor process # pid_file = "/var/run/nginx.pid" ## executable name (ie, pgrep ) # exe = "nginx" ## pattern as argument for pgrep (ie, pgrep -f ) # pattern = "nginx" ## user as argument for pgrep (ie, pgrep -u ) # user = "nginx" ## Systemd unit name, supports globs when include_systemd_children is set to true # systemd_unit = "sg-control.service" # include_systemd_children = true ## CGroup name or path, supports globs cgroup = "system.slice/sg-control.service" pid_finder = "native" fieldpass = ["cpu_time_*", "memory_*", "*_usage"] tagexclude = ["cgroup_full", "user"] [inputs.procstat.tagdrop] process_name = ["bash"] [[inputs.procstat]] cgroup = "system.slice/caddy.service" pid_finder = "native" fieldpass = ["cpu_time_*", "memory_*", "*_usage"] tagexclude = ["cgroup_full", "user"] # Gather indicators from established connections, using iproute2's ss command. [[inputs.socketstat]] ## ss can display information about tcp, udp, raw, unix, packet, dccp and sctp sockets ## Specify here the types you want to gather socket_types = [ "tcp", "udp" ] ## The default timeout of 1s for ss execution can be overridden here: # timeout = "1s" # Gather systemd units state [[inputs.systemd_units]] ## Set timeout for systemctl execution # timeout = "1s" ## Filter for a specific unit type, default is "service", other possible ## values are "socket", "target", "device", "mount", "automount", "swap", ## "timer", "path", "slice" and "scope ": unittype = "service" ## Filter for a specific pattern, default is "" (i.e. all), other possible ## values are valid pattern for systemctl, e.g. "a*" for all units with ## names starting with "a" pattern = "sg-* ssh caddy* chrony* dnsmasq* gestures* wifi* wpa* gps*" # Read metrics about temperature [[inputs.temp]] # no configuration # Monitor wifi signal strength and quality [[inputs.wireless]] ## Sets 'proc' directory path ## If not specified, then default is /proc # host_proc = "/proc" # Reads metrics from a SSL certificate [[inputs.x509_cert]] ## List certificate sources, support wildcard expands for files ## Prefix your entry with 'file://' if you intend to use relative paths sources = ["https://127.0.0.1:443"] ## Timeout for SSL connection # timeout = "5s" ## Pass a different name into the TLS request (Server Name Indication). ## This is synonymous with tls_server_name, and only one of the two ## options may be specified at one time. ## example: server_name = "myhost.example.org" server_name = "192-168-1-1.my.local-ip.co" taginclude = ["common_name", "serial_number", "sgid", "verification"] [inputs.x509_cert.tagpass] issuer_common_name = ["R3"] ############################################################################### # SERVICE INPUT PLUGINS # ############################################################################### # # Run executable as long-running input plugin # [[inputs.execd]] # ## One program to run as daemon. # ## NOTE: process and each argument should each be their own string # command = ["telegraf-smartctl", "-d", "/dev/sda"] # # ## Environment variables # ## Array of "key=value" pairs to pass as environment variables # ## e.g. "KEY=value", "USERNAME=John Doe", # ## "LD_LIBRARY_PATH=/opt/custom/lib64:/usr/local/libs" # # environment = [] # # ## Define how the process is signaled on each collection interval. # ## Valid values are: # ## "none" : Do not signal anything. (Recommended for service inputs) # ## The process must output metrics by itself. # ## "STDIN" : Send a newline on STDIN. (Recommended for gather inputs) # ## "SIGHUP" : Send a HUP signal. Not available on Windows. (not recommended) # ## "SIGUSR1" : Send a USR1 signal. Not available on Windows. # ## "SIGUSR2" : Send a USR2 signal. Not available on Windows. # signal = "none" # # ## Delay before the process is restarted after an unexpected termination # restart_delay = "10s" # # ## Data format to consume. # ## Each data format has its own unique set of configuration options, read # ## more about them here: # ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md # data_format = "influx" # # Parse the new lines appended to a file # [[inputs.tail]] # ## File names or a pattern to tail. # ## These accept standard unix glob matching rules, but with the addition of # ## ** as a "super asterisk". ie: # ## "/var/log/**.log" -> recursively find all .log files in /var/log # ## "/var/log/*/*.log" -> find all .log files with a parent dir in /var/log # ## "/var/log/apache.log" -> just tail the apache log file # ## "/var/log/log[!1-2]* -> tail files without 1-2 # ## "/var/log/log[^1-2]* -> identical behavior as above # ## See https://github.com/gobwas/glob for more examples # ## # files = ["/var/mymetrics.out"] # # ## Read file from beginning. # # from_beginning = false # # ## Whether file is a named pipe # # pipe = false # # ## Method used to watch for file updates. Can be either "inotify" or "poll". # # watch_method = "inotify" # # ## Maximum lines of the file to process that have not yet be written by the # ## output. For best throughput set based on the number of metrics on each # ## line and the size of the output's metric_batch_size. # # max_undelivered_lines = 1000 # # ## Character encoding to use when interpreting the file contents. Invalid # ## characters are replaced using the unicode replacement character. When set # ## to the empty string the data is not decoded to text. # ## ex: character_encoding = "utf-8" # ## character_encoding = "utf-16le" # ## character_encoding = "utf-16be" # ## character_encoding = "" # # character_encoding = "" # # ## Data format to consume. # ## Each data format has its own unique set of configuration options, read # ## more about them here: # ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md # data_format = "influx" # # ## Set the tag that will contain the path of the tailed file. If you don't want this tag, set it to an empty string. # # path_tag = "path" # # ## Filters to apply to files before generating metrics # ## "ansi_color" removes ANSI colors # # filters = [] # # ## multiline parser/codec # ## https://www.elastic.co/guide/en/logstash/2.4/plugins-filters-multiline.html # #[inputs.tail.multiline] # ## The pattern should be a regexp which matches what you believe to be an indicator that the field is part of an event consisting of multiple lines of log data. # #pattern = "^\s" # # ## The field's value must be previous or next and indicates the relation to the # ## multi-line event. # #match_which_line = "previous" # # ## The invert_match can be true or false (defaults to false). # ## If true, a message not matching the pattern will constitute a match of the multiline filter and the what will be applied. (vice-versa is also true) # #invert_match = false # # #After the specified timeout, this plugin sends the multiline event even if no new pattern is found to start a new event. The default is 5s. # #timeout = 5s