i think that you can achieve this by setting up Metricbeat on Device B and configuring it to send its metrics to Logstash running on Device A. Then, on Device A, you can configure Logstash to receive these metrics and forward them along with its own metrics to Elasticsearch.
Thank you, that sounds reasonable!
In the meantime I also found what I can only describe as a workaround.
I solved it by running an HTTP proxy on Device A, and configuring the IP and port of Device A as a proxy on the output in Device B configuration, which seems to be doing the job as well.