# 'mage' is not recognized as an internal or external command

**URL:** <https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082>\
**Category:** Beats\
**Created:** [January 29, 2020, 10:21pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082 "2020-01-29T22:21:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [January 29, 2020, 10:21pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/1 "2020-01-29T22:21:57Z")

</div>

Hi all,

I am having an issue and hoping you have seen this previously.  
#Using Windows 10#  
I cloned the beats source code according to [https://www.elastic.co/guide/en/beats/devguide/current/beats-contributing.html](https://www.elastic.co/guide/en/beats/devguide/current/beats-contributing.html)  
When I run "make", the cmd showed 'mage' is not recognized as an internal or external command.  
Then I install mage according to [https://github.com/magefile/mage](https://github.com/magefile/mage)  
Howere, it still shows same error message.

Thanks.

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [January 29, 2020, 10:43pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/2 "2020-01-29T22:43:14Z")

</div>

Hello, thanks for reaching out. What errors are you getting after you run `mage`. If you do not pass any arguments to mage it should print out the available build targets.

Which version of Go are you using? If you're building beats for a particular branch, you may want to check the `.go-version` file in the top directory of the beats repo to ensure the versions match.

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [January 29, 2020, 11:02pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/3 "2020-01-29T23:02:16Z")

</div>

> [@Michael\_Madden](#):
>
> Which version of Go are you using? If you're building beats for a particular branch, you may want

Hi, I did not run `mage`. I am just working on the beginning part of setting up dev environment.  
The following is what I did in command line.

 ![mage](https://us1.discourse-cdn.com/elastic/original/3X/3/6/36d1a0324adf02be3c1fc09c2ec4f37131b7f509.png)

And the cmd shows:

> INFO: Could not find files for the given pattern(s).  
> 'mage' is not recognized as an internal or external command,  
> operable program or batch file.

Thanks for replying.

The version of GO is `1.13.7`

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [January 29, 2020, 11:42pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/4 "2020-01-29T23:42:26Z")

</div>

Hello, I ran into something similar when I tested this on my Windows 10 laptop. On Linux and macOS, mage is build from source if it's needed. I didn't see the same behavior on Windows.

I downloaded the latest release of mage for Windows from the mage GitHub page:

> **[magefile/mage](https://github.com/magefile/mage/releases)**
>
> a Make/rake-like build tool using Go. Contribute to magefile/mage development by creating an account on GitHub.

I extracted the zip file and added the path to `mage.exe` to my Windows PATH. After `mage.exe` is in your path you should be able to do something like this.

```auto
cd $GOPATH\src\github.com\elastic\beats\filebeat
mage build
dir filebeat.exe

```

Please let us know if installing mage helps.

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [January 30, 2020, 6:19pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/5 "2020-01-30T18:19:42Z")

</div>

Thanks for your instruction Michael. After following it, I run `make` again. The following is what my cmd shows. Is it right? And how can I use metricbeat **locally**? What command should I input to start it?  
I am pretty new here and asking a lot of details. Thanks for your patience.

 ![make](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3b5a444b809bc728b1477b4c97af8b6a63c8e264.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [January 30, 2020, 6:37pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/6 "2020-01-30T18:37:04Z")

</div>

Hello,

When `mage` is ran without any arguments, it outputs the available build targets.

To build metricbeat you can do something like this:

```auto
PS C:\Users\mjm> cd .\go\src\github.com\elastic\beats\metricbeat\                                                       
PS C:\Users\mjm\go\src\github.com\elastic\beats\metricbeat> mage build 2020/01/30 12:32:10 Found Elastic Beats dir at C:\Users\mjm\go\src\github.com\elastic\beats
>> build: Building metricbeat
PS C:\Users\mjm\go\src\github.com\elastic\beats\metricbeat> dir *.exe                                                   

    Directory: C:\Users\mjm\go\src\github.com\elastic\beats\metricbeat

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 1/30/2020 12:33 PM 64124928 metricbeat.exe

```

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [January 30, 2020, 7:01pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/7 "2020-01-30T19:01:19Z")

</div>

I run` mage build` first, and `matribeat -e` as well. However, the metricbeat stopped accidentally. I really do not know why. The following is what I got. Thanks for your help.

 ![metricbeat](https://us1.discourse-cdn.com/elastic/original/3X/2/c/2cbb031db3e4f78e3e381f153fad20836b4aeef9.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [January 30, 2020, 7:19pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/8 "2020-01-30T19:19:00Z")

</div>

I had similar results when I ran `metricbeat -e` on my Windows 10 laptop.

I think the following message is key. metricbeat may need to run as an administrator on Windows.

Can you try running `metricbeat -e` when PowerShell is running as Administrator?

> 2020-01-30T13:14:06.134-0600 WARN system/system\_windows.go:27 Metricbeat is running without SeDebugPrivilege, a Windows privilege that allows it to collect metrics from other processes. The user running Metricbeat may not have the appropriate privileges or the security policy disallows it.

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [January 30, 2020, 7:36pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/9 "2020-01-30T19:36:09Z")

</div>

> [@Michael\_Madden](#):
>
> `metricbeat -e`

I tried using Powershell as administrater, but still same error message showing up with `SeDebugPrivilege enabled`.

 ![admin](https://us1.discourse-cdn.com/elastic/original/3X/9/f/9ff4dfc637322b40cf391031da3523f125bb8ffb.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [January 30, 2020, 7:40pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/10 "2020-01-30T19:40:48Z")

</div>

I wonder if it would be helpful to verify that the released version of a beat (maybe `metricbeat`) works fine for you?

I'd try going through the following document which outlines setting up metricbeat 7.5.2.  
[https://www.elastic.co/guide/en/beats/metricbeat/7.5/metricbeat-getting-started.html](https://www.elastic.co/guide/en/beats/metricbeat/7.5/metricbeat-getting-started.html)

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [January 30, 2020, 8:51pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/11 "2020-01-30T20:51:49Z")

</div>

I also have Metricbeat 7.5.2 on my Windows and it works fine. Thanks a lot Michael. Hope you can get any luck! Looking forward to your update!

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [January 31, 2020, 6:37pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/12 "2020-01-31T18:37:11Z")

</div>

Hi, do you get any idea how to make the source code work? I am still stuck here. Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [February 4, 2020, 3:51pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/13 "2020-02-04T15:51:18Z")

</div>

I believe I have a solution for the issue we were running into earlier with mage not being found on Windows.

To have mage automatically built/installed, you can run `make.bat` from the top level of the beats checkout. This should give you the version of mage that we test beats with.

```auto
PS C:\Users\mjm> cd .\go\src\github.com\elastic\beats
PS C:\Users\mjm\go\src\github.com\elastic\beats> .\make.bat

```

Please ensure `%GOPATH%\bin` in in your `PATH` after running `make.bat`.

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [February 4, 2020, 4:22pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/14 "2020-02-04T16:22:22Z")

</div>

If you pull the latest updates from the beats repo, do you see this issue? When I'd tried this earlier I was not seeing the metricset 'system/load' not found message.

```
PS C:\Users\mjm\go\src\github.com\elastic\beats\metricbeat> mage build 2020/02/04 10:20:03 Found Elastic Beats dir at C:\Users\mjm\go\src\github.com\elastic\beats
>> build: Building metricbeat
PS C:\Users\mjm\go\src\github.com\elastic\beats\metricbeat> .\metricbeat.exe Exiting: 1 error: metricset 'system/load' not found
```

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [February 4, 2020, 5:03pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/15 "2020-02-04T17:03:12Z")

</div>

Since you're building metricbeat from the master branch on WIndows, there's an additional step to adjust `system.yml`.

You'll need to comment out the line `- load` in `modules.d/system.yml`. It should look like this:

```auto
- module: system
  period: 10s
  metricsets:
    - cpu
    #- load
    - memory
    - network
    - process
    - process_summary
    - socket_summary
    #- entropy
    #- core
    #- diskio
    #- socket
    #- services
  process.include_top_n:
    by_cpu: 5 # include top 5 processes by CPU
    by_memory: 5 # include top 5 processes by memory

```

After saving this update to `system.yml`, I was able to start metricbeat.

If you run into issues, please ensure you go through the steps to configure metricbeat.  
[https://www.elastic.co/guide/en/beats/metricbeat/master/metricbeat-configuration.html](https://www.elastic.co/guide/en/beats/metricbeat/master/metricbeat-configuration.html)

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [February 4, 2020, 5:54pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/16 "2020-02-04T17:54:19Z")

</div>

Hi Michael, thanks for your follow up. After I commented out `load`, I still cannot start it . There's nothing from output.

 ![latest](https://us1.discourse-cdn.com/elastic/original/3X/1/5/15c70c094b146c52d994594f85bbc3df59b36b78.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [February 4, 2020, 6:10pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/17 "2020-02-04T18:10:44Z")

</div>

Can you run this with `metricbeat.exe -e`. You'll likely see much more information about the metricbeat start up process. Please let us know if you see any errors. At a minimum, you'll likely need to configure the output for metricbeat to point to an Elasticsearch instance.

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [February 4, 2020, 6:39pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/18 "2020-02-04T18:39:50Z")

</div>

Thanks Michael. I can see the detailed info right now. Thanks you for your patience in this period. Actually, what I am doing now still need to make it work on Linux (AWS Ubuntu). Do you know how to run source code under Linux? Do I still need to install mage?

---

<div class="post-metadata">

**Author:** ![Michael\_Madden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_madden/32/46640_2.png) [@Michael\_Madden](https://discuss.elastic.co/u/Michael_Madden)\
**Post date:** [February 4, 2020, 7:01pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/19 "2020-02-04T19:01:03Z")

</div>

You're welcome. On Linux and macOS, I've seen the build process install mage if it's not installed.

For Linux, I would try the following to build metricbeat:

```auto
cd $HOME/go/src/github.com/elastic/beats/metricbeat
make
ls -lh metricbeat

```

---

<div class="post-metadata">

**Author:** ![Yiw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yiw/32/46202_2.png) [@Yiw](https://discuss.elastic.co/u/Yiw)\
**Post date:** [February 4, 2020, 9:27pm UTC](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082/20 "2020-02-04T21:27:50Z")

</div>

Hi Michael, my windows works great right now, but Linux has different issues. I set the `GOPATH` first and run `make`. The following is what I got:

 ![linux](https://us1.discourse-cdn.com/elastic/original/3X/0/c/0c44dcfbc883e52eb0daf2c6ce7c5cbfd235a89c.png)

[Next page](https://discuss.elastic.co/t/mage-is-not-recognized-as-an-internal-or-external-command/217082.md?page=2)
