You want to aggregate total memory usage by 'job' using the 'node_memory_Usage_bytes' metric, while keeping the 'instance' label in the output. Which aggregation clause should you use?
Trap 1: sum(node_memory_Usage_bytes) drop (instance)
The 'drop' keyword is not a valid PromQL aggregation modifier.
Trap 2: sum(node_memory_Usage_bytes) by (job)
The 'by' clause drops all labels except 'job', meaning the 'instance' label would be discarded.
Trap 3: sum(node_memory_Usage_bytes) without (instance)
This would drop the 'instance' label and keep everything else, which is the opposite of keeping instance while grouping by job.
- A
sum(node_memory_Usage_bytes) drop (instance)
Why wrong: The 'drop' keyword is not a valid PromQL aggregation modifier.
- B
sum(node_memory_Usage_bytes) by (job)
Why wrong: The 'by' clause drops all labels except 'job', meaning the 'instance' label would be discarded.
- C
sum(node_memory_Usage_bytes) without (instance)
Why wrong: This would drop the 'instance' label and keep everything else, which is the opposite of keeping instance while grouping by job.
- D
sum(node_memory_Usage_bytes) by (job, instance)
Using 'by (job, instance)' aggregates across any other unneeded labels while preserving both 'job' and 'instance'.