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

Cannot read property getTime of undefined error #118

Open
SharatSS123 opened this issue Jul 1, 2021 · 3 comments
Open

Cannot read property getTime of undefined error #118

SharatSS123 opened this issue Jul 1, 2021 · 3 comments

Comments

@SharatSS123
Copy link

Geting the above error while trying to view the data as a graph, but am able to view it as a table perfectly.
The data in mongoDB is of the format date time.
Has anyone faced similar issue like this!

@SharatSS123
Copy link
Author

16251560219507510907889909981164

@juanluishg
Copy link

Does "ts" variable exists in your collection? And there is values for the timerange that you have specified in grafana?

Also you should check if "ts" variable in mongodb is in date format.

@ktippey-hzdr
Copy link

ktippey-hzdr commented Jun 16, 2023

fyi, "ts" is the hard-coded time-series key. I was using "date_time" and trying to get several documents. Ended up rewriting the getTimeseriesResults function in mongodb-grafana/dist/server/mongodb-proxy.js to fix things.

function getTimeseriesResults(docs)
{
  var results = {}
  for ( var i = 0; i < docs.length; i++)
  {
    var doc = docs[i]
    for (const [key, value] of Object.entries(doc))
    {
      if (key =='date_time')
        continue

      if (!(key in results))
      {
        results[key] = {'target': key, 'datapoints':[]}
      }
      else
      {
        results[key].datapoints.push([value, doc['date_time'].getTime()])
      }
    }
  }
  console.log(results)
  return results

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

3 participants