Инструменты пользователя

Инструменты сайта


linux:metrics

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Предыдущая версия справа и слева Предыдущая версия
Следующая версия
Предыдущая версия
linux:metrics [2022/06/06 04:15]
admin
linux:metrics [2023/11/05 06:05] (текущий)
admin [Мониторинг ZFS]
Строка 10: Строка 10:
 <code bash>wget https://repos.influxdata.com/debian/pool/stable/t/telegraf/telegraf_1.19.1-1_amd64.deb # Debian <code bash>wget https://repos.influxdata.com/debian/pool/stable/t/telegraf/telegraf_1.19.1-1_amd64.deb # Debian
 wget https://repos.influxdata.com/centos/9/amd64/stable/telegraf-1.22.4-1.x86_64.rpm # CentOS wget https://repos.influxdata.com/centos/9/amd64/stable/telegraf-1.22.4-1.x86_64.rpm # CentOS
 +
 +   # Либо есть в тех же репозиториях что и influxdb
 +cat <<EOF | sudo tee /etc/yum.repos.d/influxdata.repo
 +[influxdata]
 +name = InfluxData Repository - Stable
 +baseurl = https://repos.influxdata.com/stable/\$basearch/main
 +enabled = 1
 +gpgcheck = 1
 +gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key
 +EOF
 +
 +dnf install telegraf
 </code> </code>
  
Строка 46: Строка 58:
  
 <code bash> <code bash>
-# Use 'telegraf -config telegraf.conf -test' to see what metrics a config 
-# file would generate. 
- 
-# Global tags can be specified here in key="value" format. 
 [global_tags] [global_tags]
-  # dc = "us-east-1" # will tag all metrics with dc=us-east-1 
-  # rack = "1a" 
- 
-# Configuration for telegraf agent 
 [agent] [agent]
-  ## Default data collection interval for all inputs 
   interval = "60s"   interval = "60s"
-  ## Rounds collection interval to 'interval' 
-  ## ie, if interval="10s" then always collect on :00, :10, :20, etc. 
   round_interval = true   round_interval = true
- 
-  ## Telegraf will cache metric_buffer_limit metrics for each output, and will 
-  ## flush this buffer on a successful write. 
   metric_buffer_limit = 1000   metric_buffer_limit = 1000
-  ## Flush the buffer whenever full, regardless of flush_interval. 
   flush_buffer_when_full = true   flush_buffer_when_full = true
- 
-  ## 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 = "0s"   collection_jitter = "0s"
- 
-  ## Default flushing interval for all outputs. You shouldn't set this below 
-  ## interval. Maximum flush_interval will be flush_interval + flush_jitter 
   flush_interval = "10s"   flush_interval = "10s"
-  ## 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 = "0s"   flush_jitter = "0s"
 + 
   ## Logging configuration:   ## Logging configuration:
-  ## Run telegraf in debug mode 
   debug = false   debug = false
-  ## Run telegraf in quiet mode 
   quiet = false   quiet = false
-  ## Specify the log file name. The empty string means to log to stdout. 
   logfile = "C:/Program Files/Telegraf/telegraf.log"   logfile = "C:/Program Files/Telegraf/telegraf.log"
- + 
-  ## Override default hostname, if empty use os.Hostname()+
   hostname = ""   hostname = ""
- +  
 + 
 ############################################################################### ###############################################################################
 #                                  OUTPUTS                                    # #                                  OUTPUTS                                    #
 ############################################################################### ###############################################################################
- + 
-# Configuration for influxdb server to send metrics to+
 [[outputs.influxdb]] [[outputs.influxdb]]
-  # The full HTTP or UDP endpoint URL for your InfluxDB instance. 
-  # Multiple urls can be specified but it is assumed that they are part of the same 
-  # cluster, this means that only ONE of the urls will be written to each interval. 
-  # urls = ["udp://localhost:8089"] # UDP endpoint example 
   urls = ["http://:8086"] # required   urls = ["http://:8086"] # required
-  # The target database for metrics (telegraf will create it if not exists) 
   database = "telegraf" # required   database = "telegraf" # required
-  # Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h". 
-  # note: using second precision greatly helps InfluxDB compression 
   precision = "s"   precision = "s"
   retention_policy = ""   retention_policy = ""
-  ## Write timeout (for the InfluxDB client), formatted as a string. 
-  ## If not provided, will default to 5s. 0s means no timeout (not recommended). 
   timeout = "10s"   timeout = "10s"
   username = ""   username = ""
   password = ""   password = ""
-  # Set the user agent for HTTP POSTs (can be useful for log differentiation) +
-  # user_agent = "telegraf" +
-  # Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes) +
-  # udp_payload = 512+
  
  
Строка 320: Строка 289:
  
  
-===== InfluxDB ===== +==== Мониторинг ZFS ====
-Платформа для создания и работы с приложениями временных рядов. (https://www.influxdata.com/)\\+
  
-==== Подготовка сервера ==== +<details> 
-Для БД временных рядов важна синхронизация времени, настраиваем временную зону и ставим службу синхронизации времени\\ +<summary>:!: Плагин для ZFS</summary> 
-*В каталоге /usr/share/zoneinfo список всех возможных вариантов временных зон +[[https://github.com/influxdata/telegraf/blob/master/plugins/inputs/zfs/README.md|Doc]]\\
-<code bash># \cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime</code> +
-<code bash># apt install chrony && sudo systemctl enable chrony</code>+
  
-Открываем файервол: +Добавялем в конфиг, собсна достаточно с параметрами по умолчанию\\ 
-<code bash># iptables -I INPUT 1 -p tcp --dport 8086 -j ACCEPT</code>+Данные берутся из "/proc/spl/kstat/zfs"\\ 
 +<code bash> 
 +[[inputs.zfs]]
  
 +</code>
 +</details>
  
-==== Установка ==== 
-Импортируем ключ: 
-<code bash># wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -</code> 
  
-Добавляем репо: +<details> 
-<code bash># echo "deb https://repos.influxdata.com/debian buster stable| sudo tee /etc/apt/sources.list.d/influxdb.list</code>+<summary>:!: Публикация в Prometheus </summary> 
 +[[https://github.com/influxdata/telegraf/blob/master/plugins/outputs/prometheus_client/README.md|Doc]]\\ 
 +По некоторым причинам удобнее метрики передавать (настраивать в графане) через прометеус\\ 
 +Есть модуль который публикует содержимое телеграфа в формате прометеуса, в веб-страницу\\ 
 +Добавляем блок "output" в конфиг:\\ 
 +<code bash> 
 +[[outputs.prometheus_client]] 
 +  listen = ":9273" 
 +  string_as_label = true 
 +  metric_version = 2 
 +</code
 +</details>
  
-Ставим: 
-<code bash># apt update && sudo apt install influxdb</code> 
  
  
  
-==== Управление ==== 
-По умолчанию вход открытый, включить надо в конфиге, в блоке "http", параметр - **auth-enabled = true # Set to true** 
  
-<code bash># influx 
  
-> CREATE USER admin WITH PASSWORD '<password>' WITH ALL PRIVILEGES +<details
-> SHOW USERS +<summary> </summary>
- +
-> GRANT [READ,WRITE,ALL] ON "<database_name>" TO "<username>" +
-> REVOKE [READ,WRITE,ALL] ON "<database_name>" FROM "<username>" +
-> GRANT ALL PRIVILEGES TO "<username>" +
-> REVOKE ALL PRIVILEGES FROM "<username>" +
-> SHOW GRANTS FOR "<user_name>" +
-> SET PASSWORD FOR "<username>" = '<password>' +
-> DROP USER "<username>" +
->  +
-> CREATE DATABASE +
-> DROP DATABASE +
-> DROP SERIES +
-> DROP MEASUREMENT +
-> CREATE RETENTION POLICY +
-> ALTER RETENTION POLICY +
-> DROP RETENTION POLICY +
-> CREATE CONTINUOUS QUERY +
-> DROP CONTINUOUS QUERY +
->+
  
 +<code bash>
  
 </code> </code>
 +</details>
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
  
-====  ==== 
-<code bash># </code> 
  
linux/metrics.1654488938.txt.gz · Последнее изменение: 2022/06/06 04:15 — admin