Closed Cmdrd closed 4 years ago
The Iterable_metrics functions could not be used as they require a value to be associated with a key which that value is then turned into a metric value. Prometheus does not support string metric values. It only support strings as labels. This small loop turns the disqualified status into a label which can then be used in a query, although not as flexible as a metric, this is about all that Prometheus will support without converting the string into a relative float. If iterable_metrics was used, in addition to the work of pulling the information out of /api/dashboard, a new list would have to be created with the disqualified string being the key and an unused float being the value so the function can operate properly.
Storj can now present it however it wants, Grafana and such will just have to be tweaked if there is some sort of colour code assigned to a specific string.
This code also could not be added into the sat loop because of the way the data is stored. This value can only be extracted from /api/dashboard, not /satellites. A search would have to be run against the dashboard data to get the index value of the satellite id, then at that point that nested list could be extracted and the disqualified status could be presented. That was a few more lines of code just to try to squeeze into that loop. Figured less code to get the same outcome is probably preferred.
Since https://github.com/anclrii/Storj-Exporter/pull/25 and https://github.com/anclrii/Storj-Exporter/pull/22 are closely related I was looking for a consistent way to make them both work together. Since I ended up with a working code in the process I'm raising https://github.com/anclrii/Storj-Exporter/pull/26 for review. I Also updated some of existing functions to enable reusing them with disqualified metric. Can you please check https://github.com/anclrii/Storj-Exporter/pull/26 and let me know if you're happy with the change?
I will have to do some work to test this from my but a quick perusal of the code does look like it checks out and should produce the output we're looking for with this.
Shortened up the disqualified status check this is now presented as a label that can be used in conjunction with the related satellite id:
There does not appear to be a great way to present this information in Grafana but hopefully with at least pushing this implementation upstream that someone can come up with solution with the data now being presented.