Metricbeat module Apache error - error fetching data: HTTP error 404 in : 404 Not Found

Hi all

I having problems when trying to get metrics from my Apache installation running on a Centos 7 VM

Env:

ECK 2.6.1
1 ES Master Node 8.6.2 running on a single node K3S Kubernetes Cluster installed on Centos 7 Server
Kibana 8.6.2. running also in the K3S

1 Virtual Machine Server with Centos 7 Desktop in which I installed Metricbeat and FB 8.6.2 and I enabled the apache module in both beats.

Apache version:

httpd -v
Server version: Apache/2.4.6 (CentOS)

I have downloaded a PHP project app called 'loginsystem' and I placed it in '/var/www/html/loginsystem'. It works great and my Filesystem apache module gets documents filled with useful info and I get Filebeat Dashboards working great.

I use the PHP app by pointing in my navigator to http://192.168.0.205/loginsystem/
I use my Windows 10 that runs in my physical PC by pointing to the IP of the VM that hosts the Apache and the metricbeat

In FB all goes well but in metricbeat it is a different story...

I have activated the 'apache' module in metricbeat.
I have run the 'metricbeat setup -e' succesfully
When I check Kibana for the documents inserted by that metricbeat and that module, I only find documents with this message:

error fetching data: HTTP error 404 in : 404 Not Found
Nothing else.

My metricbeat.yaml looks like this:

# =========================== Modules configuration ============================

metricbeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

# ======================= Elasticsearch template setting =======================

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
  #_source.enabled: false


# ================================== General ===================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging

# ================================= Dashboards =================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here or by using the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

# =================================== Kibana ===================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "https://192.168.0.201:30344"
  ssl.verification_mode: "none"


  # Kibana Space ID
  # ID of the Kibana Space into which the dashboards should be loaded. By default,
  # the Default Space will be used.
  #space.id:
# =============================== Elastic Cloud ================================

# These settings simplify using Metricbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

# ================================== Outputs ===================================

# Configure what output to use when sending the data collected by the beat.

# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["192.168.0.201:30187"]

  # Protocol - either `http` (default) or `https`.
  protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  username: "elastic"
  password: "XXXXXXXXXXXXXXXXXX"
  ssl.verification_mode: "none"

# ------------------------------ Logstash Output -------------------------------
#output.logstash:
  # The Logstash hosts
  #hosts: ["localhost:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

# ================================= Processors =================================

# Configure processors to enhance or manipulate events generated by the beat.

processors:
  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~


# ================================== Logging ===================================

# Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publisher", "service".
#logging.selectors: ["*"]
# ============================= X-Pack Monitoring ==============================
# Metricbeat can export internal metrics to a central Elasticsearch monitoring
# cluster.  This requires xpack monitoring to be enabled in Elasticsearch.  The
# reporting is disabled by default.

# Set to true to enable the monitoring reporter.
#monitoring.enabled: false

# Sets the UUID of the Elasticsearch cluster under which monitoring data for this
# Metricbeat instance will appear in the Stack Monitoring UI. If output.elasticsearch
# is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch.
#monitoring.cluster_uuid:

# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well.
# Note that the settings should point to your Elasticsearch *monitoring* cluster.
# Any setting that is not set is automatically inherited from the Elasticsearch
# output configuration, so if you have the Elasticsearch output configured such
# that it is pointing to your Elasticsearch monitoring cluster, you can simply
# uncomment the following line.
#monitoring.elasticsearch:

# ============================== Instrumentation ===============================

# Instrumentation support for the metricbeat.
#instrumentation:
    # Set to true to enable instrumentation of metricbeat.
    #enabled: false

    # Environment in which metricbeat is running on (eg: staging, production, etc.)
    #environment: ""

    # APM Server hosts to report instrumentation results to.
    #hosts:
    #  - http://localhost:8200

    # API Key for the APM Server(s).
    # If api_key is set then secret_token will be ignored.
    #api_key:

    # Secret token for the APM Server(s).
    #secret_token:


# ================================= Migration ==================================

# This allows to enable 6.7 migration aliases
#migration.6_to_7.enabled: true


This is how my /etc/metricbeat/modules.d/apache.yml looks like:

- module: apache
  metricsets:
    - status
  period: 10s
  hosts: ["http://127.0.0.1"]
  #username: ""
  #password: ""

By last , I've got two logs in /var/log/metricbeat
metricbeat-20230913-1.ndjson

{"log.level":"info","@timestamp":"2023-09-13T21:56:06.880+0200","log.origin":{"file.name":"instance/beat.go","file.line":724},"message":"Home path: [/usr/share/metricbeat] Config path: [/etc/metricbeat] Data path: [/var/lib/metricbeat] Logs path: [/var/log/metricbeat]","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2023-09-13T21:56:06.880+0200","log.origin":{"file.name":"instance/beat.go","file.line":732},"message":"Beat ID: 0173ed71-fdb6-475c-8d53-14fcbda3cfda","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"warn","@timestamp":"2023-09-13T21:56:09.882+0200","log.logger":"add_cloud_metadata","log.origin":{"file.name":"add_cloud_metadata/provider_aws_ec2.go","file.line":81},"message":"read token request for getting IMDSv2 token returns empty: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers). No token in the metadata request will be used.","service.name":"metricbeat","ecs.version":"1.6.0"}

and
/var/log/metricbeat/metricbeat-20230913.ndjson

{"log.level":"info","@timestamp":"2023-09-13T18:44:02.370+0200","log.origin":{"file.name":"instance/beat.go","file.line":724},"message":"Home path: [/usr/share/metricbeat] Config path: [/etc/metricbeat] Data path: [/var/lib/metricbeat] Logs path: [/var/log/metricbeat]","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2023-09-13T18:44:02.371+0200","log.origin":{"file.name":"instance/beat.go","file.line":732},"message":"Beat ID: 0173ed71-fdb6-475c-8d53-14fcbda3cfda","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"warn","@timestamp":"2023-09-13T18:44:05.372+0200","log.logger":"add_cloud_metadata","log.origin":{"file.name":"add_cloud_metadata/provider_aws_ec2.go","file.line":81},"message":"read token request for getting IMDSv2 token returns empty: Put \"http://169.254.169.254/latest/api/token\": context deadline exceeded (Client.Timeout exceeded while awaiting headers). No token in the metadata request will be used.","service.name":"metricbeat","ecs.version":"1.6.0"}

Any idea about what could be wrong and causing those error messages?

After reading the log info, it does not seem very useful to me.

Thank you all in advance for reading and/or helping.

Carlos T.

Kindly refer to the documentation here and here

Apache integration scrapes the status data from the web page generated by the mod_status module.

To enable mod_status, you may follow the direction here

After enablement by configuration, please don't forget to restart apache.

1 Like

Sir.

You've been added today to my personal list of heroes.
Indeed, it works.

I've just edited the '/etc/httpd/conf/httpd.conf' and added the following lines:

<Location "/server-status">
    SetHandler server-status
    Require host example.com
</Location>

The only thing have in consideration is replacing 'example.com' by my localhost name where my Apache runs, as this is where the filebeat runs also.

Save -->
restart httpd
All good :slight_smile:
Ty Sir, have a nice weekend

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.