title: AWS CLI query filtering oddly
body: <p>Overall, I am trying to find out which of our SNS topics aren't being used.  So I thought to get a list of SNS topics that are active and subtract that from the full list.  Seems like that is not so easy.  Cloudwatch only reports metrics if there has been activity in the last 6 hours.  But it is all I can find, so I will cron a job to grab the active topics every couple of hours and keep a unique list. (If someone has a better idea, I am all ears).</p>
  <p>To that end I am building a query to give me the active topic names at a given time.
  First pass looks like this</p>
  <pre><code>aws cloudwatch list-metrics --query 'Metrics[*].Dimensions[*].[Name,Value]' --namespace 'AWS/SNS' --metric-name 'NumberOfMessagesPublished'
  </code></pre>
  <p>That gets me something like this</p>
  <pre><code>[
    [
      [
          &quot;TopicName&quot;,
          &quot;bogus&quot;
      ]
    ]
  ]
  </code></pre>
  <p>But I only want the topic name really.
  So, based on the section &quot;Filtering for specific values&quot; in this AWS <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-filter.html" rel="nofollow noreferrer">doc</a> I modified the query to be</p>
  <pre><code>--query 'Metrics[*].Dimensions[?Name=='TopicName'].[Value]'
  </code></pre>
  <p>But all I get back is</p>
  <pre><code>[
      []
  ]
  </code></pre>
  <p>I can't see any difference between the example and my use case.  But I must be missing something.</p>