How can I add the request IP address to every document?

Hi,

I am not sure this is possible: In theory, you would have to create an ingest pipeline in ElasticSearch which does what you want and modify your REST call to execute the pipeline. But from what I found there is no processor for adding the IP from the REST call. See here for the Github issue.
Depending on the usecase this might also be problematic as the IP adress can be faked.

I guess you have (at least) 3 options depending on your infrastructure:
Option 1: Alter your REST call to include the IP adress out of the box
Option 2: Switch from a direct REST call to ElasticSearch to LogStash. LogStash supports this.
Option 3: This is not exactly what you asked for as it does not directly give you the IP. You may use the set-security-user-processor to get the informationabout the user/apiKey which was used to write send the document. If each server has a separate user/apiKey you can use this information to uniquely identify the sending server(You may then use a mapping to get the IP based on the server but it is not the same as getting the IP of the server obviously)

Best regards
Wolfram