Metrics caching
Caching support (enabled by default) was added because on some clouds, querying for these metrics from the openstack api can take some time, causing Prometheus to time out waiting for the response.
When caching is enabled in the exporter:
- The exporter will periodically query the openstack api for metrics data and update the cache. The cache data is updated only after all collection jobs are completed, ensuring no mixing of old and new data.
- External requests (eg. from Prometheus scraping) will always get a response quickly, because the response will either be:
- empty response (cache not populated yet, cache expired)
- metrics from the cache
The expiry ttl for the cache, and the frequency that the cache is updated with new metrics, is configurable via the cache-ttl
option.
- The cache expires after
cache-ttl
duration. - The cache is refreshed with a period equal to half the
cache-ttl
duration.