1. 程式人生 > 實用技巧 >grafana+open-falcon資料展示時報錯:Cannot read property 'length' of null

grafana+open-falcon資料展示時報錯:Cannot read property 'length' of null

報錯現象和具體錯誤資訊:

具體錯誤資訊:

Cannot read property 'length' of null

TypeError: Cannot read property 'length' of null
    at OpenfalconDatasource.translateTime (https://netbench.ksyun.com/grafana/public/plugins/fastweb-openfalcon-datasource/datasource.js:151:45)
    at OpenfalconDatasource.query (https://netbench.ksyun.com/grafana/public/plugins/fastweb-openfalcon-datasource/datasource.js:25:28)
    at e.issueQueries (https://netbench.ksyun.com/grafana/public/build/0.62c2e3e7aa607c7f2d09.js:7:17800)
    at e.issueQueries (https://netbench.ksyun.com/grafana/public/build/0.62c2e3e7aa607c7f2d09.js:7:204121)
    at u (https://netbench.ksyun.com/grafana/public/build/vendor.2c3c591224fb193f7fd3.js:92:69119)
    at https://netbench.ksyun.com/grafana/public/build/vendor.2c3c591224fb193f7fd3.js:92:69565
    at d.$digest (https://netbench.ksyun.com/grafana/public/build/vendor.2c3c591224fb193f7fd3.js:92:75262)
    at d.$apply (https://netbench.ksyun.com/grafana/public/build/vendor.2c3c591224fb193f7fd3.js:92:77076)
    at https://netbench.ksyun.com/grafana/public/build/vendor.2c3c591224fb193f7fd3.js:92:84441
    at i (https://netbench.ksyun.com/grafana/public/build/vendor.2c3c591224fb193f7fd3.js:92:21978)

解決辦法:(只是表象的去解決了,還沒從根上完全解決,但是不影響展示了)

經過排查和測試發現:當你選擇展示的時間段為30分鐘以下的時候會報上述錯誤,選取1個小時以上時間段展示的則沒有錯誤,如下:

在網上也查找了其他網友錯誤的排查方法,發現了同樣的問題點,(即我們的採集資料其時間戳和時間精度,沒有精確到毫秒。當我們取30分鐘以內的資料時,資料散點不夠用,因此產生了錯誤)--》這個是最有可能的bug點,但目前我沒有去嘗試修改datasource.js檔案裡的translateTime方法,只是看其他網友有嘗試去解決,後續有空了自己再驗證。