Instalación Grafana · 8 min read · Dec 08, 2025

Cómo instalar la herramienta de monitoreo Grafana 8 en Debian 11

Grafana es una herramienta de visualización de datos gratuita y de código abierto que se utiliza para monitorear métricas de otros hosts. Está escrita en Typescript y Go y te permite crear y editar gráficos de registros y datos, así como crear métricas. Puede generar gráficos y paneles a partir de una base de datos de series temporales, incluyendo Graphite, InfluxDB o OpenTSDB, y te permite compartirlos con otros usuarios.

Características

  • Plantillas de panel
  • Anotaciones de aprovisionamiento
  • Modo quiosco y listas de reproducción
  • Plugins personalizados
  • Alertas y ganchos de alerta

En esta publicación, te mostraremos cómo instalar Grafana 8 en Debian 11.

Requisitos previos

  • Un servidor que ejecute Debian 11.
  • Un nombre de dominio válido apuntado a la IP de tu servidor.
  • Una contraseña de root configurada en el servidor.

Comenzando

Antes de comenzar, se recomienda actualizar tu sistema a la versión más reciente. Puedes actualizar todos los paquetes usando el siguiente comando:

apt-get update -y

Después de actualizar todos los paquetes, instala otras dependencias requeridas usando el siguiente comando:

apt-get install gnupg2 curl wget git software-properties-common -y

Una vez que todos los paquetes estén instalados, puedes proceder al siguiente paso.

Instalar Grafana 8

Por defecto, Grafana no está incluido en el repositorio predeterminado de Debian 11. Por lo tanto, necesitarás agregar el repositorio de Grafana al APT. Puedes agregarlo usando el siguiente comando:

curl https://packages.grafana.com/gpg.key | apt-key add -  
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

Una vez que el repositorio esté agregado, actualiza la caché del repositorio e instala Grafana usando el siguiente comando:

apt-get update -y  
apt-get install grafana -y

Una vez que Grafana esté instalado, inicia y habilita el servicio de Grafana usando el siguiente comando:

systemctl start grafana-server  
systemctl enable grafana-server

También puedes verificar el estado del servicio de Grafana con el siguiente comando:

systemctl status grafana-server

Obtendrás la siguiente salida:

? grafana-server.service - Instancia de Grafana
     Loaded: loaded (/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-02-04 04:08:25 UTC; 5s ago
       Docs: http://docs.grafana.org
   Main PID: 8602 (grafana-server)
      Tasks: 9 (limit: 2341)
     Memory: 29.6M
        CPU: 1.299s
     CGroup: /system.slice/grafana-server.service
             ??8602 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/run/grafana/grafana-server.pid --packaging=deb cfg:>

Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="migrations completed" logger=migrator performed=381 s>
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="Created default admin" logger=sqlstore user=admin
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="Created default organization" logger=sqlstore
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="Initialising plugins" logger=plugin.manager
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="Plugin registered" logger=plugin.manager pluginId=inp>
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="Live Push Gateway initialization" logger=live.push_ht>
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="Writing PID file" logger=server path=/run/grafana/gra>
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="HTTP Server Listen" logger=http.server address=[::]:3>
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="warming cache for startup" logger=ngalert
Feb 04 04:08:27 debian11 grafana-server[8602]: t=2022-02-04T04:08:27+0000 lvl=info msg="starting MultiOrg Alertmanager" logger=ngalert.multio>

Por defecto, Grafana escucha en el puerto 3000. Puedes verificarlo con el siguiente comando:

ss -antpl | grep 3000

Obtendrás la siguiente salida:

LISTEN 0      4096               *:3000            *:*    users:(("grafana-server",pid=8602,fd=8))               

Instalar Nginx como Proxy Inverso para Grafana

A continuación, necesitarás instalar y configurar Nginx como proxy inverso para Grafana. Primero, instala Nginx usando el siguiente comando:

apt-get install nginx -y

Una vez que Nginx esté instalado, crea un archivo de configuración de host virtual de Nginx con el siguiente comando:

nano /etc/nginx/conf.d/grafana.conf

Agrega las siguientes líneas:

server {
        server_name grafana.example.com;
        listen 80;
        access_log /var/log/nginx/grafana.log;

        location / {
                proxy_pass http://localhost:3000;
                proxy_set_header X-Forwarded-Host $host:$server_port;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

Guarda y cierra el archivo cuando termines. Luego, verifica Nginx en busca de errores de sintaxis con el siguiente comando:

ginx -t

Si todo está bien, obtendrás la siguiente salida:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

A continuación, reinicia Nginx para aplicar los cambios de configuración.

systemctl restart nginx

También puedes verificar el estado de Nginx con el siguiente comando:

systemctl status nginx

Obtendrás la siguiente salida:

? nginx.service - Un servidor web de alto rendimiento y un servidor proxy inverso
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-02-04 04:09:20 UTC; 4s ago
       Docs: man:nginx(8)
    Process: 8631 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 8632 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 8633 (nginx)
      Tasks: 2 (limit: 2341)
     Memory: 2.5M
        CPU: 35ms
     CGroup: /system.slice/nginx.service
             ??8633 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??8634 nginx: worker process

Feb 04 04:09:20 debian11 systemd[1]: Starting Un servidor web de alto rendimiento y un servidor proxy inverso...
Feb 04 04:09:20 debian11 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Feb 04 04:09:20 debian11 systemd[1]: Started Un servidor web de alto rendimiento y un servidor proxy inverso.

En este punto, Nginx está instalado y configurado como un proxy inverso para Grafana. Ahora puedes proceder al siguiente paso.

Acceder al Panel de Grafana

Ahora, abre tu navegador web y accede a la interfaz web de Grafana usando la URL http://grafana.example.com. Serás redirigido a la página de inicio de sesión de Grafana:

Inicio de sesión de Grafana

Proporciona tu nombre de usuario de administrador, contraseña y haz clic en el botón Iniciar sesión. Deberías ver la pantalla de restablecimiento de contraseña de Grafana:

Establecer una nueva contraseña

Establece tu nueva contraseña y haz clic en el botón Enviar. Deberías ver el panel de Grafana en la siguiente pantalla:

Panel de Grafana

Asegurar Grafana con Let’s Encrypt

A continuación, necesitarás instalar el paquete del cliente Certbot para instalar y gestionar el SSL de Let’s Encrypt.

Primero, instala Certbot con el siguiente comando:

apt-get install certbot python3-certbot-nginx -y

Una vez que la instalación esté terminada, ejecuta el siguiente comando para instalar el SSL de Let’s Encrypt en tu sitio web:

certbot --nginx -d grafana.example.com

Se te pedirá que proporciones una dirección de correo electrónico válida y aceptes los términos del servicio como se muestra a continuación:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for grafana.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/grafana.conf

A continuación, elige si deseas redirigir el tráfico HTTP a HTTPS como se muestra a continuación:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Escribe 2 y presiona Enter para finalizar la instalación. Deberías ver la siguiente salida:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/grafana.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://grafana.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=grafana.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/grafana.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/grafana.example.com/privkey.pem
   Your cert will expire on 2022-05-07. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Conclusión

¡Felicidades! has instalado con éxito Grafana 8 con Nginx y SSL de Let’s Encrypt en Debian 11. Ahora puedes agregar tus hosts remotos y comenzar a monitorearlos desde el panel de Grafana. No dudes en preguntarme si tienes alguna pregunta.

Share: X/Twitter LinkedIn

Recibe nuevas publicaciones en tu bandeja de entrada.

No spam. Cancela la suscripción en cualquier momento.