Metricbeat for MySQL fails - "missing required field accessing '0.queries'"


I'm setting up Metricbeats on Ubuntu 18.04 to track metrics for a MySQL database. Unfortunately, starting the agent fails with the following error:

May 02 11:08:07 ubuntu metricbeat[69057]: 2021-05-02T11:08:07.990+0530        ERROR        instance/beat.go:971        Exiting: 1 error: missing required field accessing '0.queries' (source:'/etc/metricbeat/modules.d/mysql.yml')

Here's what the MySQL config for Metricbeats looks like:

# Module: mysql
# Docs:

- module: mysql
    - status
    #- galera_status
    - performance
    - query
  period: 10s

  # Host DSN should be defined as "user:pass@tcp("
  # or "unix(/var/lib/mysql/mysql.sock)/",
  # or another DSN format supported by <>.
  # The username and password can either be set in the DSN or using the username
  # and password config options. Those specified in the DSN take precedence.
  hosts: ["root:password@tcp("]

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

  # Password of hosts. Empty by default.
  #password: secret

For the record, I'm using Metricbeat 7.12.1, with MySQL 5.7.33. So far I don't think there's anything iffy with the Elastic stack setup, because the same agent is also polling for metrics from MongoDB, Redis and RabbitMQ on the same machine. I believe the issue has been raised before too: Exiting: 1 error: missing required field accessing '0.queries' (source:'/etc/metricbeat/modules.d/mysql.yml'). Would love some tips here - thanks a ton!

Hello @rudimk .

The reason you are seeing the error is that you have enabled the query metricset, but did not define the custom queries you wanted to run, if you don't want to run custom metrics queries you can disable that metricset.

I also noticed that the documentation does not mention this, so we have opened a PR to update the documentation, for a configuration example please see this new PR:

Hi @Marius_Iversen! I disabled the query metricset and it ran just fine. Thanks ever so much! I suppose we can close this thread now :slight_smile:

1 Like

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