Drop data from InfluxDB - influxdb

I'm not fully understanding the structure of influxDB and I'm wishing to drop some data from it. I have the following:
net,agent_host=10.0.1.1,host=debian
net,host=debian,interface=all
net,host=debian,interface=eth0
net,host=dns1,interface=all
net,host=dns1,interface=eth0
net,host=dns2,interface=all
net,host=dns2,interface=eth0
net,host=plex,interface=all
net,host=plex,interface=eth0
I've been able to empty the series (?) net,agent_host=10.0.1.1,host=debian, but as you can see the value is still listed when I do show series.
I don't want to nuke all of the net series, but I don't want the index(?) net,agent_host=10.0.1.1,host=debian showing up. It adds extra fields in Grafana and I just don't want it.
Can I get rid of this without nuking all of the net series?
I dropped the data by issuing: drop series from net where agent_host="10.0.1.1"
EDIT: Totally forgot. InfluxDB version 1.1.1

Related

How can I render time-series data on a geographic display in grafana?

My goal is to render time-series data from set locations on a map. Essentially, I have about 30 predefined (static) locations in Switzerland from which I will be receiving real-time data. The data itself is relatively simple, just the signal/noise ratio of the signal we're receiving, which should be updated every few seconds or every minute. I am using InfluxDB as my database. Are there any specific setups I should be using for this kind of visualization?
My first question is: is it best to use the worldmap panel or the geomap panel at this time? I seem to be finding more information/documentation on the worldmap panel even though i have also read that geomap is (or at least will be) its replacement.
Second, I assume that since I'm using time-series data, that I should be using the Time-Series format, and not the Table format. However, I have not been able to render any data points using the time-series feature, even by following the simplest of examples in your documentation. The best I can do is use the Table feature, and internally remove previous points from my database at every iteration (so that multiple points aren't rendered at the same time for each location). Here are two screenshots of when I'm able to render data on the geomap using the Table format, and then after switching to Time-Series format that the points are no longer there (note that I have the same problem with the Worldmap application as well).
I'm able to render data using the Table method:
...but not using time series:
Thanks for any help!
For rendering timeseries data on the geomap, you must convert your lat/long fields to a single geohash field. You'll have to do that prior to inserting the lat/longs into influxDB
See this answer

Delete all series vs drop measurement

I want to know what's the difference between doing:
DROP MEASUREMENT A
and
DROP SERIES FROM A
Since all series and points from A are gone after any of those commands, isn't it just the same?
https://docs.influxdata.com/influxdb/v1.5/query_language/database_management/#delete-series-with-delete
The DELETE query deletes all points from a series in a database. Unlike DROP SERIES, it does not drop the series from the index and it supports time intervals in the WHERE clause.
Better use workaround to fully clean data
https://github.com/influxdata/influxdb/issues/4275#issuecomment-227219840

How to show the most recent timestamp for an InfluxDB measurement in Grafana table (or singlestat)?

I'm using Telegraf/InfluxDB/Grafana to register and view metrics for my servers. Occasionally one of these components crash and metrics stop flowing into InfluxDB.
To be able to notice when this happens (on top of using Monit to restart the service) I would like to create a Grafana dashboard where I have a singlestat panel for each host that shows the most recent timestamp (or better, how much time has passed) since the last metric was received. I'd also like to colorize the background of the singlestat depending on how long it's been. I would like to be able to do this for any InfluxDB metric, as different metrics can have different reasons for lagging behind.
Right now, I've tried something like this in InfluxQL, but I just get an error that at least one non-time field must be present in the query:
SELECT last(time) FROM "system" WHERE "load1" > -1 GROUP BY "host"
If I try to change it to this I get a "Multiple series error":
SELECT last(time), last("load1") FROM "system" GROUP BY "host"
Is what I'm trying to do not easily doable or am I missing something obvious?
...the query syntax was taken from somewhere in this issue.
I haven't yet looked at the singlestat panel, but I suggest creating a 'scripted dashboard'.
Start by manually creating a singlestat dash with a dummy number. Then export it to see what the json looks like.
Then, recreate that same json, with the live result from the above query, using a scripted dashboard.
Look in grafana's /public/dashboards for 'scripted.js' or 'scripted_templated.js'. Make a copy of one of those in the same folder, then hack away to generate your json. Here and here and here are some nice examples for the javascript magic to submit the query to influxdb and parse the result into the json for your singlestat dash. Good luck.

Adding a version to time-series data

I wish to store time series data with versioning. By versioning, I mean that I might have a metric energy_mwh with tag meter_id=123 and a fieldset something like this time=2016-01-01 10:00, mwh=20.50, read-time=2016-01-01 20:15 and if I re-read the meter at a later time I want to keep both the new and old version of the meter reading. Later when I query the data I will be mostly just interested in the mwh value with the highest read-time for any given time. If I query over a range of times the read-time is going to vary.
I am thinking of using InfluxDB or some other time series database with a similar data model.
Is there a right way of doing this? I believe that I must keep read-time as a tag - not a field or I will lose the older version of the data. I guess that is answer - but it doesn't feel right to me to have what I see as a piece of data: read-time sitting in an identifier - specifically a tag. Am I on the right track?

Grafana dynamically display new hosts added by collectd

How to get grafana to dynamically add graphs for newly added hosts? For example, I have grafana chart to display load average for existing hosts. When I add a new host, the collectd will send the new host metrics to influxdb. But every time I have to manually add one more graph in grafana which is not desired? Is there a way to get grafana automatically plot the new host metrics without changing grafana?
You have to make use of the Grafana HTTP api and update your dashboard by adding the new graph that you want. This practically means that you have to:
use the api to take the json of the dashboard
handle this data and add your extra code for the new panel that you want to add
use the api again to update the dashboard
The hierarchy is simple: a dashboard has rows and rows have panels. Probably you will have to add some json code inside panels. Go check your json file and all these will make sense to you...
You can use regexp patterns in InfluxDB 0.8 (see also the 0.9 equivalent docs) to match all your newly added hosts. InfluxDB regexps use the Golang syntax.
For example, to match all series starting with stats.cpuNUMBER:
series: /^stats\.cpu\d+/
select: avg(load)
However this way you won't get one new plot for each newly added host, but a line for every host in the same plot.
You have to add regex in your select clause.
SELECT mean(value) FROM /logstash.*.requests.count/ WHERE $timeFilter
GROUP BY time($interval)
Above script will plot each series matching above regex automatically for all hosts without changing the grafana.
logstash.ABC1.requests.count
logstash.ABC2.requests.count
logstash.ABC3.requests.count
When ABC4 host is added and it is shipped correctly, new graph will be plotted automatically.

Resources