I’m trying to figure out how to convert a rather simple influxql query to influxdb2 flux but I just can’t find the correct way. This is the query:
SELECT NON_NEGATIVE_DERIVATIVE(MEAN(transmit), 10s) as transmit, NON_NEGATIVE_DERIVATIVE(MEAN(receive), 10s) as receive
FROM nics
WHERE (host = ‘somethost’)
AND time >= ‘3600s’
GROUP BY time(600s), host fill(none)
Can someone help me with this conversion?
Related
This is the SQL Code for my query
`
SELECT tbl_salaries.Mobile_PK, Len([Mobile_PK]) AS Expr1
FROM tbl_salaries
WHERE (((Len([Mobile_PK]))>10));`
Result:
I dont know what is going wrong i was working with this database for 2 months with no problems all of a sudden all my queries with relational operators are inverted. NEED YOUR HELP
Got an answer form MS Coomunity
Len function not to be used with Number field.
The direct approach is to use Mobile_PK>=1000000000
I was trying to write a simple FluxQL Query in Grafana Dashboard that uses a variable
m1(of type constant)(which contains the name of the measurement)
I created the variable m1 in grafana dashboard variables
m1 = my-measurement
and tried to run the following queries but non of them worked and they either say expression request error or No Data)
i.e
SELECT count("fails") FROM "/^${m1:raw}$/"
SELECT count("fails") FROM "/^${m1}$/"
SELECT count("fails") FROM $m1" (expression request error)
SELECT count("fails") FROM "$m1"
SELECT count("fails") FROM "${m1}"
The only query worked was without dashboard variables
SELECT count("fails") FROM "my-measurement"
How can I use the variables to work for that query.
On the similar ground I tried to make a custom variable(myVar) for which we take integer input values from user and on that basis where clause should work, but same error occurs either no data or expression request error
What I tried was
SELECT count(*) from "my-measurement-2" WHERE ("value" > $myVar)
How should I solve these issues?Please help
You may have a problem with
1.) syntax
SELECT count("fails")
FROM "${m1:raw}"
2.) data
You may correct query syntax, but query can be very inefficient. Query execution may need a lot of time - so it's better to have timefilter, which will use selected dashboard time range (make sure you have some data in that time range)
SELECT count("fails")
FROM "${m1:raw}"
WHERE $timeFilter
3.) Grafana panel configuration
Make sure you are using suitable panel - for query above Stat panel is a good option (that query returns only single value, not timeseries, so time series panel types may have a problem with that).
Generally, use query inspector to see how are variables interpolated - there can be "magic", which is not obvious - e.g. quotes which are added around numeric variables, so then it is string filtering and not numeric filtering on the InfluxDB level.
I'm trying to graph CPU temps in Chronograf from a different server on the network via the IPMI input in Telegraf.
It works fine doing the following query:
SELECT "value" FROM "telegraf"."autogen"."ipmi_sensor" WHERE time > :dashboardTime: AND ("entity_id"='3.2' OR "entity_id"='3.1') GROUP BY "entity_id"
However, in the graph the elements are named "entity_id=3.1" and "entity_id=3.2"
How can I rename those elements on the graph? I've tried this, but I'm not coming up with the right stuff:
SELECT "entity_id"='3.1' AS "CPU 1" AND "entity_id"='3.2' AS "CPU 2" FROM "telegraf"."autogen"."ipmi_sensor" WHERE time > :dashboardTime: GROUP BY "entity_id"
I'm sure this is a simple syntax fix, but I'm just learning here and I'm stumped.
I've a query that uses difference function and I can't understand why it returns no data.
The query is:
SELECT
difference(FIRST(grid_power_counter)) as grid_power_consumed
FROM homesolar.origin.main GROUP BY time(15m)
If I remove the difference function it returns data:
SELECT
FIRST(grid_power_counter) as grid_power_consumed
FROM homesolar.origin.main GROUP BY time(15m)
Also, I can get results if I add a where time > now()-24h to the select with difference function.
I really can't understand that behavior. Can someone help me?
Q: My query would only work if I add the where filter to it. Why is that so?
Quoted from influxdb's Groupby time doc:
Basic GROUP BY time() queries require an InfluxQL function in the
SELECT clause and a time range in the WHERE clause.
I suspect your first DIFFERENCE query didn't work because it was missing the mandatory WHERE filter for the Groupby time(...) function.
The Group by time() clause could be returning no rows and hence not.
This could potentially be a github issue for the influx team as I think their query parser should be complaining to you about the missing where filter for Group by time.
References:
https://docs.influxdata.com/influxdb/v1.5/query_language/data_exploration/#the-group-by-clause
How it's possible to run a collection of query like this (came from a spreadsheet copy) directly in one cypher query? one by one it's ok, but need 100 copy/paste
*******************************
MATCH (c:`alpha`)
where c.name = "a-01"
SET c.CP_PRI=1, c.TO_PRI=1, c.TA_PRI=2
return c ;
MATCH (c:`beta`)
where c.name = "a-02"
SET c.CP_PRI=1, c.TO_PRI=1, c.TA_PRI=0
return c ;
and 100 other lines ...
*********************************
you may try the 'union' clause, which joins the results of queries into one big-honkin result set:
http://docs.neo4j.org/chunked/milestone/query-union.html
That said - the root behavior of what you are trying to do could use some details - maybe there's a better way to write the query - you could use Excel to 'build' the unified query via calculations / macros, you could possibly write a unified query that combines the rules you are trying to follow, there's a lot of options, but it's hard to know a starting direction w/o context....
Talking about the REST API you can use the transactional endpoint in Neo4J 2.0, or the batch endpoint in Neo4J 1.x.
If you want to use the shell, have a look to the import page, in particular the neo4j-shell-tools where they're importing massive quantity of data batching multiple queries.