I'm setting up Grafana for a internal dashboard for the company I work at. We have a phone system that we track, and have metrics saved in a database. I've extracted key metrics and stored them on a Postgres database. Here is what it looks like:
postgres=# SELECT * FROM phonedata LIMIT 5;
id | date | data
----+------------+----------------------------------------------------------------------------------
16 | 2019-05-27 | {"avgDuration": "608", "avgQueuetime": "0:02:46.716667", "voicemailCount": "6"}
17 | 2019-05-26 | {"avgDuration": "676", "avgQueuetime": "None", "voicemailCount": "0"}
18 | 2019-05-25 | {"avgDuration": "506", "avgQueuetime": "0:01:32.684211", "voicemailCount": "1"}
19 | 2019-05-24 | {"avgDuration": "540", "avgQueuetime": "0:02:14.784091", "voicemailCount": "11"}
20 | 2019-05-23 | {"avgDuration": "616", "avgQueuetime": "0:03:09.433962", "voicemailCount": "10"}
(5 rows)
This data shows the statistics for the date as shown in the "date" column. This all works fine. I have data for the last 90 days so there is no problem with lack of data.
Now I'm trying to make a graph on Grafana that shows the average duration of a phone call per day, bit I can't get it working.
Here is a link to a image of the code I have written and the graph on Grafana. StackOverflow won't let me post the image directly
https://i.imgur.com/3uQe9t5.png
Here is the code written out:
SELECT
date AS "time",
data->>'avgDuration'::VARCHAR as "values"
FROM
phonedata
WHERE
$__timeFilter(date) AND
data->>'avgDuration' NOT ilike 'None'
ORDER BY 1
I feel like I'm very close but not quite there yet. I have tried many different variations on this but can't figure it out.
Any help would be tremendous.
Thanks
(I'm running Grafana v5.4.2 (commit: d812109))
