Writing data over Influx HTTP API returns OK, but table is empty - influxdb

I'm writing batched data over HTTP API like this
demo,state=idle
max=100.0,mean=20.0,event_type=0,probability=0.6,min=0.0 1529087114083
demo,state=idle
max=100.0,mean=80.0,event_type=1,probability=0.6,min=0.0 1529087114083
demo,state=idle
max=100.0,mean=20.0,event_type=2,probability=0.6,min=0.0 1529087114083
demo,state=idle
max=100.0,mean=80.0,event_type=3,probability=0.6,min=0.0 1529087114083
And the request returns 204 which is "ok" according to Influx API docs.
Still, when I want to check my data in admin
SELECT median("mean") AS "median_mean", mean("mean") AS "mean_mean"
FROM "sfb"."autogen"."demo" WHERE time > now() - 1h GROUP BY
:interval: FILL(null)
I get
Your query is syntactically correct but returned no results

Solved: need to specify proper timestamp precision - otherwise it calculates wrong data and data is not visible

Related

influxdb - some values become null when request with mean() or median()

i have an issue with influxdb query.
when I query normally:
SELECT "distance" FROM "testdb"."autogen"."laserdistance" WHERE time > timeA AND time < timeB
I will get back all the data without error.
if I query with either mean() or median():
SELECT mean("distance") AS "mean_distance" FROM "testdb"."autogen"."laserdistance" WHERE time > timeA AND time < timeB GROUP BY time(some_interval) FILL(null)
I will sure get back some null value in a very inconsistent pattern(sometime a lot, sometime not so much).
I understand that FILL(null) is the one responsible for the null issue to fill in the interval that don't have value.
is there a way to get the nearest value instead of fill it with null?
Use FILL(linear):
linear - Reports the results of linear interpolation for time intervals with no data.
Doc: https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#group-by-time-intervals-and-fill

grafana-influxdb get multiple rows for last timestamp

I am using telegraf-influxdb-grafana together. But I could not get rows for only last timestamp.
Here is what I am doing;
Collecting DB statistics(Running queries at that time) with Telegraf(exec plugin).
Storing output to influxdb
Trying to monitor running queries over grafana
But I need to get all rows at last timestamp.
Here is what I've tried;
> select * from postgresql_running_queries where time=(select max(time) from postgresql_running_queries)
ERR: error parsing query: found SELECT, expected identifier, string, number, bool at line 1, char 54
Here is what I want to see;
Time DB USER STATE QUERY
2017-06-06 14:25.00 mydb myuser active my_query
2017-06-06 14:25.00 mydb myuser idle in transaction my_query2
2017-06-06 14:25.00 mydb2 myuser2 active my_query3
Can any one help me to achive this?
I am open to any solution.
select last(fieldname) from measurment_name;
Query in this format will return last timestamp data from the InfluxDB.
But I am surprised with the fact that you are expecting 3 values for a single timestamp (unless you have different TAG values, refer this documentation how to store duplicate points). You will a ONLY ONE record for a given timestamp. InfluxDB overwrites previous content if there is another entry for same timestamp, here is why.
Your results will be something like (if you don't have different TAG value):
Time DB USER STATE QUERY
2017-06-06 14:25.00 mydb2 myuser2 active my_query3
EDIT:
Based on comment, my guess is you are using TAGs to differentiate, still above query should work, if not, you may try by adding WHERE clause.

YQL error into pressure when use u=c

good morning,
I starting to use a YQL for extract a weather condition for my town.
I live in Italy and set the query with u=c parameter, but in this case the pressure value is wrong.
If I request without u=c the query return:
atmosphere
pressure "1006.0"
but if I send a query with u=c return is:
atmosphere
pressure "34067.08"
my query is:
https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="codogno,it") and u=c&format=json
I think Yahoo got it wrong. So if you requested u=c then it returns millibars but it is not expected value you must convert it to inch then you got the real millibars.
then if you requested u=f then it returns in but it is not as expected value it is a millibars so you must again convert it to an in.
Maybe we should consider a new provider.

Twitter search api with hindi characters in the query returns 403 error

I am receiving 403 error from search api when using this query:
"सार्वजनिक स्वास्थ्य जॉन्स हॉपकिन्स विश्वविद्यालय" OR "एमए एन ए
पौष्टिक सहायता उत्पाद निगम" OR "मेडिसिन्स सैंस फ्रंटियर्स"
Error I have got from Twitter's api is:
{exceptionCode=[8e13056f-6071abbc], statusCode=403, message=Missing or
invalid url parameter., code=195, retryAfter=-1,
rateLimitStatus=RateLimitStatusJSONImpl{remaining=447, limit=450,
resetTimeInSeconds=1464249586, secondsUntilReset=695}, version=4.0.1}
It is strange because if I cut any element from original query it works.
The request I send is:
https://api.twitter.com/1.1/search/tweets.json?q=%22%E0%A4%B8%E0%A4%BE%E0%A4%B0%E0%A5%8D%E0%A4%B5%E0%A4%9C%E0%A4%A8%E0%A4%BF%E0%A4%95%20%E0%A4%B8%E0%A5%8D%E0%A4%B5%E0%A4%BE%E0%A4%B8%E0%A5%8D%E0%A4%A5%E0%A5%8D%E0%A4%AF%20%E0%A4%9C%E0%A5%89%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B9%E0%A5%89%E0%A4%AA%E0%A4%95%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B5%E0%A4%BF%E0%A4%B6%E0%A5%8D%E0%A4%B5%E0%A4%B5%E0%A4%BF%E0%A4%A6%E0%A5%8D%E0%A4%AF%E0%A4%BE%E0%A4%B2%E0%A4%AF%22%20OR%20%22%E0%A4%8F%E0%A4%AE%E0%A4%8F%20%E0%A4%8F%E0%A4%A8%20%E0%A4%8F%20%E0%A4%AA%E0%A5%8C%E0%A4%B7%E0%A5%8D%E0%A4%9F%E0%A4%BF%E0%A4%95%20%E0%A4%B8%E0%A4%B9%E0%A4%BE%E0%A4%AF%E0%A4%A4%E0%A4%BE%20%E0%A4%89%E0%A4%A4%E0%A5%8D%E0%A4%AA%E0%A4%BE%E0%A4%A6%20%E0%A4%A8%E0%A4%BF%E0%A4%97%E0%A4%AE%22%20OR%20%22%E0%A4%AE%E0%A5%87%E0%A4%A1%E0%A4%BF%E0%A4%B8%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B8%E0%A5%88%E0%A4%82%E0%A4%B8%20%E0%A4%AB%E0%A5%8D%E0%A4%B0%E0%A4%82%E0%A4%9F%E0%A4%BF%E0%A4%AF%E0%A4%B0%E0%A5%8D%E0%A4%B8%22&count=100&since=2016-05-23&with_twitter_user_id=true&include_entities=true
Do you have any idea what is wrong?
You just hit a query limit, you can get similar failures with even a simple repeated A OR B query once it gets over the max length.
https://dev.twitter.com/rest/reference/get/search/tweets
q: A UTF-8, URL-encoded search query of 500 characters maximum,
including operators. Queries may additionally be limited by
complexity.
Since you want an OR, you should probably query 3 times and union the results in your code.

YQL sample query returns max 260 results

I am following YQL sample query
select * from local.search(500) where query="sushi" and location="san francisco, ca"
but I get 260 max count instead of 500. I tried also to use limit 500 after 'where' and different keywords, always get maximum 260 results. How do you increase it?
The underlying API that the local.search table uses (Yahoo! Local Search Web Service) has restrictions on the number of results returned.
The results parameter (the number of results "per page") has a maximum value of 20.
The start parameter (the offset at which to start) has a maximum value of 250.
Since you ask for the first 500 results, YQL makes multiple queries against the Local Search API returning 20 results at a time. Therefore the start values are 1, 21, 41, ... 241. This brings back 260 results, as you have seen.
Since the YQL query asks for more results, the next start value is tried (261) which is beyond the allowed range so the underlying service returns an error (with the message "invalid value: start (261) must be between 1 and 250"). If you turn on "diagnostics" in the YQL console, you will see the "Bad Request" being returned.
Nothing you do to the query will bring back more results than the underlying service allows.
I figured out, I was missing paging number, so 0++ will work
select * from local.search(0,500) where query="sushi" and location="san francisco, ca"

Resources