InfluxDB query and filter values - influxdb

cant seem to find if similar post.
I am using Grafana / InfluxDB I am trying to create a variable in Grafana, to create this variable I need to query values which I can do easily with this piece:
SHOW TAG VALUES WITH KEY = "name"
However, I need to filter the values that I get, in example, I would like only to see values that have specific url maybe just https://google.com.
I tried something like this
SHOW TAG VALUES WITH KEY = "name" WHERE "name" = 'https://google.com'
And I get only on instance of this URL, perhaps there is a way to find all the URL's which contain https://google.com

Try regular expressions, probably:
SHOW TAG VALUES WITH KEY = "name"
WHERE "name" =~ /.https:\/\/google\.com./

Related

How do i remove rows based on comma-separated list of values in a Power BI parameter in Power Query?

I have a list of data with a title column (among many other columns) and I have a Power BI parameter that has, for example, a value of "a,b,c". What I want to do is loop through the parameter's values and remove any rows that begin with those characters.
For example:
Title
a
b
c
d
Should become
Title
d
This comma separated list could have one value or it could have twenty. I know that I can turn the parameter into a list by using
parameterList = Text.Split(<parameter-name>,",")
but then I am unsure how to continue to use that to filter on. For one value I would just use
#"Filtered Rows" = Table.SelectRows(#"Table", each Text.StartsWith([key], <value-to-filter-on>))
but that only allows one value.
EDIT: I may have worded my original question poorly. The comma separated values in the parameterList can be any number of characters (e.g.: a,abcd,foo,bar) and I want to see if the value in [key] starts with that string of characters.
Try using List.Contains to check whether the starting character is in the parameter list.
each List.Contains(parameterList, Text.Start([key], 1)
Edit: Since you've changed the requirement, try this:
Table.SelectRows(
#"Table",
(C) => not List.AnyTrue(
List.Transform(
parameterList,
each Text.StartsWith(C[key], _)
)
)
)
For each row, this transforms the parameterList into a list of true/false values by checking if the current key starts with each text string in the list. If any are true, then List.AnyTrue returns true and we choose not to select that row.
Since you want to filter out all the values from the parameter, you can use something like:
= Table.SelectRows(#"Changed Type", each List.Contains(Parameter1,Text.Start([Title],1))=false)
Another way to do this would be to create a custom column in the table, which has the first character of title:
= Table.AddColumn(#"Changed Type", "FirstChar", each Text.Start([Title],1))
and then use this field in the filter step:
= Table.SelectRows(#"Added Custom", each List.Contains(Parameter1,[FirstChar])=false)
I tested this with a small sample set and it seems to be running fine. You can test both and see if it helps with the performance. If you are still facing performance issues, it would probably be easier if you can share the pbix file.
This seems to work fairly well:
= List.Select(Source[Title], each Text.Contains(Parameter1,Text.Start(_,1))=false)
Replace Source with the name of your table and Parameter1 with the name of your Parameter.

Rails SQLite check returning double

I'm using Rails to search through a SQLite table (for other reasons I can't use the standard database-model system) using a SELECT query like so:
info = ActiveRecord::Base.connection.execute("SELECT * FROM #{form_name} WHERE EmailAddress = \"#{user_em}\";")
This returns the correct values, but for some reason the output is in duplicate, the difference being the 2nd set doesn't have column titles in the hash, instead going from 0-[num columns]. For example:
{"id"=>1, "Timestamp"=>"2/27/2017 14:26:03", "EmailAddress"=>"-snip-", 0=>1, 1=>"2/27/2017 14:26:03", 2=>"-snip-"}
(I'll note the obvious- there's only one row in the table with that information in it)
While it's not exactly a fatal problem, I'm interested as to why it's doing so and if it's possible to prevent it. Thanks!
This allows you to read the values both by column index or column name:
id = row[0]
timestamp = row["Timestamp"]

youtube/v3/search - id.kind criteria

Is there a way I can specify the id.kind criteria along with the other criteria in youtube/v3/search?
I tried entering the parameter &id.kind=youtube#video in my get url it didn't work.
For the search endpoint, you can filter the type of resource returned with the "type" parameter; if you set it to "channel," for example, you'll only get back resources where the id.kind value is "youtube#channel."
Acceptable values for the "type" parameter of a search are "channel," "video," or "playlist," and you can search on multiple types with a comma-delimited list of the types you want back.

Get all the rows raleted with a specific string

I am using rails with a postgresql db, and I would like to know which is the best solution, in getting all the rows which are similar with a string.
string format: domain.com or domain.com/uk or subdomain.domain.com
db column format : http://www.test.com/All-test/test1/test2-test3/
So I would like to get from my table all the rows which are matching with my string.
Currently I have a script which is going through all the rows in my table, and taking the column values, from where it takes the host and compares it with the string.
Thank you
Looks like the LIKE function is what you want to use. You can use in in an ActiceRecord query like this:
search_string = "domain.com"
YourModel.where("db_column LIKE ?", "%#{search_string}%").first
You might need to refine the search, but the link above should give you all the tools you need

grails query for distinct entry

Hi I am trying to query my database by a specific property. Multiple entries in my database may have the same value for the property but I want it to return only the first entry that has that distinct value for the property.
For example, if my domain has a code property, then there might be an entry where "code" = "boy", and there might be another one where "code" = "girl" and there might be yet another one where again "code" = "boy". I want to query it so I get the first entry where "code" = "boy" and the entry where "code" = girl" but not the third entry where code is again equal to boy.
I was able to get the distinct code values from the database using both createCriteria() or namedQueries() but I am not able to get the whole object, just the value of code. How can I get the actual object?
Thinking about I came with an HQL query:
select d
from Domain d
where d.id = (select min(d1.id)
from Domain d1
where d1.code = d.code)

Resources