In a Grafana dashboard a custom metric is shown. This metric is received via Prometheus. The metric is built via Spring Boot Actuator / Micrometer.
In about half of the cases the Prometheus query of the metric gives an empty result. In the other cases the value is valid. So, it may have to do with a threshold of scraping?
Analysing the query Prometheus uses, an empty result is presented:
http://valid.url/prometheus/api/v1/query?query=last_seconds_since_startime_seconds
The result is:
{"status":"success","data":{"resultType":"vector","result":[]}}
Using this query a complete result is shown (after about 17 seconds) with the actual value:
http://valid.url/stackname/componentname/actuator/prometheus
In the text is:
last_seconds_since_startime_seconds 63.0
The environment is Spring Boot, Micrometer, Actuator, Prometheus and Grafana. The actuator query is built with Micrometer:
Gauge.builder( LAST_SECONDS_SINCE_STARTIME, this,
PrometheusStatistics::secondsSinceStart)
.description("Seconds since last fetch")
.baseUnit("seconds")
.strongReference(true)
.register(meterRegistry);