Bar Graph is not plotting properly [its spread over complete x-axis]

Hi Team,

response:Object
results:Object
A:Object
refId:“A”
meta:Object
series:Array[1]
0:Object
name:“Wrong AOTS Ticket Associated”
points:Array[154]
0:Array[1,1508868168000]
1:Array[null,1509145867000]
2:Array[null,1509742563000]
3:Array[null,1509743378000]
4:Array[null,1509743933000]
5:Array[1,1510248873000]
6:Array[1,1510331509000]
7:Array[null,1510335770000]
8:Array[null,1510339356000]
9:Array[1,1510341748000]
10:Array[null,1510343671000]

This is the data format .
when i try to plot it i get bar graph like below .
can i know what is the error .

I have changed null value as “null as zero” .

Hi,

What data source are you using? Looking at some of the data points I can see that they’re outside the time range of your screenshot - how come? Maybe you can include a screenshot of the metrics tab.

Marcus

Yes when i use bar graph plugin , data points goes outside the time range but when i use line graph it remains normal and correct according to the data points .

Hi,

Could you please include screenshot of your queries, i.e. the metric tab? Thanks

Marcus

Can you try and add the order by to the second query.

Marcus

Even if i add …
its not working …
i had same issue from long time with many data …
all data points will work with line graph properly … bar graph is not plotting properly

Please refer to the time series queries documentation for mysql in Grafana.

So would any of the following queries work better? I’m a bit unsure about your time_sec column which may result in that below queries don’t work. What values and data type does time_sec column have?

SELECT
  $__timeGroup(time_sec,'5m') as time_sec,
  entity_count as value,
  "Network Ticket" as metric
FROM networkTicket
WHERE $__timeFilter(time_sec)
GROUP BY 1
ORDER BY 1
SELECT
  cast((time_sec/1000 as signed integer)) as time_sec,
  entity_count as value,
  "Network Ticket" as metric
FROM networkTicket
WHERE $__timeFilter(time_sec)
GROUP BY 1
ORDER BY 1

Marcus

I am seeing the same thing. On my local pre-production environment, I am seeing the bar chart rendered correctly, as:

However, on my production environment, I am seeing a complete mess (made more apparent by using a line plot):

Both graphs have an identical query:

SELECT date_trunc('hour', observation_date) AS time, COUNT(date_trunc('hour', observation_date)) AS "Total"
FROM global
WHERE  $__timeFilter(observation_date)
GROUP BY time;

I am struggling to understand why the production graph is not rendering correctly. Both running 4.6.3.

1 Like

Adding an additional ORDER BY time fixed it, but odd that this is not required on the pre-production grafana!

1 Like

Do you run the same Grafana versions on both environments? Are you using the same mysql instance or different - maybe one of the instances sorts the results automatically and the other don’t?

You should always add the ORDER BY to make sure that the data are sorted correctly.

Regarding the display as graph problem you first had I can confirm that using the $__timeGroup macro of for example 10s resolves the problem even though all my timestamps were written each 10s. Cannot answer why this is, but comparing with the postgres data source it doesn’t have the same problem.

Marcus

1 Like

Hi,

Is $_timeGroup function has been added to new release .
because Danielle said its not yet release .

Hi,

$_timeGroup macro function is not included in latest stable Grafana release v4.6.3, but are included in the latest nightly build, i.e. latest commits from Grafana master branch.

Marcus

Can i know , is it stable version to download and use it.
as i will be using it in production

Please read my comment in Best way how to install 5.0 nightly beside production 4.6 carefully

Marcus