Is there any way to enable/disable log queries in Grafana based on a multi-variable? - grafana

I have a Grafana dashboard with a Logs panel. The panel has 3 separate queries: A, B & C. Each query filters the log data in a different way and displays the results in a different way. Having all 3 queries in the same panel rather than in separate panels is helpful because the results get displayed chronologically in relation to each other. By default I have A & B enabled, with C disabled.
I would like to be able to toggle each one on/off by selecting options from a variable drop-down instead of having to "Edit" or "Explore" the log panel, but can't quite work out how to do that.
So far, I have created a custom multi-select variable called LogTypes which can have any combination of the values Verbose, Messages & Errors. I initially (naively) tried changing the start of query A from:
{app="$app"}
to:
{app="$app", "Messages"=~"$LogTypes"}
to essentially try to only "enable" query "A" when Messages was selected as a Log Type, but it seems that LogQL expects "Messages" to be an identifier rather than a string. Is there another way to compare a constant string to a variable string in order to turn the query on/off like this?
Alternatively, is there some other functionality that I should potentially be looking at to achieve the same result?

Related

Advanced tag filtering not working for more than one tags selected in same collection

The problem I'm having right now is related to advanced filtering in shopify theme "Fashe"
I have made certain filter groups in my store using advanced filtering by group option. But when i choose a filter in one category, I want other filters to be updated as well related to that category.
Like If i choose collection type to be of one kind, i want the collection colors to be related to those kind only. right now it shows me all the colors available in my store. If choosing one filter, it should change the values in other filters also based on the collection type.
If somebody has this issue resolved, I would be very much pleased if you help me with this.
SECOND THING
One more issue is when I select filter A, the theme gives me the results associated with that filter but when i click Filter B (filter A being selected already) the theme gives me no results instead it shows that no products matching. Somebody with this issue???
Example: www.mytheme/collections/fine/opt1+opt2
This works as an AND statement. But I want to show results from both, opt1 and opt2.
Shopify should work with OR statements. Like combined results of filter A and Filter B.

Filtering a datasource using multi select wild character

Does anyone know if there is a wildcard character in AppMaker that can be used for all possible values for a field in a query?
I currently have a datasource that is being filtered based on the status using a multi-select widget. What I would like to accomplish is when all values have been de-selected I want to load all the records of that datasource without clearing the entire query in case other filters have been applied. I have it working in-a-sense that I have to explicitly construct my query as such:
widget.datasource.query.filters.Status._in = ['Status Value 1','Status Value 2','Status Value 3']
My current solution is loading the correct data when a value is selected and it correctly shows the union of the query as the values are modified. However, it selects all of the values in my multi-select; which I know is how it is supposed to work.
I tried using widget.datasource.query.filters.Status._contains = ''; and changing the assignment value to no avail. I even tried the opposite approach using _notContains
The intended outcome is to have a filtering dashboard appear much like any website where when no filtering is selected all records are displayed. I was hoping to find a wildcard character that would load all of the records. Just trying to find a way to mimic other website filters with all records when none are selected.
Thanks for the time!
So the easiest solution here is to set up your Multiselect as follows:
Options binding:
#models.YourModel.fields.Status.possibleValues
or if you don't have the possible Status values in your model then set your options binding to:
['Status Value 1','Status Value 2','Status Value 3']
Values binding:
#datasource.query.filters.Status._in
Now anytime you select any choices in the multiselect, the query will only include records that include the selected choices. And if you deselect all choices the query will ignore that filter or treat it as an empty array of values, therefore returning all records unless you applied other filters.

how to create multiple filters from one dimension tableau (10)?

I have a two dimensions with the following data set
Original Dimension
I would like to create two filters that can be used to filter my dashboard. These two filter would be called - "Product_Type" and "Product" and should have the following drop downs:
Filter Breakdown
To summarize, I am looking for a way to take my original dimension and create the filter breakdowns so that in my dashboard I can have two filter (Product_type and Product). When i click on the Product_type filter, i should be able to see "overall", "fruits", "vegetable" and "leafy. Based on my selection , the Product filter should automatically show only the relevant values - i.e. if i picked "leafy" it should only show "spinach" and "kale". Finally if i select "kale" my entire dashboard should change accordingly.
Looking for a way to do this without drastically affecting the performance.
update: i was able to achieve this by creating multiple parameters and then using the pop window technique (https://vimeo.com/107352893) - but this has affected my workbook performance very badly. Need another solution!!
You should be able to accomplish your desired functionality by creating a calculated field for product type and a CASE statement to classify the products based on the product type you specified your image.
Further, filters can be configured to display available values based on the other filters in place. I would recommend having your Product Type filter a the "context" or "data-source" level, and your product filter at the lowest level, so that the selectable options for the product filter can be displayed using the "only relevant Values" option and limits the products that can be chosen.
Please see the following link for some more information on filtering hierarchies
Performance Related
General Filtering
Blog Post
"Only relevant values - Specifies which values to show in the filter. When you select this option other filters are considered and only values that pass these filters are shown. For example, a filter on State will only show the Eastern states when a filter on Region is set. You can use the toggle at the top of the filter card to switch between this option and the All Values in Database option.
All values in database - Specifies which values to show in the filter. When you select this option all values in the database are shown regardless of the other filters on the view.
All values in context (Tableau Desktop only) - When one of the filters in the view is a context filter, select this option on a different filter to only display values that pass through the context filter. For more information, see Improve View Performance with Context Filters."

Run VBA code after form load

I have this continuous form "Results" built on a "Search" query in Microsoft Access and I want to show a hidden text field "Number" (with its Visible property initially set to False) depending on the value of one query result written in a "Type" combo box. My code is currently as follows:
Private Sub Form_Load()
If Me.Type="Reclamation" Then
Me.Number.Visible=True
Else: Me.Number.Visible=False
End If
End Sub
This does not seem to work, however the code does fine when triggered by a change event. Adding, changing and deleting records are also disabled in "Results".
Should I run code from a macro, on the query or try another event (I've tried many events though with no success)?
Thanks for the help, and sorry for the noob question!
Continuous Forms behave differently than what you think. It cannot work with UnBound Controls. If the control Number is bound it will take effect on only the Record that has foucs. Using Form Current combined with Load should/might work, but again it will not be the best solution. Because it will be applied to all other records in the SubForm.
Example of what I mean is, if the form has three records. First Record has Type (a terrible field/control name) "Reclamation" then the "current" record's Number (again a very bad field/control name) will be hidden along with all the other record's Number, even if they have other Type's in their record.
I would suggest you to go with Single Form.

"The data has been changed" error when editing underlying record in Access VBA

I have a form in Access where I have 2 unbound multi-select listboxes, with some code to move items between them.
Each of the fields in the table which are shown in the listboxes are boolean values - if the value is true then the name of that field shows up in lstSelected, and if false shows up in lstUnselected.
The listboxes have a RowSourceType of Value List, and the value list is generated programatically by looking at the underlying record and constructing a string with the field names where the boolean values are true for lstSelected and False for lstUnselected.
On the form I have two buttons, cmdMoveToSelected and cmdMoveToUnselected. When I click on cmdMoveToSelected it changes the boolean value of the underlying field for any selected items in the lstUnselected listbox from false to true by executing an SQL string, then rebuilds the value lists for both of the listboxes.
I have all of this working just fine. If I do a me.lstUnwanted.requery and a me.lstwanted.requery then everything moves and shows up correctly, and the underlying fields are edited correctly, BUT when I click on anything else on the form I get the error:
The data has been changed.
Another user edited this record and saved the changes before you attempted to save your changes.
Re-edit the record.
Now I've found a way around this (jobDetailsID is the primary key of the record being dealt with):
Dim intCurID as Integer
intCurID = Me.JobDetailsID
Me.Form.Requery
Me.Recordset.FindFirst "JobDetailsID = " & curID
This requeries the form and then moves back to the current record, and this gets rid of the error, however it causes there to be a delay and the form to flicker while it opens back at the first record, changes back to the correct record and repopulates the list boxes.
Is there a way to do away with this error, or get it to trigger programmatically so I can catch it by turning the warnings off via vba?
Thanks in advance.
Maybe it helps not to bind the form to the table being altered by cmdMoveToSelected, but to a query that doesn't contain all the boolean fields. If cmdMoveToSelected alters one or more boolean fields, the record is changed, but the query result isn't. Not sure if it's sound though.
It also sounds a bit like a design problem rather than a form problem, storing options in boolean fields instead of into a related table.
Probably the best solution would be to not directly update the current record in the table while the Form is dirty. Instead, update the values of the fields within the form itself (Me!FieldName) as the items are moved from one List Box to the other, and let the form write those values back to the table as usual.
I seem to have fixed it, though the fix doesn't make a great deal of sense to me.
I added in a Me.Refresh to the button click code, after I had requeried the two listboxes and it appears to have stopped the message from coming up. However this only works when I have the JobDetailsID textbox visible on the form (though I expect this is arbitrary and any field-linked textbox would work).
Can anybody explain to me why this works? I'd like to understand fully when to use requery, refresh etc
I've had this sort of thing happen when I've left the form RowSource query hanging in place after converting the controls to unbound textboxes, etc. The general Form rowsource query (to bring in all fields I might possibly end up using) provides me with a query-list identical to the table fieldnames, making it simple to select them for control-names as needed. Works fine, but you have to remove the form rowsource query after all the names are matched-up. (After which DLookup and BeforeUpdate works for getting and storing values and changes.)