title: AWS CloudWatch agent fails - refresh EC2 Instance Tags failed: RequestError: send request failed
body: <p>I am trying to monitor custom metrics on my EC2 instance using StatsD. I folloed AWS documentation and configured role, installed CloudWatch agent, configured it. My EC2 instance is behind proxy. I configured <code>common-config.toml</code>. I also created certificate bundle for <code>https://ec2.us-west-2.amazonaws.com/</code>. I get error:</p>
  
  <pre><code>refresh EC2 Instance Tags failed: RequestError: send request failed
  caused by: Post https://ec2.us-west-2.amazonaws.com/: proxyconnect tcp: tls: first record does not look like a TLS handshake, metrics will be dropped until it got fixed
  </code></pre>
  
  <p>Here is full log of service start</p>
  
  <pre><code>2020/05/27 06:45:29 I! I! Detected the instance is EC2
  2020/05/27 06:45:29 Reading json config file path: C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json ...
  C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
  2020/05/27 06:45:29 Reading json config file path: C:\ProgramData\Amazon\AmazonCloudWatchAgent\Configs\file_config.json ...
  Valid Json input schema.
  No csm configuration found.
  Configuration validation first phase succeeded
  
  2020/05/27 06:45:29 I! Config has been translated into TOML C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.toml 
  2020-05-27T06:45:29Z I! HTTP_PROXY "http://192.16.4.5:3128" is set!
  2020-05-27T06:45:29Z I! HTTPS_PROXY "https://192.16.4.5:3128" is set!
  2020-05-27T06:45:29Z I! NO_PROXY "169.254.169.254" is set!
  2020-05-27T06:45:29Z I! AWSCABundle "C:\cert\bundle.pem" is set!
  2020-05-27T06:45:29Z I! cloudwatch: get unique roll up list []
  2020-05-27T06:45:29Z I! Starting AmazonCloudWatchAgent (version 1.237768.0)
  2020-05-27T06:45:29Z I! Loaded outputs: cloudwatch cloudwatchlogs
  2020-05-27T06:45:29Z I! Loaded inputs: windows_event_log statsd win_perf_counters
  2020-05-27T06:45:29Z I! Tags enabled: host=cloudwatch01
  2020-05-27T06:45:29Z I! Agent Config: Interval:1m0s, Quiet:false, Hostname:"cloudwatch01", Flush Interval:1s 
  2020-05-27T06:45:29Z I! Started the statsd service on :8125
  2020-05-27T06:45:29Z I! cloudwatch: publish with ForceFlushInterval: 1m0s, Publish Jitter: 3s
  2020-05-27T06:45:29Z I! The state file C:\ProgramData\Amazon\AmazonCloudWatchAgent\Logs\state\Amazon_CloudWatch_WindowsEventLog_System for Amazon_CloudWatch_WindowsEventLog_System does not exist: CreateFile C:\ProgramData\Amazon\AmazonCloudWatchAgent\Logs\state\Amazon_CloudWatch_WindowsEventLog_System: The system cannot find the file specified.
  2020-05-27T06:45:29Z I! Statsd listener listening on:  [::]:8125
  2020-05-27T06:45:30Z E! refresh EC2 Instance Tags failed: RequestError: send request failed
  caused by: Post https://ec2.us-west-2.amazonaws.com/: proxyconnect tcp: tls: first record does not look like a TLS handshake, metrics will be dropped until it got fixed
  2020-05-27T06:45:30Z E! CreateLogStream / CreateLogGroup with log group name System stream name i-0c0000000000 has errors. Will retry the request: RequestError: send request failed
  
  </code></pre>
  
  <p>I am using squid proxy.<br>
  What causes TLS handshake problem?<br>
  When opening browser from RDP session, no problem to access https servers through squid proxy.</p>