Example Graph SQL Server doesn't work

Hi everyone!

I am a new user of Grafana. In order to understand how it works, I used this link.

I put the correct settings in SQL Server in local (after a lot of work).

I create a new Dashboard.

There are the data from SQL Server:

2018-03-15 12:30:00.000 Metric A 62 6
2018-03-15 12:30:00.000 Metric B 49 11
2018-03-15 13:55:00.000 Metric A 14 25
2018-03-15 13:55:00.000 Metric B 48 10

But it not shows any data in Graph:

There are no data in Graph:

What happened? It seems there are not errors, but I don’t understand.

Thank You

If in the mysql command line you run
select * from metric_values sort by time desc limit 1;
what does it show? Include the column headings in the post.

Did you refer Graph or Table?

I think it is not correct

I disable the encryption with no results

Thanks

Sorry, it should be order by, not sort by.
However, I did not mean in Grafana, but in a command line mysql client running in a terminal window. That way you can find out what is in the database without involving Grafana, so you can tell whether the problem is with the data in the db, or with Grafana.

The problem is with Grafana, because if I type in SQL Management Studio:

select * from metric_values

There are the values of the database:

|2018-03-15 12:30:00.000 |Metric A |62 |6|
|2018-03-15 12:30:00.000 |Metric B |49 |11|
|2018-03-15 13:55:00.000 |Metric A |14 |25|
|2018-03-15 13:55:00.000 |Metric B |48 |10|

Regards

Look at the dates. Have you selected those dates for viewing in the graph?

I did exactly like the Example (Time series queries).

The query one:

SELECT
  time,
  valueOne,
  measurement as metric
FROM
  metric_values
WHERE
  $__timeFilter(time)
ORDER BY 1


And the query two

SELECT
  time,
  valueOne,
  valueTwo
FROM
  metric_values
WHERE
  $__timeFilter(time)
ORDER BY 1

There are no data in any case.

![imagen|625x500](upload://o25gHY3Bla8qfvOiRZRBe9dXAIx.png) 

I don't know what am i doing bad. 

Regards

Sorry ther post repeat, I didn’t put the quotes very well.

I did exactly like the Example (Time series queries).

The query one:

SELECT
time,
valueOne,
measurement as metric
FROM
metric_values
WHERE
$__timeFilter(time)
ORDER BY 1

and the other

SELECT
time,
valueOne,
valueTwo
FROM
metric_values
WHERE
$__timeFilter(time)
ORDER BY 1

And the result is this:

I don’t know where the error is.

Regards

What time range are you looking at on the chart? It looks as if it is probably showing todays data (you haven’t posted a full screenshot so we can’t see). Unless there is data for that time range then nothing will be shown. The data you posted is for 2018 so unless the chart is showing that time range then nothing will be shown.

I am looking any time range. It’s only to know how I can make the graph with the database like the example (well, doing the same steps).

In the example I try to do the same example creating the tables in SQL Server.

CREATE TABLE [event] (
time_sec bigint,
description nvarchar(100),
tags nvarchar(100),
)

CREATE TABLE metric_values (
  time datetime,
  measurement nvarchar(100),
  valueOne int,
  valueTwo int,
)

INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES('2018-03-15 12:30:00', 'Metric A', 62, 6)
INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES('2018-03-15 12:30:00', 'Metric B', 49, 11)
...
INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES('2018-03-15 13:55:00', 'Metric A', 14, 25)
INSERT metric_values (time, measurement, valueOne, valueTwo) VALUES('2018-03-15 13:55:00', 'Metric B', 48, 10)

And after it, I launch the queries like the example:

And they are not working.

For this reason, I would like to know what happen and if there is a mistake or a concept that it is not good developed.

Regards.

Ah, and how I can show the 2018 data posted?

Regards

Click on ‘Today’ in the top right hand corner.

Hi again,

It doesn’t work today and Last 5 years.

Regards

Sorry, I am out of ideas. However, I do note that another user in a thread earlier today did get the same example running ok.

Hello, i have the same issue. you following the tutorial from docs grafana right? try to change the time values, change to today date, and if still not solved, change the value become “CURRENT_TIMESTAMP”, without ("), and change custom range become today, hope this helps.

Regards

@kurace

Try to use TimeSeries format and write a single query for each one value you need to display in the graph/line chart with each having it’s own metric name or whatever.

SELECT  $__time(time)
        , valueName 	    		
 	    , 'measurement' as metric
FROM tableName
WHERE $__timeFilter(time)

You will see the option in the Metric tab in the area you write the queries an option at the bottom labeled Add Query.

Each query you add should have its own metric and select the needed value to display as that metric. So have each added query contain only 3 records: time, value, and metric. If you need to display another value as another line in the same graph, then build an additional query with only the three needed records for it.

Be sure to use the $__time() macro and put the time column name in it for the select portion of the query, and also be sure to use the $__timeFilter() in the WHERE clause as you have been giving it the time column name too.

Hopefully you can resolve with these very simple steps and get the data to display as expected as that’s the way which seems to always work best for me.

1 Like

Thanks for all people. It works, and now I am going to learn about Grafana.

Regards!!

1 Like

@kurace

What was your final and working solution with MS SQL with your type of query, how did you write it syntax wise, what options did you use, etc.? Explaining this with a little more detail will help keep the post helpful to others potentially.

I wasn’t sure if you wrote the query and use the options as i listed in my response or if you used some other specific options and method for writing your query for the data graphing needs?