You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I ran grafanaAlerts command in console, I received error:
File "/usr/bin/grafanaalerts", line 11, in
sys.exit(main())
File "/usr/lib/python2.6/site-packages/grafana_alerts/__init__.py", line 12, in main
return the_launcher.launch()
File "/usr/lib/python2.6/site-packages/grafana_alerts/launcher.py", line 16, in launch
alert_checker.check()
File "/usr/lib/python2.6/site-packages/grafana_alerts/alerting.py", line 50, in check
alert_checker.check()
File "/usr/lib/python2.6/site-packages/grafana_alerts/alerting.py", line 103, in check
contents = urllib2.urlopen(request).read()
File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib64/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.6/urllib2.py", line 435, in error
return self._call_chain(*args)
File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
It's because there is an incorrect use the path http://my_grafana/api/datasources/proxy/1/... there.
I ran curl "http://my_grafana/api/datasources/" and received a answer:
I saw I have few configurations in grafana but I was interested the configuration with id=7. Then I've updated the variable _GRAFANA_URL_PATH_OBTAIN_METRICS = 'api/datasources/proxy/7/render' in the alerting.py file
After it I got a new error:
File "/usr/bin/grafanaalerts", line 11, in
sys.exit(main())
File "/usr/lib/python2.6/site-packages/grafana_alerts/__init__.py", line 12, in main
return the_launcher.launch()
File "/usr/lib/python2.6/site-packages/grafana_alerts/launcher.py", line 16, in launch
alert_checker.check()
File "/usr/lib/python2.6/site-packages/grafana_alerts/alerting.py", line 53, in check
self.alert_reporter.report(reported_alerts)
File "/usr/lib/python2.6/site-packages/grafana_alerts/reporting.py", line 70, in report
alerts_to_send_map = self._group_by(diff_report, 'alert_destination')
File "/usr/lib/python2.6/site-packages/grafana_alerts/reporting.py", line 161, in _group_by
if key is None:
UnboundLocalError: local variable 'key' referenced before assignment
Then I've added a line: key='' at the beginning of the def _group_by() function in reporting.py.
After it I received a next error:
File "/usr/bin/grafanaalerts", line 11, in
sys.exit(main())
File "/usr/lib/python2.6/site-packages/grafana_alerts/__init__.py", line 12, in main
return the_launcher.launch()
File "/usr/lib/python2.6/site-packages/grafana_alerts/launcher.py", line 16, in launch
alert_checker.check()
File "/usr/lib/python2.6/site-packages/grafana_alerts/alerting.py", line 53, in check
self.alert_reporter.report(reported_alerts)
File "/usr/lib/python2.6/site-packages/grafana_alerts/reporting.py", line 71, in report
self._send_alerts_if_any(alerts_to_send_map)
File "/usr/lib/python2.6/site-packages/grafana_alerts/reporting.py", line 175, in _send_alerts_if_any
if not self._is_something_to_report(alert_event_list):
File "/usr/lib/python2.6/site-packages/grafana_alerts/reporting.py", line 302, in _is_something_to_report
if alert_event['current'].current_alert_condition_status['name'] != 'normal':
TypeError: 'NoneType' object is unsubscriptable
Then I've updated _is_something_to_report(self, alert_event_list) function as below:
def _is_something_to_report(self, alert_event_list):
"""Return True if the alert should be sent."""
# TODO externalize this condition.
for alert_event in alert_event_list:
if alert_event['current'] is None:
continue
if alert_event['current'].current_alert_condition_status is None:
continue
if alert_event['current'].current_alert_condition_status['name'] != 'normal':
return True
if alert_event['old'] is None:
continue
if alert_event['old'].current_alert_condition_status['name'] is None:
continue
if alert_event['old'].current_alert_condition_status['name'] != 'normal':
return True
return False
After these changes I get no more errors but I'm not sure I did it correctly
I think that id in variable _GRAFANA_URL_PATH_OBTAIN_METRICS should be calculated automatically at program start
The text was updated successfully, but these errors were encountered:
When I ran grafanaAlerts command in console, I received error:
It's because there is an incorrect use the path http://my_grafana/api/datasources/proxy/1/... there.
I ran curl "http://my_grafana/api/datasources/" and received a answer:
I saw I have few configurations in grafana but I was interested the configuration with id=7. Then I've updated the variable _GRAFANA_URL_PATH_OBTAIN_METRICS = 'api/datasources/proxy/7/render' in the alerting.py file
After it I got a new error:
Then I've added a line:
key=''
at the beginning of the def _group_by() function in reporting.py.After it I received a next error:
Then I've updated _is_something_to_report(self, alert_event_list) function as below:
After these changes I get no more errors but I'm not sure I did it correctly
I think that
id
in variable _GRAFANA_URL_PATH_OBTAIN_METRICS should be calculated automatically at program startThe text was updated successfully, but these errors were encountered: