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

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
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
Howere, it still shows same error message.

Thanks.

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.

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.

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

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:

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.

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

Please let us know if installing mage helps.

1 Like

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.

Hello,

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

To build metricbeat you can do something like this:

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
1 Like

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.

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.

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

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

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!

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

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.

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.

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

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:

- 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

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

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.

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?

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:

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

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: