ilgizar / ilgizar-candlestick-panel

Grafana candlestick panel plugin
MIT License
225 stars 55 forks source link

Add screenshot of Metrics tab to Readme #16

Open bdonnahue opened 6 years ago

bdonnahue commented 6 years ago

I am trying to get the plugin working but the query is where i get stuck. could you add a screenshot of the Metrics tab so I can see why no datapoints are being displayed.

bdonnahue commented 6 years ago

I have been debugging this a bit. I have four queries but I am still stuck.

bdonnahue commented 6 years ago

Ok I got it working.

I probably should have noted earlier that I am using mysql. I needed to add four separate queries:

SELECT
  UNIX_TIMESTAMP(date_time) as time_sec,
  open as value,
  'open' as metric
FROM sampledata2;

SELECT
  UNIX_TIMESTAMP(date_time) as time_sec,
  high as value,
  'high' as metric
FROM sampledata2;

SELECT
  UNIX_TIMESTAMP(date_time) as time_sec,
  low as value,
  'low' as metric
FROM sampledata2;

SELECT
  UNIX_TIMESTAMP(date_time) as time_sec,
  close as value,
  'close' as metric
FROM sampledata2;

The interesting thing about the MySQL backend in this situation is that it requires the query to return columns with a particular name as described here: http://docs.grafana.org/features/datasources/mysql/

The column named "metric" is used as the metric name and used to distinguish between sets of metrics. With the way the plugin is currently written , on line 105 of calndlestick_ctrl.js the metric is being resolved as the alias. This means that only one candlestick can be displayed per graph.

@ilgizar can you think of any way around this problem?

avgdev commented 5 years ago

This is how I got it to work with Mysql

screen shot 2018-09-14 at 10 15 03 am