Grafana: Difference between revisions
| Line 18: | Line 18: | ||
===Custom Colors in Pie Graph=== | ===Custom Colors in Pie Graph=== | ||
Specify custom colors for each series by editing the JSON data directly. There should be an <code>aliasColors</code> field which needs to be populated. For example: | Specify custom colors for each series by editing the JSON data directly. There should be an <code>aliasColors</code> field which needs to be populated. For example: | ||
{{Highlight | |||
{| class="wikitable" | |||
|{{Highlight | |||
| code = "aliasColors": { | | code = "aliasColors": { | ||
"1 min to 10 min": "#3b7dd0", | "1 min to 10 min": "#3b7dd0", | ||
| Line 30: | Line 31: | ||
}, | }, | ||
| lang = json}} | | lang = json}} | ||
|[[File:Grafana Pie Graph.jpg|alt=Grafana Pie Graph with custom colors|thumb|210x210px|Grafana Pie Graph with custom colors|none]] | |||
|} | |||
===Ordering Series=== | ===Ordering Series=== | ||
When making a line graph, I wanted to order series in a specific order. The best way I found was to just have multiple queries selecting specific series in a particular order. | When making a line graph, I wanted to order series in a specific order. The best way I found was to just have multiple queries selecting specific series in a particular order. | ||
Revision as of 16:57, 14 January 2021
Grafana is a tool to generate graphs and dashboards.
Random Notes
Pie Graph using MySQL
With the following query, I am able to generate a two column result set which I want to put into a pie graph.
SELECT requested_cpu, COUNT(requested_cpu) FROM `jobs` GROUP BY requested_cpu ORDER BY `COUNT(requested_cpu)` DESC
However, the Grafana Pie Graph plugin requires the result to be a time series. To work around this, add the timeseries with the current timestamp and ensure that the metric is a char type.
SELECT now() as time_sec, COUNT(requested_cpu) as `value`, CONVERT(requested_cpu, char) as metric
FROM `jobs` WHERE $__timeFilter(started)
GROUP BY requested_cpu
Custom Colors in Pie Graph
Specify custom colors for each series by editing the JSON data directly. There should be an aliasColors field which needs to be populated. For example:
Ordering Series
When making a line graph, I wanted to order series in a specific order. The best way I found was to just have multiple queries selecting specific series in a particular order.
