Mark
Mark

Reputation: 81

How to show only unique rows in CloudWatch output?

I have a CloudWatch query that creates a table of output that looks something like:

id    | name   | age
1313  | Sam    | 24 
1313  | Sam    | 24 
1313  | Sam    | 24 
1481  | David  | 62
1481  | David  | 62
3748  | Sarah  | 37
3748  | Sarah  | 37
3748  | Sarah  | 37
1481  | David  | 62

Is there a way to have CloudWatch automatically deduplicate its output, so I just see:

id    | name   | age
1313  | Sam    | 24 
1481  | David  | 62
3748  | Sarah  | 37

Upvotes: 1

Views: 3071

Answers (2)

Matt Klein
Matt Klein

Reputation: 8424

I assume dedupe didn't exist 2 years ago, but now you can do this:

fields id, name, age
| dedup id

Given documentation example

fields @timestamp, server, severity, message 
| sort @timestamp desc 
| dedup server

Upvotes: 1

Dejan Peretin
Dejan Peretin

Reputation: 12089

You can calculate an aggregated value across these 3 fields and then drop it (keep just these 3). Like this for example:

YOUR CURRENT QUERY | count(*) by id, name, age | display id, name, age

Upvotes: 3

Related Questions