Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running grafanaAlerts command #9

Open
tetlika opened this issue Aug 21, 2015 · 4 comments
Open

Error when running grafanaAlerts command #9

tetlika opened this issue Aug 21, 2015 · 4 comments

Comments

@tetlika
Copy link

tetlika commented Aug 21, 2015

we're using grafana 2.0.3-pre1, commit: v2.0.2+3-g2c52224 ; and grafanaAlerts 1.0.0.dev7

when I run in console grafanaAlerts command, I receive error:

[<grafana_alerts.alerting.AlertChecker instance at 0x1a30290>]
Traceback (most recent call last):
File "/usr/local/bin/grafanaAlerts", line 9, in
load_entry_point('grafana-alerts==1.0.0.dev7', 'console_scripts', 'grafanaAlerts')()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/init.py", line 12, in main
return the_launcher.launch()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/launcher.py", line 16, in launch
alert_checker.check()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/alerting.py", line 50, in check
alert_checker.check()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/alerting.py", line 108, in check
contents = urllib2.urlopen(request).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(_args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(_args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

whet does it mean?, thanks :)

@tetlika
Copy link
Author

tetlika commented Aug 21, 2015

P.S.

here is full output:

:~# grafanaAlerts
{"dashboards":[{"id":11,"title":"testalerts","slug":"testalerts","tags":["monitored"],"isStarred":false}],"tags":[],"tagsOnly":false}
[{u'slug': u'testalerts', u'tags': [u'monitored'], u'isStarred': False, u'id': 11, u'title': u'testalerts'}]
Dashboard: testalerts
Contents is:
{"meta":{"isStarred":false,"isHome":false,"isSnapshot":false,"slug":"testalerts","expires":"0001-01-01T00:00:00Z","created":"0001-01-01T00:00:00Z"},"model":{"annotations":{"list":[]},"editable":true,"hideControls":false,"id":11,"nav":[{"collapse":false,"enable":true,"notice":false,"now":true,"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"],"status":"Stable","time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"],"type":"timepicker"}],"originalTitle":"testalerts","rows":[{"collapse":false,"editable":true,"height":"250px","panels":[{"aliasColors":{},"bars":false,"datasource":null,"editable":true,"error":false,"fill":1,"grid":{"leftLogBase":1,"leftMax":null,"leftMin":null,"rightLogBase":1,"rightMax":null,"rightMin":null,"threshold1":null,"threshold1Color":"rgba(216, 200, 27, 0.27)","threshold2":null,"threshold2Color":"rgba(234, 112, 112, 0.22)"},"id":1,"legend":{"avg":false,"current":false,"max":false,"min":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":2,"links":[],"nullPointMode":"connected","percentage":false,"pointradius":5,"points":false,"renderer":"flot","seriesOverrides":[],"span":6,"stack":false,"steppedLine":false,"targets":[{"target":"host.cpu.percent-user"}],"timeFrom":null,"timeShift":null,"title":"CPU-MYSQL","tooltip":{"shared":true,"value_type":"cumulative"},"type":"graph","x-axis":true,"y-axis":true,"y_formats":["short","short"]},{"content":"1\u003c=x\u003c=10; warning; v.test@example.com\n\n15\u003cx\u003c40; normal; v.test@example.com\n\nx\u003c=15; critical; v.test@example.com","editable":true,"error":false,"id":2,"links":[],"mode":"text","span":6,"style":{},"title":"alerts","type":"text"}],"title":"Row"}],"schemaVersion":6,"sharedCrosshair":false,"style":"dark","tags":["monitored"],"templating":{"list":[]},"time":{"from":"now-6h","to":"now"},"timezone":"browser","title":"testalerts","version":11}}
[{u'bars': False, u'timeFrom': None, u'links': [], u'nullPointMode': u'connected', u'renderer': u'flot', u'id': 1, u'linewidth': 2, u'steppedLine': False, u'targets': [{u'target': u'host.cpu.percent-user'}], u'fill': 1, u'span': 6, u'title': u'CPU-MYSQL', u'tooltip': {u'shared': True, u'value_type': u'cumulative'}, u'legend': {u'total': False, u'show': True, u'max': False, u'min': False, u'current': False, u'values': False, u'avg': False}, u'seriesOverrides': [], u'percentage': False, u'type': u'graph', u'x-axis': True, u'error': False, u'editable': True, u'grid': {u'leftMax': None, u'threshold2': None, u'rightLogBase': 1, u'rightMax': None, u'threshold1': None, u'leftLogBase': 1, u'threshold2Color': u'rgba(234, 112, 112, 0.22)', u'rightMin': None, u'threshold1Color': u'rgba(216, 200, 27, 0.27)', u'leftMin': None}, u'stack': False, u'y-axis': True, u'timeShift': None, u'aliasColors': {}, u'lines': True, u'points': False, u'datasource': None, u'pointradius': 5, u'y_formats': [u'short', u'short']}, {u'style': {}, u'span': 6, u'links': [], u'title': u'alerts', u'editable': True, u'content': u'1<=x<=10; warning; v.test@example.com\n\n15<x<40; normal; v.test@example.com\n\nx<=15; critical; v.test@example.com', u'mode': u'text', u'error': False, u'type': u'text', u'id': 2}]
{u'bars': False, u'timeFrom': None, u'links': [], u'nullPointMode': u'connected', u'renderer': u'flot', u'id': 1, u'linewidth': 2, u'steppedLine': False, u'targets': [{u'target': u'host.cpu.percent-user'}], u'fill': 1, u'span': 6, u'title': u'CPU-MYSQL', u'tooltip': {u'shared': True, u'value_type': u'cumulative'}, u'legend': {u'total': False, u'show': True, u'max': False, u'min': False, u'current': False, u'values': False, u'avg': False}, u'seriesOverrides': [], u'percentage': False, u'type': u'graph', u'x-axis': True, u'error': False, u'editable': True, u'grid': {u'leftMax': None, u'threshold2': None, u'rightLogBase': 1, u'rightMax': None, u'threshold1': None, u'leftLogBase': 1, u'threshold2Color': u'rgba(234, 112, 112, 0.22)', u'rightMin': None, u'threshold1Color': u'rgba(216, 200, 27, 0.27)', u'leftMin': None}, u'stack': False, u'y-axis': True, u'timeShift': None, u'aliasColors': {}, u'lines': True, u'points': False, u'datasource': None, u'pointradius': 5, u'y_formats': [u'short', u'short']}
graph
{u'style': {}, u'span': 6, u'links': [], u'title': u'alerts', u'editable': True, u'content': u'1<=x<=10; warning; v.test@example.com\n\n15<x<40; normal; v.test@example.com\n\nx<=15; critical; v.test@example.com', u'mode': u'text', u'error': False, u'type': u'text', u'id': 2}
text
[<grafana_alerts.alerting.AlertChecker instance at 0x1d26290>]
Traceback (most recent call last):
File "/usr/local/bin/grafanaAlerts", line 9, in
load_entry_point('grafana-alerts==1.0.0.dev7', 'console_scripts', 'grafanaAlerts')()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/init.py", line 12, in main
return the_launcher.launch()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/launcher.py", line 16, in launch
alert_checker.check()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/alerting.py", line 50, in check
alert_checker.check()
File "/usr/local/lib/python2.7/dist-packages/grafana_alerts/alerting.py", line 108, in check
contents = urllib2.urlopen(request).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(_args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(_args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

@pabloa
Copy link
Owner

pabloa commented Aug 21, 2015

Hello Tetlika,

grafana-alerts is trying to make a HTTP Post to:

http://yourHost:youPort/api/datasources/proxy/1/render

with parameters:

target={target}&from=-60s&until=now&format=json&maxDataPoints=100

Did you set the grafana token? It is the parameter grafana_token in /etc/grafana_alerts/grafana_alerts.cfg

I did not test it with grafana 2.0.3. Please let me know hot it goes.

@tetlika
Copy link
Author

tetlika commented Aug 22, 2015

hey Pabloa,
yes of course, the token is set (viewer permissions) , if it was not configured I would receive permission denied error

P.S

with what versions of grafana have you tested your software?

thanks

@tetlika
Copy link
Author

tetlika commented Aug 24, 2015

hey Pabloa, looks I've managed to fix the problem by doing this:

#_GRAFANA_URL_PATH_OBTAIN_METRICS = 'api/datasources/proxy/1/render'
_GRAFANA_URL_PATH_OBTAIN_METRICS = 'api/datasources/proxy/2/render'

in alerting.py file, I think the problem is that datasource id in our case was 2 and not 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants