I don't know a lot about MyQSL.
Here is my code (to extract code from a monitoring tool)
SELECT DISTINCT
FROM_UNIXTIME(data_bin.ctime), index_data.host_name, index_data.service_description, metrics.metric_name, data_bin.value
FROM metrics
inner join index_data ON index_data.id = metrics.index_id
inner join data_bin ON data_bin.id_metric = metrics.metric_id
ORDER BY data_bin.ctime;
Despites my efforts, I don't manage to :
- Filter by timerange (with human readable time)
- Obtain that output :
Timerange, Hostname, ServiceA, metricA1, metricA2, ... ServiceB, metricB1, metricB2 ... -> the goal is to group by identical Timerange and Hostname
I think your question is missing some key points, and I'll adjust this if you can specify what you're looking for a bit better with some example data from each of these tables.
But in the meantime, I think I have a good understanding, maybe this is what you're looking for: