I'm using grafana cloud for creating visualization but when i'm trying to load the data source with elasticsearch i'm getting 502 error.

I'm using grafana cloud for creating visualization but when i'm trying to load the data source with elasticsearch i'm getting 502 error.

502 usually means bad gateway (there is no connection) and that IP address looks like an internal IP address. GrafanaCloud is a cloud service so it does not have access to internal IP addresses.
Your options are:
Add the following configurations in config/elasticsearch.yml:
transport.host: localhost
transport.tcp.port: 9300
http.port: 9200
network.host: 0.0.0.0