moxious / triage

testing triage actions for issues
0 stars 1 forks source link

MongoDB Query Error: error decoding key 0: strconv.ParseInt: parsing "NaN": invalid syntax #383

Open tonypowa opened 1 month ago

tonypowa commented 1 month ago

What happened?

Hey all!

I'm attempting to set up an alert based on a MongoDB query, and I'm getting an error that I don't get when I run the query through other mongo tools (Such as Studio3T).

Query:


my_collection.aggregate(

 [

 {

 "$match": { 

 "start_time": {

 "$gte": new Date(new Date() - (24 ISSUE_TRIAGE.md README.md copy-issue.sh grafana-labels.txt grafana-triage-labels.txt 60 ISSUE_TRIAGE.md README.md copy-issue.sh grafana-labels.txt grafana-triage-labels.txt 60 ISSUE_TRIAGE.md README.md copy-issue.sh grafana-labels.txt grafana-triage-labels.txt 1000))

 },

 }

 },

 {

 "$project": {

 "_id": 0,

 "Document ID": "$id",

 }

 }

 ]

)

Error:


Error

Failed to evaluate queries and expressions: failed to execute query A: error decoding key 0: strconv.ParseInt: parsing "NaN": invalid syntax

What did you expect to happen?

I expected it to return documents where start_time was within the past 24 hours, but it just throws an error. This same exact query works when I use it through other MongoDB tools. I believe this may be due to some document in the collection missing a value for the start_time field, but I haven't been able to track said document down, and it's strange that only Grafana throws this error.

Did this work before?

I don't know if this has ever worked, since this is my first time writing a query using this field.

How do we reproduce it?

I don't have a clear way to reproduce this, but perhaps trying to query a MongoDB instance with an empty value for a field could yield this?

Please let me know if I can add anything to help!

Is the bug inside a dashboard panel?

This bug is not inside a dashboard panel.

Environment (with versions)?

Grafana: 9.4.9 (Enterprise Licensed)

OS: Ubuntu 22.04

Browser: Firefox 127.0.2

Grafana platform?

I don't know

Datasource(s)?

MongoDB

tonypowa commented 1 month ago

This issue is a test copy of an issue in another repo. Original issue: https://github.com/grafana/grafana/issues/#90028

moxious commented 1 month ago

Hello @tonypowa, thank you for reporting this issue. From what you've described, it seems like the issue may be related to the MongoDB data source plugin in Grafana. Could you please confirm whether you're using an official MongoDB plugin or a third-party plugin to connect to MongoDB? If it's a known plugin supported by Grafana, the team from the AWS Datasources project might be able to help you, as they handle data source plugins including those for AWS DocumentDB, which shares compatibility with MongoDB.

However, if this doesn't seem to be the right path, could you please give more information about the plugin you're using? That would help in redirecting this issue to the appropriate project or team. In the meantime, you may also check if there's any null or NaN values in the start_time field in all documents as such values could potentially cause issues when parsed by the query engine.

moxious commented 1 month ago

Elaboration:

Hi @tonypowa,

Thank you for reaching out with the issue you're experiencing. Your detailed description is a great starting point, but we do need a bit more information to help you solve this problem more efficiently. Here are a few questions and requests to clarify the situation:

  1. Query Clarification: The provided query seems to include some unintended file names (like ISSUE_TRIAGE.md, README.md, etc.). Could you provide a corrected version of the query without these file names?

  2. Grafana Version Verification: Can you double-check if any similar issues have been reported with your current Grafana version (9.4.9)?

  3. MongoDB Schema Info: Could you give us more information about the schema of my_collection especially regarding the start_time field? Is start_time always present and can it contain null or NaN values?

  4. Data Examples: It would be helpful to see an example of a document from the my_collection where the start_time fulfills the query condition and is well-formed, as well as an example (if possible) where the start_time could be problematic (like a missing value).

  5. Reproduction Steps: Are there any additional steps within Grafana that lead to encountering the error, such as specific configurations or steps to set up the alert you mentioned?

  6. Comparison with Other Tools: When the query works in other MongoDB tools, do those tools show any warnings or handle special cases that Grafana might not be managing?

Once we have this information, we'll be in a better position to help narrow down the cause of your issue. Feel free to include any additional details you think might be relevant.

Thank you for your cooperation!

Best regards, The GitHub Project Team