Postgres json 股票数据到 Grafana Candlestick
我正在尝试使用 Grafana 中的 Candlestick 从 postgres 单元中可视化股票价格随时间、开盘价、最高价、最低价、收盘价、成交量数据的 json 格式。 在 postgres 表 timeseries
中,我有两列:ticker
,它只是股票简称,jsondata
,其格式如下:
{
"c": [
217.68,
221.03,
219.89
],
"h": [
222.49,
221.5,
220.94
],
"l": [
217.19,
217.1402,
218.83
],
"o": [
221.03,
218.55,
220
],
"s": "ok",
"t": [
1569297600,
1569384000,
1569470400
],
"v": [
33463820,
24018876,
20730608
]
}
在 Grafana 中选择Candlestick 可视化我从 postgres 服务器查询:
SELECT
now() as time,
ticker,
jsondata->>'t' as t,
jsondata->>'o' as o,
jsondata->>'h' as h,
jsondata->>'l' as l,
jsondata->>'c' as c
FROM
timeseries
WHERE
ticker = 'a'
所以我在每个单元格中都有数组,如下所示: 图片 但我无法将数组放入行或使其出现在图表中。有什么解决办法吗? 谢谢!
I am trying to visualize stock prices with time, open, high, low, close, volume data in json, from a postgres cell using Candlestick in Grafana.
In the postgres table timeseries
I have two columns: ticker
which is just the stock short name and jsondata
which is formatted like this:
{
"c": [
217.68,
221.03,
219.89
],
"h": [
222.49,
221.5,
220.94
],
"l": [
217.19,
217.1402,
218.83
],
"o": [
221.03,
218.55,
220
],
"s": "ok",
"t": [
1569297600,
1569384000,
1569470400
],
"v": [
33463820,
24018876,
20730608
]
}
In Grafana selecting the Candlestick visualization I am query this from the postgres server:
SELECT
now() as time,
ticker,
jsondata->>'t' as t,
jsondata->>'o' as o,
jsondata->>'h' as h,
jsondata->>'l' as l,
jsondata->>'c' as c
FROM
timeseries
WHERE
ticker = 'a'
So I got arrays in each cell like this:
IMAGE
But I am not able to get the arrays into rows or make it appear in the chart. Is there any solution for this?
Thanks!
The data source is this: https://finnhub.io/docs/api/stock-candles
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们可以使用联合所有的分开查询
db<>>
We can use seperate queries joined with UNION ALL
db<>fiddle here