0

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 :

  1. Filter by timerange (with human readable time)
  2. Obtain that output :

Timerange, Hostname, ServiceA, metricA1, metricA2, ... ServiceB, metricB1, metricB2 ... -> the goal is to group by identical Timerange and Hostname

1 Answers1

0

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:

SELECT DISTINCT
     FROM_UNIXTIME(data_bin.ctime) AS timerange, 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
GROUP BY index_data.host_name, timerange
ORDER BY timerange;
  • Hi, Thanks for your reply. Finally, I had to transform the data with a Python script which I can send you in PM if you're interested. – AnulomaViloa Oct 19 '20 at 11:11
  • Sure go ahead. Did you attempt that query however? –  Oct 19 '20 at 17:11