Just did a manual scraping with the following results:
foo % grep CollectionCount jmx-metrics-java8.txt
java.lang{type=GarbageCollector, name=ParNew}[]CollectionCount: 10659
java.lang{type=GarbageCollector, name=ConcurrentMarkSweep}[]CollectionCount: 24
foo % grep CollectionCount jmx-metrics-java11.txt
java.lang{name=G1 Young Generation, type=GarbageCollector}[]CollectionCount: 811
java.lang{name=G1 Old Generation, type=GarbageCollector}[]CollectionCount: 0
When I do a query in Prometheus with the metric 'java_lang_GarbageCollector_CollectionCount' I get the ParNew and ConcurrentMarkSweep values, but not the G1 ones even though these look exactly the same (java.lang prefix, type=GarbageCollector).
The G1 ones are available however when querying with separate metrics 'java_lang_G1_Young_Generation_CollectionCount' and 'java_lang_G1_Old_Generation_CollectionCount'
Why is that?