Can i build both OSS and x-pack modules for metricbeat

Hello, I'm trying to metricbeat from source and it seems I can build the binary for either the oss modules or x-pack modules.

The binary in the image(elastic/metricbeat:8.17.3) is built for both.

Is that something I can do while building it locally from source?

Sorry, could you explain better what you're trying ti build?

I'm trying to build metricbeat from source. I built it by running mage build within metricbeat directory.

When I run metricbeat modules list I just see the oss modules. When I run the same command within the elastic/metricbeat:8.17.3 image I see modules from both OSS and x-pack.

The OSS docker image we publish is docker.elastic.co/beats/metricbeat-oss:8.17.3.
Try this one and you should get only the OSS modules.

Thank you, but I'd like to build with both oss and x-pack modules. Is that an option when building metricbeat locally?

Yes, the best way to build them is using mage package instead of build. package will generate the package with all artefacts metricbeat needs.

If you run it from metricbeat it'll package the oss version, from x-pack/metricbeat, the x-pack version.

Is it what you're looking for? You can also build the docker images