Instalação Grafana · 9 min read · Dec 08, 2025

Como Instalar a Ferramenta de Monitoramento Grafana 8 no Debian 11

Grafana é uma ferramenta de visualização de dados gratuita e de código aberto que é usada para monitorar métricas de outros hosts. É escrita em Typescript e Go e permite que você crie e edite gráficos de log e dados e crie métricas. Ela pode gerar gráficos e painéis de um banco de dados de séries temporais, incluindo Graphite, InfluxDB ou OpenTSDB, e permite que você os compartilhe com outros usuários.

Recursos

  • Modelagem de painel
  • Anotações de provisionamento
  • Modo quiosque e listas de reprodução
  • Plugins personalizados
  • Alertas e ganchos de alerta

Neste post, mostraremos como instalar o Grafana 8 no Debian 11.

Pré-requisitos

  • Um servidor executando Debian 11.
  • Um nome de domínio válido apontado para o IP do seu servidor.
  • Uma senha de root configurada no servidor.

Começando

Antes de começar, é recomendável atualizar seu sistema para a versão mais recente. Você pode atualizar todos os pacotes usando o seguinte comando:

apt-get update -y

Após atualizar todos os pacotes, instale outras dependências necessárias usando o seguinte comando:

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

Uma vez que todos os pacotes estejam instalados, você pode prosseguir para a próxima etapa.

Instalar Grafana 8

Por padrão, o Grafana não está incluído no repositório padrão do Debian 11. Portanto, você precisará adicionar o repositório do Grafana ao APT. Você pode adicioná-lo usando o seguinte comando:

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

Uma vez que o repositório esteja adicionado, atualize o cache do repositório e instale o Grafana usando o seguinte comando:

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

Uma vez que o Grafana esteja instalado, inicie e habilite o serviço Grafana usando o seguinte comando:

systemctl start grafana-server  
systemctl enable grafana-server

Você também pode verificar o status do serviço Grafana com o seguinte comando:

systemctl status grafana-server

Você receberá a seguinte saída:

? grafana-server.service - Instância do 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 padrão, o Grafana escuta na porta 3000. Você pode verificar isso com o seguinte comando:

ss -antpl | grep 3000

Você receberá a seguinte saída:

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

Instalar Nginx como um Proxy Reverso para o Grafana

Em seguida, você precisará instalar e configurar o Nginx como um proxy reverso para o Grafana. Primeiro, instale o Nginx usando o seguinte comando:

apt-get install nginx -y

Uma vez que o Nginx esteja instalado, crie um arquivo de configuração de host virtual do Nginx com o seguinte comando:

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

Adicione as seguintes linhas:

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;
        }
}

Salve e feche o arquivo quando terminar. Em seguida, verifique o Nginx quanto a erros de sintaxe com o seguinte comando:

ginx -t

Se tudo estiver bem, você receberá a seguinte saída:

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

Em seguida, reinicie o Nginx para aplicar as alterações de configuração.

systemctl restart nginx

Você também pode verificar o status do Nginx com o seguinte comando:

systemctl status nginx

Você receberá a seguinte saída:

? nginx.service - Um servidor web de alto desempenho e um servidor proxy reverso
     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 Um servidor web de alto desempenho e um servidor proxy reverso...
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 Um servidor web de alto desempenho e um servidor proxy reverso.

Neste ponto, o Nginx está instalado e configurado como um proxy reverso para o Grafana. Você pode agora prosseguir para a próxima etapa.

Acessar o Painel do Grafana

Agora, abra seu navegador da web e acesse a interface da web do Grafana usando a URL http://grafana.example.com. Você será redirecionado para a página de login do Grafana:

Login do Grafana

Forneça seu nome de usuário de administrador, senha e clique no botão Entrar. Você deve ver a tela de redefinição de senha do Grafana:

Defina uma nova senha

Defina sua nova senha e clique no botão Enviar. Você deve ver o painel do Grafana na tela seguinte:

Painel do Grafana

Proteger o Grafana com Let’s Encrypt

Em seguida, você precisará instalar o pacote cliente Certbot para instalar e gerenciar o SSL Let’s Encrypt.

Primeiro, instale o Certbot com o seguinte comando:

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

Uma vez que a instalação esteja concluída, execute o seguinte comando para instalar o SSL Let’s Encrypt em seu site:

certbot --nginx -d grafana.example.com

Você será solicitado a fornecer um endereço de e-mail válido e aceitar os termos de serviço, conforme mostrado abaixo:

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

Em seguida, escolha se deseja ou não redirecionar o tráfego HTTP para HTTPS, conforme mostrado abaixo:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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

Digite 2 e pressione Enter para finalizar a instalação. Você deve ver a seguinte saída:

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.

Conclusão

Parabéns! você instalou com sucesso o Grafana 8 com Nginx e SSL Let’s Encrypt no Debian 11. Agora você pode adicionar seus hosts remotos e começar a monitorá-los a partir do painel do Grafana. Sinta-se à vontade para me perguntar se você tiver alguma dúvida.

Share: X/Twitter LinkedIn

Receba novas postagens na sua caixa de entrada

Sem spam. Cancele a assinatura a qualquer momento.