DEV Community

Beatriz Oliveira for WoMakersCode

Posted on

Como monitorar o Apache com o Metricbeat

O que é o Apache?

O Apache é um servidor web livre da Apache Software Foundation. Ele é um servidor do tipo HTTPD ( Hypertext Transfer Protocol Daemon). 

Segundo o site do Apache:

"O objetivo deste projeto é fornecer um servidor seguro, eficiente e extensível que forneça serviços HTTP em sincronia com os padrões HTTP atuais.

O Apache HTTP Server ("httpd") foi lançado em 1995 e tem sido o servidor da web mais popular na Internet desde abril de 1996. Ele comemorou seu 25º aniversário em fevereiro de 2020."

Como monitorar o Apache utilizando o Metricbeat?

Para começar esse lab, você precisará ter um ambiente com o Apache de preferência com a versão >= 2.2.31 e outro ambiente com o Elasticsearch e com o Kibana configurados.

Assim que você tiver esses pré requisitos, poderá começar a seguir os passos abaixo para configurar o Metricbeat para coletar os dados do Apache.

Para instalar o Metricbeat no host do Apache, siga os passos descritos abaixo.

  • Faça o download do Metricbeat nesse link.

  • Instale o Metricbeat:
    Windows: PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-metricbeat.ps1
    Linux: sudo rpm -vi metricbeat-7.10.1-x86_64.rpm

  • Acesse o arquivo de configuração do Metricbeat:
    Windows: C:\Program Files\Metricbeat\metricbeat.yml
    Linux: /etc/metricbeat/metricbeat.yml

  • Insira nele as informações de conexão com o Elasticsearch e com o Kibana:

output.elasticsearch:
  hosts: ["url_do_elasticsearch:9200"]
setup.kibana:
  host: ["url_do_kibana:5601"]
Enter fullscreen mode Exit fullscreen mode

Se você estiver usando o Metricbeat OSS insira as seguintes configurações no fim do arquivo metricbeat.yml:

setup.ilm.enabled: false
setup.pack.security.enabled: false
setup.xpack.graph.enabled: false
setup.xpack.watcher.enabled: false
setup.xpack.monitoring.enabled: false
setup.xpack.reporting.enabled: false
Enter fullscreen mode Exit fullscreen mode
  • Habilite e configure o módulo do Apache:

Windows: .\metricbeat.exe modules enable apache
Linux: sudo metricbeat modules enable apache

  • Para modificar as configurações do módulo, altere o arquivo apache.yml:

Windows: modules.d/apache.yml
Linux: /etc/metricbeat/modules.d/apache.yml

Por padrão, o arquivo vem com as seguintes informações:
metricbeat.modules:

- module: apache
  metricsets: ["status"]
  period: 10s
  enabled: true

  # Apache hosts
  hosts: ["http://127.0.0.1"]

  # Path to server status. Default server-status
  #server_status_path: "server-status"

  # Username of hosts.  Empty by default
  #username: username

  # Password of hosts. Empty by default
  #password: password
Enter fullscreen mode Exit fullscreen mode
  • Carregue os dashboards do módulo:

Windows: .\metricbeat.exe setup
Linux: sudo metricbeat setup

  • Inicie o serviço do Metricbeat:

Windows: Start-Service metricbeat
Linux: sudo service metricbeat start

Depois disso, você conseguirá ver os logs do seu ambiente no discover, além de ter dashboards com informações e métricas do estado do seu Apache.

Alt Text

Para obter mais informações, acesse a documentação oficial do módulo do Apache no site da Elastic.

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay