I am new to InfluxDB and I hope this isn’t too ignorant a problem But I’ve spent days on this and I do not know what I am not seeing.
I have generated a dataset )which represents expenses) using the line protocol and I want to create a simple line graph using this dataset, which I want to display using Grafana
Here is a snippet from the dataset I’m importing:
transaction,source=csv,category=none amount=-134.06,description="example description text" 1610409651297000000
transaction,source=csv,category=food amount=55.08,description="example description text 2" 1610520338723000000
transaction,source=csv,category=none amount=1000,description="example description text 3" 1610541142475000000
My problem is that InfluxDB/Grafana will always create a separate line for each of the tags. However, the tags only represent metadata. I only want so see a single line representing all expenses from the dataset.
Influx is a time series database. Meaning that timestamps are important. Looking at the sample data set, all three have unique timestamps. So pr default they will end up on separate lines. You need to either make sure they have the same timestamp when inserting into the database. Or you need to modify the time stamps (large every in aggregateWindow) for example.
When you have matching timestamps you should be able to use pivot() to “flatten” the data.
I have a question, though: Since Influx is a time series database, why should the timestamps be unique? Each datapoint should be on a different timestamp, I would assume.
In my scenario every datapoint represents an expense which naturally has a timestamp. Or do I misunderstand the timestamps in line protocol?
From you original post, my understanding is that you want a single line?
To accomplish this you need to have same time for all the points on the same line when viewing - provided you want the output to be a time series as well. The timestamp is the key influx uses to figure out which of the datapoints belong together.
If the timestamps on ingestion to the database are different for all items, you need another time for influx to collect the data on. Hence the every in aggregateWindow needs to be “large”. Large here being relative to the data. Do you want an aggregated line pr day? Pr hour? Pr week? That depends on the use case. If your use case is for a restaurant - perhaps pr hour would make sense? For a household, perhaps pr day would make more sense?
I also notice that you use meanas the aggregate function. Also depending on use case. For a restaurant perhaps mean makes sense to see how the spending patterns is distributed for lunch vs dinner customers. For a family budget perhaps sum is more interesting.
This is generally correct, only there are two separate charts for each of the category tabs (food/none). I want InfluxDB to completely ignore that there is a category tag at all. It is not relevant for this graph.
Thank you!
This feels like the right solution, but somehow I end up with this. It looks like one line alright, but still not quite what I was expecting