Diferència entre revisions de la pàgina «Grup 5 - 7 Monitorització del sistema Proxmox»

De Wiket
Salta a la navegació Salta a la cerca
Línia 3: Línia 3:
 
<div style="font-size: 130%">Instalación de InfluxDB</div>
 
<div style="font-size: 130%">Instalación de InfluxDB</div>
  
Instalamos InfluxDB con el comando:
+
Añadimos la key de InfluxDB a nuestro sistema:
  
 
<pre>wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null</pre>
 
<pre>wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null</pre>
 +
 +
Instalamos los repositorios:
 +
 +
<pre>export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
 +
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null</pre>
 +
 +
Update y install de InfluxDB
 +
 +
<pre>sudo apt-get update && sudo apt-get install influxdb2</pre>
 +
 +
Hacemos un start del servicio:
 +
 +
<pre>sudo systemctl start influxdb</pre>
 +
 +
Lo añadimos al inicio del sistema:
 +
 +
<pre>sudo systemctl enable influxdb</pre>
 +
 +
(Opcional)Añadimos el modo grafico de InfluxDB
 +
 +
<pre>sudo apt install -y influxdb2-cli</pre>
 +
 +
<div style="font-size: 130%">Instalación de Telegraf</div>
 +
 +
Añadimos el gpg de Telegraf y lo instalamos
 +
 +
<pre>wget -qO- https://repos.influxdata.com/influxdb.key | sudo tee /etc/apt/trusted.gpg.d/influxdb.asc >/dev/null
 +
source /etc/os-release
 +
echo "deb https://repos.influxdata.com/${ID} ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
 +
sudo apt-get update && sudo apt-get install telegraf</pre>
 +
 +
Comprobamos si Telegraf se ha instalado correctamente y está funcionando:
 +
 +
<pre>systemctl status telegraf</pre>
 +
 +
Ahora tenemos que ir al archivo de configuración de Telegraf y añadir lo siguiente:
 +
 +
- En el apartado url: la url del servidor InfluxDB (Si se está ejecutando en el mismo host, dejar por defecto)
 +
 +
- En el apartado token: añadir el token del administrador de Influxdb
 +
 +
- En bucket: añadir el contenedor donde irán los datos
 +
 +
- En organization: Añadir el nombre de la organización
 +
 +
En nuestro caso:
 +
 +
<pre># Configuration for sending metrics to InfluxDB
 +
[[outputs.influxdb_v2]]
 +
  ## The URLs of the InfluxDB cluster nodes.
 +
  ##
 +
  ## Multiple URLs can be specified for a single cluster, only ONE of the
 +
  ## urls will be written to each interval.
 +
  ##  ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
 +
  urls = ["http://localhost:8086"]
 +
 +
  ## Token for authentication.
 +
  token = "xxx"
 +
 +
  ## Organization is the name of the organization you wish to write to; must exist.
 +
  organization = "yyy"
 +
 +
  ## Destination bucket to write into.
 +
  bucket = "zzz"
 +
 +
  ## The value of this tag will be used to determine the bucket.  If this
 +
  ## tag is not set the 'bucket' option is used as the default.
 +
  # bucket_tag = ""
 +
 +
  ## If true, the bucket tag will not be added to the metric.
 +
  # exclude_bucket_tag = false
 +
 +
  ## Timeout for HTTP messages.
 +
  # timeout = "5s"
 +
 +
  ## Additional HTTP headers
 +
  # http_headers = {"X-Special-Header" = "Special-Value"}
 +
 +
  ## HTTP Proxy override, if unset values the standard proxy environment
 +
  ## variables are consulted to determine which proxy, if any, should be used.
 +
  # http_proxy = "http://corporate.proxy:3128"
 +
 +
  ## HTTP User-Agent
 +
  # user_agent = "telegraf"
 +
 +
  ## Content-Encoding for write request body, can be set to "gzip" to
 +
  ## compress body or "identity" to apply no encoding.
 +
  # content_encoding = "gzip"
 +
 +
  ## Enable or disable uint support for writing uints influxdb 2.0.
 +
  # influx_uint_support = false
 +
 +
  ## Optional TLS Config for use on HTTP connections.
 +
  # 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</pre>
 +
 +
 +
<div style="font-size: 130%">Instalación Grafana</div>
 +
 +
Instalación de la ultima versión Enterprise de Grafana:
 +
 +
<pre>sudo apt-get install -y apt-transport-https
 +
sudo apt-get install -y software-properties-common wget
 +
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -</pre>
 +
 +
Y ahora añadimos el repositorio de la versión estable
 +
 +
<pre>echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list</pre>
 +
 +
Tambén podemos añadir el repositorio de una versión beta pero no es recomendable
 +
 +
<pre>echo "deb https://packages.grafana.com/enterprise/deb beta main" | sudo tee -a /etc/apt/sources.list.d/grafana.list</pre>

Revisió del 16:35, 28 març 2022

Monitorización y Alertas
Instalación de InfluxDB

Añadimos la key de InfluxDB a nuestro sistema:

wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null

Instalamos los repositorios:

export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null

Update y install de InfluxDB

sudo apt-get update && sudo apt-get install influxdb2

Hacemos un start del servicio:

sudo systemctl start influxdb

Lo añadimos al inicio del sistema:

sudo systemctl enable influxdb

(Opcional)Añadimos el modo grafico de InfluxDB

sudo apt install -y influxdb2-cli
Instalación de Telegraf

Añadimos el gpg de Telegraf y lo instalamos

wget -qO- https://repos.influxdata.com/influxdb.key | sudo tee /etc/apt/trusted.gpg.d/influxdb.asc >/dev/null
source /etc/os-release
echo "deb https://repos.influxdata.com/${ID} ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install telegraf

Comprobamos si Telegraf se ha instalado correctamente y está funcionando:

systemctl status telegraf

Ahora tenemos que ir al archivo de configuración de Telegraf y añadir lo siguiente:

- En el apartado url: la url del servidor InfluxDB (Si se está ejecutando en el mismo host, dejar por defecto)

- En el apartado token: añadir el token del administrador de Influxdb

- En bucket: añadir el contenedor donde irán los datos

- En organization: Añadir el nombre de la organización

En nuestro caso:

# Configuration for sending metrics to InfluxDB
[[outputs.influxdb_v2]]
  ## The URLs of the InfluxDB cluster nodes.
  ##
  ## Multiple URLs can be specified for a single cluster, only ONE of the
  ## urls will be written to each interval.
  ##   ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
  urls = ["http://localhost:8086"]

  ## Token for authentication.
  token = "xxx"

  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "yyy"

  ## Destination bucket to write into.
  bucket = "zzz"

  ## The value of this tag will be used to determine the bucket.  If this
  ## tag is not set the 'bucket' option is used as the default.
  # bucket_tag = ""

  ## If true, the bucket tag will not be added to the metric.
  # exclude_bucket_tag = false

  ## Timeout for HTTP messages.
  # timeout = "5s"

  ## Additional HTTP headers
  # http_headers = {"X-Special-Header" = "Special-Value"}

  ## HTTP Proxy override, if unset values the standard proxy environment
  ## variables are consulted to determine which proxy, if any, should be used.
  # http_proxy = "http://corporate.proxy:3128"

  ## HTTP User-Agent
  # user_agent = "telegraf"

  ## Content-Encoding for write request body, can be set to "gzip" to
  ## compress body or "identity" to apply no encoding.
  # content_encoding = "gzip"

  ## Enable or disable uint support for writing uints influxdb 2.0.
  # influx_uint_support = false

  ## Optional TLS Config for use on HTTP connections.
  # 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


Instalación Grafana

Instalación de la ultima versión Enterprise de Grafana:

sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

Y ahora añadimos el repositorio de la versión estable

echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

Tambén podemos añadir el repositorio de una versión beta pero no es recomendable

echo "deb https://packages.grafana.com/enterprise/deb beta main" | sudo tee -a /etc/apt/sources.list.d/grafana.list