Awsfargate metricbeat module not working?

I've declared a metricbeat container in an AWS ECS task definition so that it runs as a "sidecar" container to my main application and uses the awsfargate module to index task stats (CPU, memory etc) into my monitoring cluster.

This is the command I'm using:

    "command": [
      "./metricbeat setup -E setup.kibana.host=\"${MONITORING_SERVER_KIBANA}\" -E output.elasticsearch.hosts=[\"${MONITORING_SERVER}\"] -E logging.level=\"debug\" && ./metricbeat modules enable awsfargate && ./metricbeat"
    ],

The MONITORING_SERVER_KIBANA and MONITORING_SERVER values are injected into the environment from AWS Secrets Manager.

These are the only logs from the metricbeat container:

Overwriting ILM policy is disabled. Set `setup.ilm.overwrite: true` for enabling.
Index setup finished.
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards
Enabled awsfargate

It appears to be running with no errors, but I'm not getting any data at all into my monitoring cluster under any metricbeat-* indexes.

I've tried enabling debug logging by adding: -d "*" to the end of the command, but that just doesn't work.

I'm using version 7.12.0.

What am I doing wrong?

The issue was the command, in the end. Whilst I was passing the output.elasticsearch.hosts parameter to the metricbeat setup, I wasn't passing it when actually running metricbeat. The command should, therefore, have been:

"./metricbeat setup -E setup.kibana.host=\"${MONITORING_SERVER_KIBANA}\" -E output.elasticsearch.hosts=[\"${MONITORING_SERVER}\"] && ./metricbeat modules enable awsfargate && ./metricbeat -e -E output.elasticsearch.hosts=[\"${MONITORING_SERVER}\"] "

Note: the -e is required to direct logging output to stdout, otherwise it goes to syslog.