prom-client icon indicating copy to clipboard operation
prom-client copied to clipboard

[Question] Deserialize metrics from the file

Open zavodnyuk opened this issue 2 years ago • 2 comments

Hi, in my app I don't use any kind of DB, but I want to serialize metrics to the file using getMetricsAsJSON every minute or after each event. Then in case I need to release a new version or restart my app I want read data from the file and continue count metrics. I found that I can use registerMetric and pass instance of Counter/Gauge/etc class but not the data from the file right away. Any elegant way I can de-serialize data on restart? Or the only option I have is read from the file, loop through the data and create instances and push them to registerMetric? Thank you

zavodnyuk avatar Jan 29 '23 07:01 zavodnyuk

There's indeed no way to do this current, and it sounds out of scope. Does pushGateway + using rates instead of absolute counts address your use case?

zbjornson avatar Mar 11 '23 05:03 zbjornson

I decided to revamp my app and to add db as well. So no longer a case, thank you

zavodnyuk avatar Jun 03 '23 02:06 zavodnyuk