Package org.acemq.rabbitmq.admin.metrics
Class MetricsSnapshot
java.lang.Object
org.acemq.rabbitmq.admin.metrics.MetricsSnapshot
Everything one scrape returned, queryable.
MetricsSnapshot metrics = PrometheusMetrics.at("http://localhost:15692").scrapeDetailed();
metrics.forQueue("orders.new")
.metric("rabbitmq_detailed_queue_messages_ready")
.map(MetricSample::asLong)
.orElse(0L);
A snapshot is a moment, not a stream. Nothing here computes a rate, because a rate needs
two scrapes and a clock and this holds one — takenAt() is provided so a caller
comparing two snapshots can do the arithmetic honestly rather than have it guessed for them.
-
Method Details
-
samples
- Returns:
- every sample in the scrape
-
takenAt
- Returns:
- when this scrape was taken, for a caller computing a rate across two of them
-
all
- Parameters:
name- a metric name- Returns:
- every sample of it — one per label combination, so one per queue on the detailed endpoint and exactly one on the aggregate endpoint
-
metric
- Parameters:
name- a metric name- Returns:
- the single sample of it, or empty. Use
all(String)where the metric is labelled: this returns the first and there is no meaningful first among queues
-
sum
- Parameters:
name- a metric name- Returns:
- the sum across every label combination. What "how many messages are waiting anywhere" means on the detailed endpoint
-
forQueue
Narrows to one queue.- Parameters:
queue- the queue's name- Returns:
- a snapshot of only the samples labelled with it
-
withLabel
- Parameters:
label- a label namevalue- the value it must have- Returns:
- a snapshot of only the samples carrying it
-
where
- Parameters:
predicate- what to keep- Returns:
- a snapshot of the samples matching it, taken at the same moment as this one
-
queues
- Returns:
- the distinct queue names this snapshot has samples for
-
helpFor
- Parameters:
name- a metric name- Returns:
- the broker's own description of it, from the
# HELPline. Useful when generating a dashboard, where a panel wants a subtitle somebody did not have to write
-
isEmpty
public boolean isEmpty()- Returns:
- whether the scrape returned nothing at all
-
toString
-