# Grafana graph data source microsoft sql server

**URL:** <https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147>\
**Category:** Grafana\
**Created:** [April 9, 2019, 7:20am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147 "2019-04-09T07:20:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 9, 2019, 7:20am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/1 "2019-04-09T07:20:07Z")

</div>

Hallo, im new user on grafana, i try to make a time series dashboard in grafana and i follow the tutorial in this link. [http://docs.grafana.org/features/datasources/mssql/](http://docs.grafana.org/features/datasources/mssql/)

I try this query: ```  
SELECT  
time,  
valueOne,  
measurement as metric  
FROM  
metric\_values  
WHERE  
$\_\_timeFilter(time)  
ORDER BY 1

```auto

but still no data points, but no error with the query, i need help, please correct me if my query is wrong. Thanks
```

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 9, 2019, 8:20am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/2 "2019-04-09T08:20:43Z")

</div>

Have you seen this recent thread?

> [@Example Graph SQL Server doesn't work](https://community.grafana.com/t/example-graph-sql-server-doesnt-work/16093):
>
> Hi everyone! I am a new user of Grafana. In order to understand how it works, I used this [link](http://docs.grafana.org/features/datasources/mssql/). 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 h…

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 9, 2019, 9:00am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/3 "2019-04-09T09:00:34Z")

</div>

Hi, thanks for repply!

Yes, i already read that thread but i think is it not solved yet.

Regards,  
Malik

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 9, 2019, 9:12am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/4 "2019-04-09T09:12:01Z")

</div>

Well to save me asking all the same questions again, start by answering all the questions from that thread.

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 9, 2019, 9:20am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/5 "2019-04-09T09:20:15Z")

</div>

Thanks for your support, i already read and try your suggestion. Before that i think this is because 2018, so the value cannot be displayed, but i changed with 2019, and change “today” in grafana. but still no data point. do you have any suggestion? thanks !

Regards

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 9, 2019, 9:32am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/6 "2019-04-09T09:32:52Z")

</div>

Show us what the raw query shows, from an application other than grafana, and show us a screenshot showing the query and the graph.

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 9, 2019, 9:46am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/7 "2019-04-09T09:46:27Z")

</div>

Hi, i think this is already solved yet. but still use manual querys like “INSERT INTO [Dev].[dbo].[metric\_values] (time, measurement, valueOne, valueTwo) VALUES (‘2019-04-09 14:03:00’, ‘Metric A’, 62, 6)”.

 ![Yes](https://us1.discourse-cdn.com/grafana/original/2X/2/2b41907fcfd0084972a6de827c61e061b8ee16d3.png)

How can i change the date to automatic time? i try to used “current\_timestamp” but this is did not worked.

I create table like this:  
 ![Metric_values](https://us1.discourse-cdn.com/grafana/original/2X/0/0400d58e082bf85384d3fa6719dd4fe4d1c6b980.png) .

Regards

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 9, 2019, 9:57am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/8 "2019-04-09T09:57:13Z")

</div>

Not sure what you are asking. Are you asking how to get data _into_ the database?

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 10, 2019, 3:24am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/9 "2019-04-10T03:24:03Z")

</div>

Hello, i already realize, this is only the time range issue. i change the value to CURRENT\_TIMESTAMP, The graph is show when we set time range become today, but, i checked again, the time stored into the grafana is not same as time server. can you help me with this issue ?

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 10, 2019, 7:40am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/10 "2019-04-10T07:40:14Z")

</div>

1. Give an example time it shows for a sample and what you think it should show.
2. If, in Grafana, you set the time range to something like Last 12 Hours does it show the current time at the right hand end of the scale (not the data points but the scale itself). If not then what does it show and what should it show?
3. What is the time zone of the computer running the browser set to?
4. What is the time zone of the computer running the Grafana server set to?
5. What is the time zone of the computer running MSSQL set to?
6. What is your actual time zone?

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 10, 2019, 8:17am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/11 "2019-04-10T08:17:06Z")

</div>

Hello thanks for your repply,

1. for example, i change the time zone to utc, The value shows with the right time,but current times in grafana if i used utc is not correct. like this pict  
 ![capture%201](https://us1.discourse-cdn.com/grafana/original/2X/f/f8b6b9908c44c23fdfb0370e4174779063c31542.png)  
 ![capture%202](https://us1.discourse-cdn.com/grafana/original/2X/b/b231e56bdfccfe7be3fc969d1b240f1e326535b0.png)  
like in the picture, if i change to last 5 minutes, the grafana will shows value with the current time in grafana, but the time is not match with my pc server.
2. And i also realized the weird things, if i set last 12 hours, the values is gone, even though the values i input in mssql is not less than 12 hours in grafana time.  
 ![capture%203](https://us1.discourse-cdn.com/grafana/original/2X/3/315b0fefd1a534e6799a82cbca6c3e42ece4f5e2.png)
3. The time zone of the computer is UTC+07:00
4. Time zone in grafana set as UTC, maybe following international UTC(12:00)
5. Time zone in mssql follow the server, it is UTC+07:100:
6. My actual time zone is UTC:07:00

Regards

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 10, 2019, 8:18am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/12 "2019-04-10T08:18:01Z")

</div>

please focus on the top graph, because the others is using random walk from grafana, thanks

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 10, 2019, 8:44am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/13 "2019-04-10T08:44:07Z")

</div>

On the first graph you have said the value shows the right time. Do you mean it is showing the right UTC time? If so then what is wrong with the first graph? The time axis looks correct as you have asked for today UTC.

Do you actually want to use UTC in grafana? If not then why confuse things by using that to answer the questions? Unless you want to use UTC in grafana it might be better to go back and answer the questions again with grafana set to local time.

On point two you say the data point doesn’t appear if you show last 12 hours, but since you have not told me at what time you expect it to appear that doesn’t help much. If you extend the time range where does the data appear?

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 10, 2019, 8:57am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/14 "2019-04-10T08:57:25Z")

</div>

Correct, i said the values show the right time (mssql and pc time), but if change to last 5 minutes, is it does not appear, because i used UTC in time zone. why i used UTC? because i tried all of the timezone,

first, i try default, the problem is the value cannot get the right time, for example the timestamp is 14:00:00, but it will show in grafana in 17:00:00.

second, i try with local browser, the value stored in grafana is in 17:00:00, but the grafana time(in real time) is 14:00:00.

and the last i used UTC, Is almost same like default, but the different is the value appear in the right time, for example the timestamp is in 14:00:00, but the grafana will following UTC time(in real UTC+12), thats why when i change it to last 5 minutes, the value do not appear.

I think if i used last 12 hour, the value will appear, for example the grafana time is 19:00, and the value time is 14:00, so if the values can show if i choose today, why the values does not appear if i set to last 12 hour?

Regards

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 10, 2019, 9:00am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/15 "2019-04-10T09:00:09Z")

</div>

Sorry, you have completely lost me with all this messing about with time zones. If you like you can start again, stick to local time everywhere, show us what you see and explain what you expect to see.

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 10, 2019, 9:39am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/16 "2019-04-10T09:39:30Z")

</div>

The point is i want to see the time value(in grafana), and in my pc is the same time. i very confused with this issue, because the value i write in mssql is not same as the valu which appear in grafana. I try the same way with influxdb, and it works.

Regards

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 10, 2019, 9:41am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/17 "2019-04-10T09:41:15Z")

</div>

I assumed that is what you want, but you have not posted a simple example showing what you get and what you expected to get.

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [April 10, 2019, 10:04am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/18 "2019-04-10T10:04:26Z")

</div>

@malikiy make sure to store dates in UTC in your table or use epoch (seconds since 1970) which is UTC.

---

<div class="post-metadata">

**Author:** ![clanlaw](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@clanlaw](https://community.grafana.com/u/clanlaw)\
**Post date:** [April 10, 2019, 12:33pm UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/19 "2019-04-10T12:33:37Z")

</div>

I think that probably is the problem (timestamps in the db not in UTC), but can’t be certain till we see exactly what the symptom is.

---

<div class="post-metadata">

**Author:** ![malikiy](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/malikiy/32/6580_2.png) [@malikiy](https://community.grafana.com/u/malikiy)\
**Post date:** [April 11, 2019, 6:54am UTC](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147/20 "2019-04-11T06:54:54Z")

</div>

ok i will use a simple example.

This is query i write to store in mssql:  
INSERT INTO [Dev].[dbo].[metric\_values] (time, measurement, valueOne, valueTwo) VALUES (CURRENT\_TIMESTAMP, ‘Metric A’, 62, 6)  
INSERT INTO [Dev].[dbo].[metric\_values] (time, measurement, valueOne, valueTwo) VALUES (CURRENT\_TIMESTAMP, ‘Metric B’, 49, 11)  
INSERT INTO [Dev].[dbo].[metric\_values] (time, measurement, valueOne, valueTwo) VALUES (CURRENT\_TIMESTAMP, ‘Metric A’, 14, 25)  
INSERT INTO [Dev].[dbo].[metric\_values] (time, measurement, valueOne, valueTwo) VALUES (CURRENT\_TIMESTAMP, ‘Metric B’, 48, 10)

![result](https://us1.discourse-cdn.com/grafana/original/2X/a/a6b898a251749c0532dc9a712fb4e80645a0020f.png)

and i want to show it in grafana, like in the picture, time is using CURRENT\_TIMESTAMP, it will appear a value of current time in server.

But, there is an issue with time zone setting in grafana, if i used default, the (time) in database is not same with the(time) in grafana.

If timezone use default: value appear in database is more faster than real time in server, i give an attachment to proof time is more faster than real time in mssql and pc)

 ![capture%201](https://us1.discourse-cdn.com/grafana/original/2X/6/64b22225c19b8270470964ba6d4c67ca7b4a9e10.png)  
 ![capture%202](https://us1.discourse-cdn.com/grafana/original/2X/8/81b6091c66d2a22b2729cddaa7f55fae606df018.png)

if timezone use local time browser: This timezone have a same issue.

 ![capture%203](https://us1.discourse-cdn.com/grafana/original/2X/8/8049123a4fb4f36ec73a69eb2a2af217c5a01051.png)  
 ![Capture%204](https://us1.discourse-cdn.com/grafana/original/2X/c/c4e32a72202602985aab225d3bd091dd3fbc9702.png)

If timezone use UTC: The value appear in database already have a same time with Real time in mssql and pc), but if i use utc, i know real time in grafana will follow UTC+12:00, so if i used last 5 minutes, it will not appear, because real time in grafana is following UTC+12:00(UTC international), so this is not fix my issue.

my expect is the data can be appear in the same time with grafana,mssql, and pc. I already change time setting in my pc to UTC+12:00, but the data but delay 12 hours. i will give an attachment to proof.  
capture 5 & 6: time setting(pc) use UTC+7:100:  
capture 7,8,9,10: time setting (pc) use UTC+12:00:

 ![Capture%205](https://us1.discourse-cdn.com/grafana/original/2X/c/cc67acdb59daab3bdc1771188c1420be30db539d.png)  
 ![Capture%206](https://us1.discourse-cdn.com/grafana/original/2X/1/1c66a60b3253425a82ecd0a27752811767d86b51.png)

![Capture%207](https://us1.discourse-cdn.com/grafana/original/2X/5/54aacc98d795130a5683964bc76daa10845177d4.png)  
 ![Capture%208](https://us1.discourse-cdn.com/grafana/original/2X/a/ac68ad4e6f104837042f11f741b07ac1340a061e.png)

 ![Capture%209](https://us1.discourse-cdn.com/grafana/original/2X/a/adab972619f20c8f67ba4d492eb9bf5c2386f62b.png)  
 ![CAPTURE%2010](https://us1.discourse-cdn.com/grafana/original/2X/8/8ded870d8d17f31f775b90ee5b5f5b3a0768a90d.png)

Capture 9 & 10: The value appear in grafana already same like pc & mssql time, but real time in grafana becom delayed 12 hours.

Regards

[Next page](https://community.grafana.com/t/grafana-graph-data-source-microsoft-sql-server/16147.md?page=2)
