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

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


service:grafana

Различия

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

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

Предыдущая версия справа и слеваПредыдущая версия
Следующая версия
Предыдущая версия
service:grafana [26.02.2021 08:26] – [Grafana] viacheslavservice:grafana [17.08.2024 12:43] (текущий) – [Некоторые метрики] viacheslav
Строка 1: Строка 1:
 +====== Grafana ======
 +https://grafana.com\\
 +https://hub.docker.com/r/grafana/grafana/\\
 +https://grafana.com/docs/grafana/latest/administration/configure-docker/
 +
 +Конфиг - /etc/grafana/grafana.ini
 +
 +===== Некоторые метрики =====
 +
 +<code bash>
 +# CPU
 +node_load1
 +node_load5
 +node_load15
 +# CPU в процентах
 +100 - (avg(irate(node_cpu_seconds_total{mode="idle"}[30m])) * 100)
 +# RAM (MiB)
 +node_memory_MemFree_bytes / 1024 / 1024
 +node_memory_MemTotal_bytes / 1024 / 1024
 +# HDD (GiB)
 +node_filesystem_free_bytes{mountpoint="/"} / 1024 / 1024 / 1024
 +node_filesystem_size_bytes{mountpoint="/"} / 1024 / 1024 / 1024
 +# Disk usage (GiB)
 +node_disk_read_bytes_total{device="sda"} / 1024 / 1024 / 1024
 +node_disk_written_bytes_total{device="sda"} / 1024 / 1024 / 1024
 +# System (from docker metrics)
 +engine_daemon_engine_info
 +# Legend: {{os}} {{architecture}} ({{kernel}})
 +# Docker {{version}}
 +# Boot time (Datetime default)
 +node_boot_time_seconds * 1000
 +# Uptime (Duration d hh:mm:ss)
 +node_time_seconds - node_boot_time_seconds
 +# Pending updates
 +apt_upgrades_pending
 +# Reboot required (+ value mapping)
 +node_reboot_required
 +# Services
 +count(node_systemd_unit_state{state="active"}!=0)
 +count(node_systemd_unit_state{state="inactive"}!=0)
 +count(node_systemd_unit_state{state="failed"}!=0)
 +# Docker containers status
 +engine_daemon_container_states_containers{state="running"}
 +engine_daemon_container_states_containers{state="stopped"}
 +engine_daemon_container_states_containers{state="paused"}
 +# Network
 +node_network_receive_bytes_total{device="eth0"} / 1024 / 1024
 +node_network_transmit_bytes_total{device="eth0"} / 1024 / 1024
 +# Текущий трафик по всем интерфейсам (включая Докер, loopback и т. д.)
 +sum(irate(node_network_receive_bytes_total[1m]))
 +sum(irate(node_network_transmit_bytes_total[1m]))
 +# Более аккуратный вариант
 +sum(irate(node_network_receive_bytes_total{device=~"(wlp1s0|enp3s0)"}[1m]))
 +sum(irate(node_network_transmit_bytes_total{device=~"(wlp1s0|enp3s0)"}[1m]))
 +
 +# Выцепить несколько имён метрик
 +{__name__=~"metrics_containers_.*_cpu_percent"}
 +#metrics_containers_frigate_cpu_percent{instance="glances:9091", job="glances", src="glances"} 7.388715365239294
 +#metrics_containers_glances_cpu_percent{instance="glances:9091", job="glances", src="glances"} 0.6252216748768473
 +#metrics_containers_nc_cpu_percent{instance="glances:9091", job="glances", src="glances"} 0.0629145728643216
 +</code>
 +
 +===== Настройка за реверс-прокси =====
 +Мало настроить реверс-прокси, нужно Графане рассказать, как работать.
 +<code>
 +[server]
 +domain = example.com
 +root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
 +serve_from_sub_path = true
 +</code>
 +https://grafana.com/tutorials/run-grafana-behind-a-proxy/#1
 +
 +===== Общий доступ к панели =====
 +[[https://stackoverflow.com/questions/33111835/how-to-set-up-grafana-so-that-no-password-is-necessary-to-view-dashboards|How to set up Grafana so that no password is necessary to view dashboards]]
 +
 +https://grafana.com/docs/grafana/v7.5/auth/grafana/#anonymous-authentication
 +
 +===== Показать значения ярлыков внутри метрики =====
 +К примеру, есть метрика вида
 +  node_uname_info{domainname="(none)", instance="172.17.0.1:9100", job="host", machine="x86_64", nodename="user-xubuntuVM", release="5.4.0-65-generic", sysname="Linux", version="#73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021"} 1
 +Из неё нужно вытащить значение sysname и release.
 +
 +{{:service:pasted:20210225-094434.png}}
 +
 +Затем в правой колонке настроек выбрать
 +  * Visualization -> Stat
 +  * Display -> Text mode -> Name
 +  * Display -> Graph mode -> None
 +
 +https://stackoverflow.com/questions/38525891/how-do-i-write-a-prometheus-query-that-returns-the-value-of-a-label
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki