Data Studio: Turn a parameter into a Data Source Filter - dashboard

So I have a parameter which I have used for some calculations in the report. I also have a data source filter which uses the same labels. Currently I am using both but want to combine them to reduce steps while filtering.
Data source filter is "Region Distribution"
Parameter is "param_Region"
"param_Region" currently only filters the three calculations named leadGoals, MQLGoals and SQLGoals.
"Region Distribution" filters everything but it messes up the calculation.
They both have same labels so I would like to combine them so just one filter affects the whole dashboard.
Here is the dashboard: https://datastudio.google.com/u/0/reporting/8ee516a9-e93e-4b2f-b782-871d6c6a42f9/page/WdShC/edit
Here is the data source: https://docs.google.com/spreadsheets/d/1Jc3T5S0EqblsEb61-z_7XQuwH0qq2Ccrm0FFv66KqGY/edit#gid=0

To apply filting data by selecting a parameter:
generate a new field to compare the parameter value with the values of the field:
param_Region = "all"
OR UPPER(param_Region) = UPPER(Region Distribution)
Add a filter for that new field.
Apply this filter to any graph.

Related

Grafana Value Mapping an Array

So I'm using grafana to display some data in a table. So in my grafana table I have a column named 'request_types'. Its value is represented by an array such as
["all"], ["Music", "Film"], ...etc
What I'm trying to do is create value mappings in grafana to map the array to specific values. For example
["all"] -> "All"
["Artist", "Film"] -> Artist, Film
How can I achieve this in grafana? Is value mapping the only option I have?
So in order for me to achieve this I had to create a custom data source plugin. Basically my data source plugin makes an http request to retrieve Elasticsearch data. From there I can write some typescript to manipulate my data.

How can I sort the legend by series name in Prometheus/Grafana

I have a Grafana dashboard panel configured to render the results of a Prometheus query. There are a large number of series returned by the query, with the legend displayed to the right. If the user is looking for a specific series, they have to potentially scroll through all of them, and it's easy to miss the one they're looking for. So I'd like to sort the legend by series name, but I can't find any way to do that.
My series name is a concatenation of two labels, so if I could sort the instant vector returned from the PromQL query by label value, I think Grafana would use that order in the legend. But I don't see any way to do that in Prometheus. There is a sort() function, but it sorts by sample value. And I don't see any way to sort the legend in Grafana.
As far as I know, You can only use the function sort() to sort metrics by value.
According to this PR, Prometheus does not intend to provide the function sort_by_label().
According to this Issue, Grafana displays the query results from Prometheus without sorting.
According to this Issue, Grafana supports sorting by value when displaying legend.
In Grafana 7, Prometheus metrics can be transformed from time series format to table format using the Transform module, so that you can sort the metrics by any label or value.
Prometheus doesn't support sorting results by series names as mentioned in https://stackoverflow.com/a/65353296/274937 . If you still need sorting results by metric name or by arbitrary set of labels, then take a look at VictoriaMetrics. It provides sort_by_label and sort_by_label_desc functions. For example, the following query sorts time series returned by query by metric names:
sort_by_label(query, "__name__")
The __name__ refers to metric name. See these docs for more details.

How to add filter to a custom query on Data Studio?

I'm building a dash using Data Studion and I need to create a custom query using CASE WHEN statments. The problem is that the conditions must be the values selected through a filter. How can I get the value selected on the filter and use it as a parameters on my query?
you can not , the only parameter that can be passed from a filter is dates as per this documentation https://support.google.com/datastudio/answer/6370296?hl=en
all you can do is vote for this feature request
https://issuetracker.google.com/issues/142183085

Elasticsearch + Logstash: How to add a fields based on existing data at importing time

Currently, I'm importing data into Elastic through logstash, at this time by reading csv files.
Now let's say I have two numeric fields in the csv, age, and weight.
I would need to add a 3rd field on the fly, by making a math on the age, the weight and another external data ( or function result ); and I need that 3rd field to be created when importing the data.
There is any way to do this?
What could be the best practice?
In all Logstash filter sections, you can add fields via add_field, but that's typically static data.
Math calculations need a separate plugin
As mentioned there, the ruby filter plugin would probably be your best option. Here is an example snippet for your pipeline
filter {
# add calculated field, for example BMI, from height and weight
ruby {
code => "event['data']['bmi'] = event['data']['weight'].to_i / (event['data']['height'].to_i)"
}
}
Alternatively, in Kibana, there are Scripted fields meant to be visualized, but cannot be queried

Sorting string column in Kibana visualization

I have a status field in my elastic search index which can take values Open,Closed,Clear,Intermediate,Ready for Approval. Right now, I have created a visualization and sorted this field descending based on the Term. What I want to achieve is - I want this to be sorted in this particular order Open,Clear,Intermediate,Ready for Approval,Closed.
How do I achieve this? One option I am thinking is creating a scripted field and prefixing with integer column, but I am not sure if I will be able to filter the visualization later?
If this list of possible values is a static list of known values, there is another way to define your visualization with a little more manual configuration. Just replace your terms aggregation with a filters aggregation and add custom filters for the possible values like so:
Kibana will respect the order of your filters in the visualization. From a performance perspective, this should also be better than using a scripted field...

Resources