Query for stacked bar graph

I’m new to InfluxDB and Grafana so please bear with me…

I’d like to create a graph that shows daily bars of stock quotes. Stacked on top to show the total portfolio value, per day. Though it would be nice if I could zoom in and show bars for arbitrary periods like 5m, should data be available with that resolution. I prefer to not put a hardcoded timestamp on the InfluxDB data, but let grafana figure it out when drawing the graph (if possible).
For now I’m using a script that polls stock quotes and inserts them into InfluxDB one by one. This means timestamps are slightly different for each quote (the script takes a couple seconds in total).

I’ve had some success with a query where I use the quote-name tag in a GROUP BY clause. This appeared to work when I had only one measurement but when more were added things got screwed up. I’ll try to add some screenshots but I think this is a simple usecase, I just have a hard time wrapping my head around all these concepts which are new to me. Can I solve it in the query? Do I need to fiddle with resolution and retention policies? Do all measurements need to have the exact same timestamp when inserting into InfluxDB?


Not really sure what you’re trying to achieve here. Screenshots would probably help.

Have a look at stack documentation for graph panel.

Have a look at this example on the play site and change the Draw modes to only have bars selected.


Thanks for pointing me to the play site, that’s actually a great source of help/inspiration.

I resolved my issue by adding a time(auto) to the group-by clause and increasing the min time interval. I also found out the schema doesn’t really work out as InfluxDB doesn’t support joins or merging series from different measurements. And it’s a bit unfortunate you can pick a unit type (currency, in my case), but that doesn’t cause the value to be formatted like a currency. For single stats I can use the ‘locale’ unit type to format a currency amount but when I do that on a graph it makes the legend disappear… But at least I’m having fun, and feel like it’s finally starting to make sense :wink: