graphite-project / graphite-web

A highly scalable real-time graphing system
http://graphite.readthedocs.org/
Apache License 2.0
5.9k stars 1.26k forks source link

"list indices must be integers, not str" in aliasByNode #944

Closed miloszszymczak closed 6 years ago

miloszszymczak commented 10 years ago

Hi. I use Graphite along with Grafana and sometimes while auto-update of graphs I encounter this error:

error

TypeError at /render
list indices must be integers, not str
Request Method: POST
Request URL:    http://graphite.myhost.com/render
Django Version: 1.4.2
Exception Type: TypeError
Exception Value:    
list indices must be integers, not str
Exception Location: /opt/graphite/webapp/graphite/render/functions.py in <genexpr>, line 1022
Python Executable:  /usr/bin/python
Python Version: 2.7.3
Python Path:    
['/opt/graphite/webapp',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/pymodules/python2.7',
 '/opt/graphite/webapp/graphite/thirdparty']
Server time:    Wed, 18 Jun 2014 11:13:32 +0000
Traceback Switch to copy-and-paste view

/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response
                        response = callback(request, *callback_args, **callback_kwargs) ...
&#9654; Local vars
/opt/graphite/webapp/graphite/render/views.py in renderView
        seriesList = evaluateTarget(requestContext, target) ...
&#9654; Local vars
/opt/graphite/webapp/graphite/render/evaluator.py in evaluateTarget
  result = evaluateTokens(requestContext, tokens) ...
&#9654; Local vars
/opt/graphite/webapp/graphite/render/evaluator.py in evaluateTokens
    return evaluateTokens(requestContext, tokens.expression) ...
&#9654; Local vars
/opt/graphite/webapp/graphite/render/evaluator.py in evaluateTokens
    return func(requestContext, *args) ...
&#9654; Local vars
/opt/graphite/webapp/graphite/render/functions.py in aliasByNode
    series.name = '.'.join(metric_pieces[n] for n in nodes) ...
&#9654; Local vars
/opt/graphite/webapp/graphite/render/functions.py in <genexpr>
    series.name = '.'.join(metric_pieces[n] for n in nodes) ...
&#9654; Local vars
Request information

GET
No GET data
POST
Variable    Value
format  
u'json'
from    
u'-7d'
until   
u'now'
maxDataPoints   
u'636'
target  
u'aliasByNode(summarize(myproject.prod.*.*.timers.app.view.myproject.api.views.MyProjectQuery.POST.mean_99, "10min", "max"), 2,3)'

I logged some information and it appears, that before the error appears, aliasByNode function receives tuple ("10min", "max") instead of (2, 3). What may be causing it?

obfuscurity commented 10 years ago

What values does myproject.prod.*.*.timers.app.view.myproject.api.views.MyProjectQuery.POST.mean_99 report around that time? Perhaps we're not handling Nones properly in summarize() (I doubt it, just taking a stab in the dark).

miloszszymczak commented 10 years ago

As shown on the picture, there are some null values, but usually everything's fine even with them, error shows up at random while Grafana auto-update.

[null, 1402905000], [null, 1402905600], [null, 1402906200], [null, 1402906800], [null, 1402907400], [null, 1402908000], [null, 1402908600], [null, 1402909200], [null, 1402909800], [null, 1402910400], [null, 1402911000], [null, 1402911600], [null, 1402912200], [null, 1402912800], [2.1949026000000003, 1402913400], [2.1984015666666665, 1402914000], [2.2147782333333335, 1402914600], [2.1966841999999995, 1402915200], [2.1873180000000003, 1402915800], [2.224719733333333, 1402916400],
obfuscurity commented 10 years ago

It makes no sense that this happens irregularly. Can you take a look at the specific request that's failing and see if the request looks different than expected? Hint: use the web inspector.

/cc @torkelo in case this is a Grafana issue somehow.

torkelo commented 10 years ago

Strange, grafana should send the same query every time when auto refresh. The query is built only when you use the query editor. The error looks strange, given the query. It complains about the aliasByNode parameters must be integers, and they are, it is the summarize parameters that are strings. It almost seems like a threading or caching issue.

aliasByNode(summarize(myproject.prod...timers.app.view.myproject.api.views.MyProjectQuery.POST.mean_99, "10min", "max"), 2,3)

miloszszymczak commented 10 years ago

As I wrote above - because of some glitch aliasByNode receives ("10min", "max") tuple instead of (2, 3) as arguments - I logged it right from the function. That's why it complains about non-integer indices.

miloszszymczak commented 10 years ago

Do you have any ideas on how I can debug it? I have access to the code and since the error appears several times a day, I can log any information you need to find out what's happening.

mlowicki commented 10 years ago
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/opt/graphite/webapp/graphite/render/views.py" in renderView
  113.         seriesList = evaluateTarget(requestContext, target)
File "/opt/graphite/webapp/graphite/render/evaluator.py" in evaluateTarget
  10.   result = evaluateTokens(requestContext, tokens)
File "/opt/graphite/webapp/graphite/render/evaluator.py" in evaluateTokens
  21.     return evaluateTokens(requestContext, tokens.expression)
File "/opt/graphite/webapp/graphite/render/evaluator.py" in evaluateTokens
  29.     return func(requestContext, *args)
File "/opt/graphite/webapp/graphite/render/functions.py" in aliasByNode
  1022.     series.name = '.'.join(metric_pieces[n] for n in nodes)
File "/opt/graphite/webapp/graphite/render/functions.py" in <genexpr>
  1022.     series.name = '.'.join(metric_pieces[n] for n in nodes)

Exception Type: TypeError at /render
Exception Value: list indices must be integers, not str

POST

format u'json'
from    u'-24h'
target u"aliasByNode(summarize(share.prod.{ams,os}.{db1,db2,faviconer1,faviconer2,front1,front2}.gauges.memory.MemFree,'10min','max'),2,3)"
maxDataPoints u'424'
until   u'now'
steve-dave commented 10 years ago

@miloszszymczak @mlowicki sorry if I've missed it somewhere above but can you please advise the exact graphite-web version you are running?