Hello - I am brand new to Grafana, trying to following the “Getting Started” and “Introduction” documentation, but I’m hopelessly lost trying to map time series dimensions (which is what I think I want, though the term is new to me) I have Grafana 10 installed locally along with the SQLite data source plugin, and a sample DB that looks like this.
CREATE TABLE temperatures (
site VARCHAR,
time VARCHAR,
temp NUMBER
);
INSERT INTO temperatures VALUES ('New York', '2023-11-02T00:00:00Z', '33.4');
INSERT INTO temperatures VALUES ('New York', '2023-11-02T00:02:00Z', '32.3');
INSERT INTO temperatures VALUES ('New York', '2023-11-02T00:04:00Z', '31.2');
INSERT INTO temperatures VALUES ('Los Angeles', '2023-11-02T00:05:00Z', '65.7');
INSERT INTO temperatures VALUES ('New York', '2023-11-02T00:06:00Z', '32.3');
INSERT INTO temperatures VALUES ('Los Angeles', '2023-11-02T00:07:00Z', '66.2');
INSERT INTO temperatures VALUES ('New York', '2023-11-02T00:08:00Z', '34.2');
INSERT INTO temperatures VALUES ('Los Angeles', '2023-11-02T00:09:00Z', '66.3');
INSERT INTO temperatures VALUES ('New York', '2023-11-02T00:10:00Z', '33.3');
INSERT INTO temperatures VALUES ('Los Angeles', '2023-11-02T00:11:00Z', '64.9');
Here, I’m mapping temperatures for two different cities. For several minutes only New York reports temperatures, then Los Angeles also begins reporting. Each city checks in every two minutes: NY on the even minutes and LA on the odd minutes.
I would like to have a graph that shows a single timeline (in this case for 11/2/2023 from 12:00AM to 12:11AM) with a graph showing both cities on it and their temperature changes. This seems like a pretty common thing (comparable to showing, say, CPU usage changing on two different hosts over the same span of time).
But I cannot gather from the documents how to accomplish this. My SQL skill is somewhat middling, and a simple query of SELECT site, time, temp from temperatures ORDER BY time
only produces tabular output and no graphs at all. Changing the query to SELECT site, time, temp from temperatures ORDER BY time
gives a single graph that bounces back and forth, which isn’t what I want (and of course with no indication of site).
The docs seem to indicate that dimensions can be managed by a GROUP BY clause, but doesn’t seem to give any examples I can make use of. I tried SELECT site, time, temp from temperatures GROUP BY site, time ORDER BY time
but that didn’t seem helpful.
Can anyone help me get started with this query? What I’d really like to do would be to have a single timeline that can show, say, the changing temperatures for 10 cities.
Thanks to anyone who can help!