PureStorage-OpenConnect / pure-exporter

Prometheus exporter for Pure Storage FlashArray and FlashBlade. DEPRECATED IN FAVOR OF FA AND FB OPENMETRICS EXPORTERS
Apache License 2.0
29 stars 20 forks source link

FlashArray without Volume Groups fails to retrieve volume metrics #29

Closed tothf closed 3 years ago

tothf commented 3 years ago

When a FlashArray has no any volume groups, even an empty one is enough, the get_volumes() returns without 'vgroup' field included. I think this is something to do with the actual Pure API.

The exporter drops the following error:

[2021-04-14 05:45:16,694] ERROR in app: Exception on /metrics/flasharray [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/app/pure_exporter.py", line 135, in route_flasharray_all
    return route_flasharray('all')
  File "/app/pure_exporter.py", line 131, in route_flasharray
    return route_array('flasharray', m_type)
  File "/usr/local/lib/python3.9/site-packages/flask_httpauth.py", line 164, in decorated
    return f(*args, **kwargs)
  File "/app/pure_exporter.py", line 125, in route_array
    resp = make_response(generate_latest(registry), 200)
  File "/usr/local/lib/python3.9/site-packages/prometheus_client/exposition.py", line 177, in generate_latest
    for metric in registry.collect():
  File "/usr/local/lib/python3.9/site-packages/prometheus_client/registry.py", line 83, in collect
    for metric in collector.collect():
  File "/app/flasharray_collector/flasharray_collector.py", line 46, in collect
    yield from VolumeSpaceMetrics(self.fa).get_metrics()
  File "/app/flasharray_collector/flasharray_metrics/volume_space_metrics.py", line 53, in get_metrics
    self._data_reduction()
  File "/app/flasharray_collector/flasharray_metrics/volume_space_metrics.py", line 37, in _data_reduction
    self.data_reduction.add_metric([v_name[1], v['naaid'], v_name[0], v['vgroup']], v['data_reduction'] if v['data_reduction'] is not None else 0)
KeyError: 'vgroup'

To fix it we just need to add 'vgroup' where it is required.

genegr commented 3 years ago

Fixed in current 1.2.5-a version.