# Run multiple queries to MySQL

**URL:** <https://discuss.elastic.co/t/run-multiple-queries-to-mysql/293154>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [December 29, 2021, 8:14pm UTC](https://discuss.elastic.co/t/run-multiple-queries-to-mysql/293154 "2021-12-29T20:14:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vPilot](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vPilot](https://discuss.elastic.co/u/vPilot)\
**Post date:** [December 29, 2021, 8:14pm UTC](https://discuss.elastic.co/t/run-multiple-queries-to-mysql/293154/1 "2021-12-29T20:14:28Z")

</div>

I have my mysql.yml file configured to run two separate queries for collecting both processlist details and replication details:

```auto
- module: mysql
  metricsets:
       - status
       - query
   queries:
        - query: "SHOW SLAVE STATUS"
          response_format: "table"
          query_namespace: "replication_check"
        - query: "SHOW PROCESSLIST"
          response_format: "table"
          query_namespace: "processlist"

```

However when I have the 2nd query configured and un-commented, it seems to overtake the first query and I get no results back from the `replication_check` namespace. Is there a specific way these need to be formatted so they both run at the same time?

---

<div class="post-metadata">

**Author:** ![Mario\_Castro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_castro/32/35107_2.png) [@Mario\_Castro](https://discuss.elastic.co/u/Mario_Castro)\
**Post date:** [January 12, 2022, 10:37am UTC](https://discuss.elastic.co/t/run-multiple-queries-to-mysql/293154/2 "2022-01-12T10:37:47Z")

</div>

Hi @vPilot 🙂

There's a limitation about the queries you can launch. You need to setup two configs for MySQL (no need of 2 processes).

You can take a look at the example in the SQL module [SQL module | Metricbeat Reference [7.16] | Elastic](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-sql.html#_example_launch_two_or_more_queries) which is what MySQL query metricset uses under the hood.

The docs for MySQL query metricset must be definitely updated.

---

<div class="post-metadata">

**Author:** ![vPilot](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vPilot](https://discuss.elastic.co/u/vPilot)\
**Post date:** [January 12, 2022, 4:12pm UTC](https://discuss.elastic.co/t/run-multiple-queries-to-mysql/293154/3 "2022-01-12T16:12:04Z")

</div>

After some poking and prodding, I was able to get it to work - it turns out that the way the query results were separating was causing some of my headache. So I had to do some additional adjustments when using Explore, as well as for my dashboards, and I was able to get it to work with the configuration I shared above.

Turns out it was mostly a user error 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 9, 2022, 6:12pm UTC](https://discuss.elastic.co/t/run-multiple-queries-to-mysql/293154/4 "2022-02-09T18:12:10Z")

</div>

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