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: Cannot read property '1' of null #6078

Closed
1 task
abreng opened this issue Sep 20, 2016 · 13 comments
Closed
1 task

Error: Cannot read property '1' of null #6078

abreng opened this issue Sep 20, 2016 · 13 comments
Labels
needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc

Comments

@abreng
Copy link

abreng commented Sep 20, 2016

  • I'm submitting a ...
  • Bug report

Please include this information:

  • What Grafana version are you using?

grafana-3.1.1-1470047149.x86_64

  • What datasource are you using?

Prometheus

  • What OS are you running grafana on?

RHEL

  • What did you do?

I started Prometheus an Grafana server which I'm going to use for monitoring server host and MySQL DB. Metrics are properly getting scraped in Prometheus and there are no errors in Prometheus logs.

  • What was the expected result?

I was expecting to see the graphs for metrics pertaining to the linux and MySQL DB.

  • What happened instead?

No graphs are getting displayed and in each metric column. I get a error saying 'cannot read property '1' of null in the orange mark on the corner.

Error Snap:
image

IMPORTANT If it relates to metric data viz:

  • An image or text representation of your metric query
@torkelo
Copy link
Member

torkelo commented Sep 20, 2016

can you show the prometheus metric query and response? (open chrome dev tools network tab)

@torkelo torkelo closed this as completed Sep 20, 2016
@torkelo torkelo added the needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc label Sep 20, 2016
@abreng
Copy link
Author

abreng commented Sep 20, 2016

Hope this helps?

image

@torkelo
Copy link
Member

torkelo commented Sep 20, 2016

not really :)

Problem 1) you are using Prometheus not grafana in screenshot
Problem 2) The chrome dev tools is not showing the raw prometheus response

@abreng
Copy link
Author

abreng commented Sep 20, 2016

Hi torkelo, can you help me how to go about in providing the necessary info? You want Grafana screenshot?

@abreng
Copy link
Author

abreng commented Sep 20, 2016

Is this you want?

image

@torkelo
Copy link
Member

torkelo commented Sep 20, 2016

@tesla747 I want what the Github issue template requires you to provide, without this info it's impossible for me to help you.

The github issue template includes this text:

The raw query and response for the network request (check this in chrome dev tools network tab, here you can see metric requests and other request, please include the request body and request response)

I need the request response from Prometheus that is causing Grafana to throw error. you can check that in chrome dev tools network tab.

You can also click on the red error icon in the top left corner of a panel and open the error inspector. Might be something interesting there. But I doubt that as it looks like it's a javascript error caused by some strange/invalid response from Prometheus

@abreng
Copy link
Author

abreng commented Sep 20, 2016

Query:
image

Response from datasource (got from dev tools -> Network -> Response tab

/*! grafana - v3.1.1-1470047149 - 2016-08-01

  • Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["lodash","moment","app/core/utils/datemath","./metric_find_query"],function(a){function b(a,b,h,i,j){function k(a){return a.replace(/[^$_+?.()|[]{}]]/g,"\$&")}function l(a,b){return c["default"].isString(a)&&(a=e.parse(a,b)),Math.ceil(a.valueOf()/1e3)}this.type="prometheus",this.editorSrc="app/features/prometheus/partials/query.editor.html",this.name=a.name,this.supportMetrics=!0,this.url=a.url,this.directUrl=a.directUrl,this.basicAuth=a.basicAuth,this.withCredentials=a.withCredentials,this.lastErrors={},this.request=function(a,b,c){var d={url:this.url+b,method:a,requestId:c};return(this.basicAuth||this.withCredentials)&&(d.withCredentials=!0),this.basicAuth&&(d.headers={Authorization:this.basicAuth}),h.datasourceRequest(d)},this.interpolateQueryExpr=function(a,b,d){if(!b.multi&&!b.includeAll)return a;if("string"==typeof a)return k(a);var e=c["default"].map(a,k);return e.join("|")};this.query=function(a){var d=this,e=l(a.range.from,!1),f=l(a.range.to,!0),g=[],h=[];if(a=c["default"].clone(a),c["default"].each(a.targets,c["default"].bind(function(b){if(b.expr&&!b.hide){h.push(b);var c={};c.expr=i.replace(b.expr,a.scopedVars,d.interpolateQueryExpr),c.requestId=a.panelId+b.refId;var j=b.interval||a.interval,k=b.intervalFactor||1;b.step=c.step=this.calculateInterval(j,k);var l=Math.ceil(f-e);0!==c.step&&l/c.step>11e3&&(b.step=c.step=Math.ceil(l/11e3)),g.push(c)}},this)),c["default"].isEmpty(g)){var j=b.defer();return j.resolve({data:[]}),j.promise}var k=c["default"].map(g,c["default"].bind(function(a){return this.performTimeSeriesQuery(a,e,f)},this));return b.all(k).then(function(a){var b=[];return c["default"].each(a,function(a,g){if("error"===a.status)throw d.lastErrors.query=a.error,a.error;delete d.lastErrors.query,c["default"].each(a.data.data.result,function(a){b.push(d.transformMetricData(a,h[g],e,f))})}),{data:b}})},this.performTimeSeriesQuery=function(a,b,c){var d="/api/v1/query_range?query="+encodeURIComponent(a.expr)+"&start="+b+"&end="+c+"&step="+a.step;return this.request("GET",d,a.requestId)},this.performSuggestQuery=function(a){var b="/api/v1/label/name/values";return this.request("GET",b).then(function(b){return c["default"].filter(b.data.data,function(b){return 1!==b.indexOf(a)})})},this.metricFindQuery=function(a){if(!a)return b.when([]);var c;try{c=i.replace(a,{},this.interpolateQueryExpr)}catch(d){return b.reject(d)}var e=new f"default";return e.process()},this.annotationQuery=function(a){var d=a.annotation,e=d.expr||"",f=d.tagKeys||"",g=d.titleFormat||"",h=d.textFormat||"";if(!e)return b.when([]);var j;try{j=i.replace(e,{},this.interpolateQueryExpr)}catch(k){return b.reject(k)}var m={expr:j,step:"60s"},n=l(a.range.from,!1),o=l(a.range.to,!0),p=this;return this.performTimeSeriesQuery(m,n,o).then(function(a){var b=[];return f=f.split(","),c["default"].each(a.data.data.result,function(a){var e=c["default"].chain(a.metric).filter(function(a,b){return c["default"].contains(f,b)}).value();c["default"].each(a.values,function(c){if("1"===c[1]){var f={annotation:d,time:1e3_Math.floor(c[0]),title:p.renderTemplate(g,a.metric),tags:e,text:p.renderTemplate(h,a.metric)};b.push(f)}})}),b})},this.testDatasource=function(){return this.metricFindQuery("metrics(.)").then(function(){return{status:"success",message:"Data source is working",title:"Success"}})},this.calculateInterval=function(a,b){var c=a.match(g),e=d["default"].duration(parseInt(c[1]),c[2]),f=e.asSeconds();return f<1&&(f=1),Math.ceil(f_b)},this.transformMetricData=function(a,b,d,e){var f=[],g=null;g=this.createMetricLabel(a.metric,b);var h=1e3_parseInt(b.step),i=1e3_d;c["default"].each(a.values,function(a){var b=parseFloat(a[1]);c["default"].isNaN(b)&&(b=null);for(var d=1e3_a[0],e=i;e<d;e+=h)f.push([null,e]);i=d+h,f.push([b,d])});for(var j=1e3_e,k=i;k<=j;k+=h)f.push([null,k]);return{target:g,datapoints:f}},this.createMetricLabel=function(a,b){return c["default"].isUndefined(b)||c["default"].isEmpty(b.legendFormat)?this.getOriginalMetricName(a):this.renderTemplate(b.legendFormat,a)||"{}"},this.renderTemplate=function(a,b){var c=/{{\s(.+?)\s}}/g;return a.replace(c,function(a,c){return b[c]?b[c]:c})},this.getOriginalMetricName=function(a){var b=a.name||"";delete a.name;var d=c["default"].map(c["default"].pairs(a),function(a){return a[0]+'="'+a[1]+'"'}).join(",");return b+"{"+d+"}"}}b.$inject=["instanceSettings","$q","backendSrv","templateSrv","timeSrv"];var c,d,e,f,g;return a("PrometheusDatasource",b),{setters:[function(a){c=a},function(a){d=a},function(a){e=a},function(a){f=a}],execute:function(){g=/(\d+)(ms|s|m|h|d|w|M|y)/}}});

A snap from the above query I got from network tab:
image

Regret that i'm unable to provide the right info but I really need Grafana to work. Let me if anything else is necessary

@abreng
Copy link
Author

abreng commented Sep 20, 2016

As you rightly pointed out, the inspector doesn't show up anything useful

@abreng
Copy link
Author

abreng commented Sep 20, 2016

image

@torkelo
Copy link
Member

torkelo commented Sep 20, 2016

I am afraid your network response is not really useful, your just showing a Grafana loading a javascript file, what would be useful is the response from the prometheus query_range network call. When you have the dev tools network tab open, clear the list and then hit the dashboard refresh button (the recycle icon), then you should only see metric requests to prometheus.

From the javascript error I think the problem is in your interval option. Grafana 3.1.1 does support the use of the interval variable in Prometheus step option.

For that feature you need to use nightly build of Grafana 4.0
http://grafana.org/download/builds.html

@abreng
Copy link
Author

abreng commented Sep 20, 2016

I will try with the new build. In the meantime, can you check the below snap whether is this helpful?
I opened the dev tools and clicked the refresh.

image

@torkelo
Copy link
Member

torkelo commented Sep 20, 2016

No, it's it helpful, need to click on one network call in the list and the the response tab

@abreng
Copy link
Author

abreng commented Sep 21, 2016

Thanks torkelo. Nightly build works just fine. Thanks much. Grafana rocks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc
Projects
None yet
Development

No branches or pull requests

2 participants