-
Notifications
You must be signed in to change notification settings - Fork 21
Implement Grafana Query Builder #329
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am currently on 12.0.2 and everything is working will test version 11 |
The problem exists up to including v 11.4.6 and is fixed in 11.5.0. |
It looks like the issue is with the I think we should consider raising the minimum supported Grafana version. |
@archef2000, Could you please take a look at the tests and fix them? |
In my experience query builders are fairly hard to use manually, - click click click hundred times, - I prefer plain old text for that. But what do I know, I am probably a wrong dk :) |
Oops, looks like I tagged the wrong person 😅 |
As for me, to up the version is ok, but we need to test everything properly We could have another option to use, use the old Combobox, but I am not sure it would work in the newest versions. 11.3.1 as @Loori-R mentioned, is not an old version and many users are using versions 10-11. |
As an option, we could use |
I think using Select instead of Combobox is a better idea. We do not need to change the supported version, and we do not need to use the Alpha component. |
@Loori-R Can comfirm that with the Select component everything works. |
@archef2000 Would you mind replacing |
Already on it |
It looks like there are still some |
I am not finished yet and will make a commit once all are changed and tested |
This query should give me the value types of query: |
Not sure, but it seems like |
Seems like the query won’t return |
Sorry guys missed you question query
the next filter will get only type so the query like |
I was in the assumption that /field_values will return the values of the field that are available after the query. Just noticed it in the value_type operation, but then I will have to change the logic for all. Should I change the getFieldList function with an additional type? |
I don't quite understand what you're trying to achieve. For the expression:
|
For the value_type operation I want to get the availabe value types of the field specified. The field_values is explained so that I get all field values of the specified field from the result of the query. The query gives me the correct result, but the endpoint seems to ignore the query. |
Maybe we could just hardcode the supported value types (like |
@arturminchukov @Loori-R I am now finished with implementing all the operations and fixed all errors I could find. |
![]() I cannot set
![]() So it looks like now I don't have the opportunity to set the |
One more strange behavior of filter for me provided in the video Screen.Recording.2025-09-29.at.17.46.37.mov |
|
|
||
export type SplitString = SplitStringValue | SplitStringBracket | SplitStringComment; | ||
|
||
export const splitString = (str: string): SplitString[] => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add some JS Doc for this function with description what this function do? Cause I didn't guess the functionality just by the name. And maybe add some examples to description.
src/components/QueryEditor/QueryBuilder/Editors/FieldsEditorWithPrefix.tsx
Outdated
Show resolved
Hide resolved
if (prevFieldsName !== fieldName) { // change all defaultFields in the visQuery to the new fieldName | ||
const oldVisQueryOps = visQuery.operations.map((v) => ({ ...v, disabled: false })); // render all operations even when disabled | ||
const oldQueryModeller = createQueryModellerWithDefaultField(prevFieldsName, [VictoriaLogsQueryOperationCategory.Filters, VictoriaLogsQueryOperationCategory.Operators]); | ||
const oldExpr = oldQueryModeller.renderQuery({ operations: oldVisQueryOps }); // old so that old defaultField doesn't get rendered | ||
const newVisQuery = parseExprToVisualQuery(oldExpr, fieldName, queryModeller).query; | ||
for (let i = 0; i < visQuery.operations.length; i++) { | ||
const op = visQuery.operations[i]; | ||
if (op.disabled) { | ||
newVisQuery.operations[i].disabled = op.disabled; // keep disabled operations disabled | ||
} | ||
} | ||
onChange(index, { expr, visQuery: newVisQuery, fieldName } as unknown as string); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we should wrap it with useEffect()
hook here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire if block only runs if the field name of the logic operation gets changed. And the useEffect would need all the dependencies of that block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I just create one helper file or split it up even more?
I prefer group util
functions into files by their functionality, because I think it improves readability.
Yeah, you're right! Right now VL datasource doesn't have such endpoints. Created the issue to add it. So could you wait until I add these endpoints and after it check if |
@arturminchukov It did exist and the filter did work. |
Looks like just need to add mux.HandleFunc("/select/logsql/streams", ds.VLAPIQuery)
mux.HandleFunc("/select/logsql/stream_field_names", ds.VLAPIQuery)
mux.HandleFunc("/select/logsql/stream_field_values", ds.VLAPIQuery) to here. Could you add this code to your pr? |
UPD. @archef2000 , I merged pr with these changes. Could you just make rebase on updated main branch? |
/build |
|
✅ Preview Build Completed!Version: 📦 Build Artifacts
📥 DownloadArtifact name: 🔐 AttestationBuild provenance attestation: View details 🧪 How to test this build
📋 Build Details
|
/build |
|
✅ Preview Build Completed!Version: 📦 Build Artifacts
|
for |
The |
can |
No as the OperationList component provided by grafana/ui just asks the queryModeller for all operation categories without any context. |
Quick question how far we are with releasing this version of datasource officially? |
@szibis Right now I don't have the exact ETA for releasing this feature. If I have any updates, I will let you know. |
@szibis @szibis Have you tried it already? |
The QueryModeller is pretty heavy to create and it would need more than just this change as there are many places where a full QueryModeller is used. Then there is the problem that nearly all operations that are placed result in a query that fails. You first need to fill it with information so that also requires knowledge. It also means limiting advanced users that might create a query out of order. And what happens when I drag a pipe to the start? The error code of vl-select is very informative and should be very easy to understand. There is always a learning curve of a new tool and after the first failed query it should be clear what is allowed. |
understand your concerns since it's a huge feature and it took significant time to implement, but i cannot agree with your statement regarding "learning curve". Builder is an intuitive tool, which should require no learning at all. by the way have you checked loki builder? it has required non-draggable filter, reusing this approach in current PR could improve UX a lot |
Add support for all operations of LogsQL in the Grafana Query Builder.
@Loori-R
#48