title: AWS CloudWatch Agent Windows - hostname not showing as a dimension in Metrics
body: <p>CloudWatch agent version: 1.3.411.60</p>
  
  <p><strong>The Objective:</strong> Get the localhost name of Windows EC2 instance to be a dimension (column) for each metric configured. So that you can filter by the instance's ComputerName</p>
  
  <p>Per the AWS Docs for creating a CloudWatch Agent Config file,</p>
  
  <blockquote>
    <p>omit_hostname – Optional. By default, the hostname is published as a dimension of metrics that are collected by the agent. Set this value to true to prevent the hostname from being published as a dimension. The default value is false.</p>
  </blockquote>
  
  <p>Link to the doc: <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html</a></p>
  
  <p>Being that's the case, after applying my configurated json file, i see the configured metrics in CloudWatch successfully, but without a dimension/Column with the host's name showing.</p>
  
  <p>When i view the log, i see that the agent successfully retrieved the localhost name of the instance, <strong>HOST-123456</strong> (actual name redacted)</p>
  
  <pre><code>2020/05/11 22:59:23 I! I! Detected the instance is EC2
  2020/05/11 22:59:23 Reading json config file path: C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json ...
  Valid Json input schema.
  No csm configuration found.
  Configuration validation first phase succeeded
  2020/05/11 22:59:23 I! Config has been translated into TOML C:\ProgramData\Amazon\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.toml 
  2020-05-11T22:59:27Z I! cloudwatch: get unique roll up list [[AutoScalingGroupName]]
  2020-05-11T22:59:27Z I! Starting AmazonCloudWatchAgent (version 1.237768.0)
  2020-05-11T22:59:27Z I! Loaded outputs: cloudwatchlogs cloudwatch
  2020-05-11T22:59:27Z I! Loaded inputs: win_perf_counters windows_event_log
  2020-05-11T22:59:27Z I! Tags enabled: host=HOST-123456
  2020-05-11T22:59:27Z I! Agent Config: Interval:30s, Quiet:false, Hostname:"HOST-123456", Flush Interval:1s 
  2020-05-11T22:59:27Z I! cloudwatch: publish with ForceFlushInterval: 1m0s, Publish Jitter: 43s
  </code></pre>
  
  <p>In the .json file it reads first (the one i configured), i explicitly state the false boolean for omitting the hostname, even though that is the default configuration (I've gotten the same results leaving this out and just letting the default be configured on it's own)</p>
  
  <pre><code>"agent": {
          "metrics_collection_interval": 30,
          "logfile": "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Logs\\amazon-cloudwatch-agent.log",
          "omit_hostname": false
      },
  </code></pre>
  
  <p>In the .toml file that the agent converts the .json to, i see the hostname value is null,</p>
  
  <pre><code>[agent]
    collection_jitter = "0s"
    debug = false
    flush_interval = "1s"
    flush_jitter = "0s"
    hostname = ""
    interval = "30s"
    logfile = "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Logs\\amazon-cloudwatch-agent.log"
    metric_batch_size = 1000
    metric_buffer_limit = 10000
    omit_hostname = false
    precision = ""
    quiet = false
    round_interval = false
  </code></pre>
  
  <p>AND lower in the outputs.cloudwatch section i see there is a specific key called tagexclude with "host" in it, (and metricPath which i do not know what that is)</p>
  
  <pre><code>[outputs]
  
    [[outputs.cloudwatch]]
      force_flush_interval = "60s"
      namespace = "PerfMon"
      region = "us-west-1"
      rollup_dimensions = [["AutoScalingGroupName"]]
      tagexclude = ["host", "metricPath"]
  </code></pre>
  
  <p>I've not been successful googling around for deeper insight into this, so i'm hoping someone may be able to inform me with what's going on. Any insight is much appreciated.</p>
  
  <p>to note: The default Name field in AWS for EC2 instance's is filled with the name of the ASG the EC2 resides in for other reasons so that field can't be utilized.</p>